SQL Pagination And Keyset

Guides correct, scalable pagination and the row-value machinery behind it. Prefer keyset/seek pagination — `WHERE (sort_key, id) greater than (:last_key, :last_id) ORDER BY sort_key, id FETCH FIRST n ROWS ONLY` — over `LIMIT n OFFSET m`, because `OFFSET` makes the server fetch-and-discard the first m rows (O(offset), so deep pages time out) and is unstable — an insert or delete between page loads shifts the window so the reader skips a row or sees one twice. Teaches the standard `OFFSET. Auto-invokes when writing or editing pagination, `LIMIT`/`OFFSET`/`FETCH` queries, infinite-scroll or cursor/keyset endpoints, multi-column `ORDER BY` with paging, row-value comparisons, or `VALUES` bulk row sets.

ctoth 2851d0c 3 files · 30.1 KB Updated

File contents

ctoth/sql-skills-plugin/tree/main/plugins/sql/skills/sql-pagination-and-keyset commit 2851d0cd66

Frequently asked questions

npx skillmds@latest add ctoth/sql-pagination-and-keyset