Stop Using OFFSET for Large PostgreSQL Tables: A Practical Guide to Cursor Pagination
Pagination looks like a solved problem until your API starts slowing down on page 500. The first version usually looks harmless: SELECT id , created at , status FROM orders ORDER BY created at DESC LIMIT 20 OFFSET 10000 ; It returns 20 rows. The SQL is simple.