Keyset pagination is a highly efficient method for retrieving large result sets page by page, but its standard approach faces issues with descending sort orders. Using practical examples in PostgreSQL, the post explores multiple techniques to work around these limitations, including using negative values for descending sorts,

14m read timeFrom cybertec-postgresql.com
Post cover image
Table of contents
An example table for paginated queriesNormal keyset paginationThe problem with keyset pagination in descending and mixed orderKeyset pagination using the negative valueKeyset pagination by splitting up the queryKeyset pagination by defining a custom data typeConclusion

Sort: