liveBook · Manning

LIMIT clause

As explained in ScyllaDB in Action

A LIMIT clause is a CQL query clause that caps the number of rows returned without capping the number of rows scanned.

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.

How ScyllaDB in Action covers it

How deep it goes
Explains syntax, per-partition behavior, pagination, and scan implications, while deferring detailed execution internals.
Examples
Uses article-summary queries showing two-row, oversized-limit, and successive-page results.
What you can do after
Apply it via CQL to cap responses and build page-by-page reads without OFFSET.
How it connects
Connects LIMIT with WHERE clauses, pagination, PER PARTITION LIMIT, OFFSET, partition keys, and descending sort order.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ScyllaDB in Action. The section links point to the parts of the book it draws on.