PostgreSQL

PostgreSQL LIMIT

Restrict how many rows a query returns.

Limit results

SELECT * FROM products
ORDER BY year DESC
LIMIT 5;

Use OFFSET to skip rows, commonly for pagination. Always use ORDER BY when the selected rows must be predictable.

SELECT * FROM products
ORDER BY name
LIMIT 10 OFFSET 20;