LIMIT
The LIMIT
statement allows slicing the result array using an offset and a count. It reduces the number of elements in the result to at most the specified number. Two general forms of LIMIT
are followed:
The first form allows specifying only the count value whereas the second form allows specifying both offset and count. The first form is identical using the second form with an offset value of 0.
Above query returns the first five elements of the array of user objects. It could also be written as LIMIT 0, 5
for the same result.
The offset
value specifies how many elements from the result shall be skipped. It must be 0 or greater. The count
value specifies how many elements should be at most included in the result.
In above example, the objects of users are sorted, the first three results get skipped and it returns the next two user objects.
Where a LIMIT
is used in relation to other operations in a query has meaning. LIMIT
operations before FILTER
s in particular can change the result significantly, because the operations are executed in the order in which they are written in the query. See FILTER
for a detailed example.