By BrainSoft | 5 19 September 2026
A table with a few million rows and an ORDER BY created_at DESC LIMIT 20 OFFSET 400000 query looks fine in development. On production data the page takes four seconds, the database burns CPU, and the API starts timing out under load. The query is not slow because the table is big. It is slow because the database has to walk and throw away every row before th ...