START clause

The START clause is used to set the index at which to start returning results of a query, with 0 as the starting point.

This simple query demonstrates how adding START 2 will skip over the numbers 1 and 2, returning the output [3, 4, 5].

SELECT * FROM 1, 2, 3, 4, 5 START 2;

This clause is most often paired with LIMIT to perform pagination, to avoid sending messages that exceed a certain size to other pieces of software, and so on.

The following pseudocode demonstrates the most common pattern seen when START and LIMIT are used together.

let current = 0;
loop {
let query = db.query(SELECT * FROM person START {current} LIMIT 100);
if query.is_empty() {
break;
} else {
query.send_to_app();
current += 100;
}
}

Was this page helpful?