Plan nodes · Grouping and sorting

Limit

Stops after the first N rows (LIMIT and OFFSET).

Returns at most the requested number of rows, skipping the OFFSET first, and then stops asking its child for more. Because of that, a plan under a Limit is chosen for how fast it returns its first rows, not all of them.

Example

SELECT * FROM tracks ORDER BY ms, name LIMIT 10

3 nodes

Run with EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) on the sample database, PostgreSQL 19.0. Open it in the EXPLAIN visualizer →

Related

Sort · Incremental Sort · Aggregate · Group · Unique · WindowAgg