A LIMIT clause caps the number of rows returned by a CQL query. It reduces the response sent to an application, but does not reduce the rows ScyllaDB scans. section 7.1.2
Use LIMIT to control result size and support common read patterns:
- Place LIMIT after the WHERE clause and specify the maximum number of returned rows. section 7.1.2
- Use PER PARTITION LIMIT when querying multiple partitions and applying a separate cap to each partition; on one partition, it is effectively equivalent to LIMIT. section 7.1.2
- Combine LIMIT with a WHERE condition based on the previous page to paginate results without using OFFSET. section 7.1.3
Paginating article summaries
A home page can request two summaries with LIMIT 2. To fetch the next page from a descending id order, retain the last id and query with id < 9f545786-704b-11ee-b962-0242ac120002 AND LIMIT 2. Repeat with the last id from each page until fewer rows are returned.
