LIMIT and OFFSET allow you to retrieve just a portion of the rows that is generated by the rest of the query:
selectselect_listfromtable_expression[LIMIT {number| All}] [offsetnumber]
If a limit count is given, no more than that many rows would be returned (but possibly less, if the query itself yields les s rows). Limit all is the same as omitting the limit clause.
OFFSET says to skip this many rows before beginning to return rows. Offset 0 is the same as omitting the offset clause. If both offset and LIMIT appear, then OFFSET rows is skipped before starting to count the LIMIT rows is returned.
When using-LIMIT, it is important-to-use-ORDER BY clause-constrains the result rows into a unique ORDER. Otherwise you'll get an unpredictable subset of the "s rows. is asking for the tenth through twentieth rows, but tenth through twentieth in what ordering? The ordering is unknown, unless your specified ORDER by.
the query optimizer takes limit into when generating a query plan is very likely to get different plans (yielding differ ENT row orders) depending on what give for limit and offset. Thus, using Different limit/offset values to select different subsets of a query Result will give inconsistent results unless you enforce a predictable result ordering with order by. This was not a bug; It is an inherent consequence of the fact that SQL does not promise to deliver the results of a query in any particular or Der Unless order By is used to constrain the ORDER.
The rows skipped by an OFFSET clause still has to be computed inside the server; Therefore a large OFFSET can be inefficient.
Postgresql LIMIT and OFFSET