Limit Query Results

On this page Carat arrow pointing down
Warning:
GA releases for CockroachDB v23.1 are no longer supported. Cockroach Labs will stop providing LTS Assistance Support for v23.1 LTS releases on November 13, 2025. Prior to that date, upgrade to a more recent version to continue receiving support. For more details, refer to the Release Support Policy.

The LIMIT and OFFSET clauses restrict the operation of:

OFFSET instructs the operation to skip a specified number of rows. It is often used in conjunction with LIMIT to "paginate" through retrieved rows.

Warning:

Using LIMIT/OFFSET to implement pagination can be very slow for large tables. We recommend using keyset pagination instead.

Syntax

LIMIT

LIMIT { <limit_value> | ALL }

For PostgreSQL compatibility, CockroachDB also supports FETCH FIRST limit_value ROWS ONLY and FETCH NEXT limit_value ROWS ONLY as aliases for LIMIT. If limit_value is omitted, then one row is fetched.

OFFSET

OFFSET <offset_value> [ ROW | ROWS ]

Examples

For example uses with SELECT, see Limit Row Count.

See also


Yes No
On this page

Yes No