PrepZone Logo
PrepZone
Back to Database

Database · Medium

OFFSET vs keyset pagination — tradeoffs, performance, and when to use each.

DatabaseSQLFresher

Answer preview

Pagination returns a slice of an ordered result. LIMIT ... OFFSET is the obvious approach but the database must read and discard every skipped row, so page 10 000 is slow. Keyset (seek) pagination instead remembers the last row's sort key and uses a WHERE predicate, giving consta…