Most APIs start with offset-based pagination. It feels natural: GET /items?page=500&limit=20 is easy to understand, easy to build, and works seamlessly when your database tables contain a few thousand records.
However, once your database table grows to hundreds of thousands or millions of rows, offset pagination quietly degrades performance and causes subtle data anomalies that frustrate end users.
Here is why offset pagination fails at scale and how cursor-based pagination fixes it.
The Hidden Cost of OFFSET
To understand why offset pagination slows down, look at what the database engine does under the hood when executing an OFFSET query.
SELECT id , title , created_at FROM articles ORDER BY created_at DESC LIMIT 20 OFFSET 100000 ;
Enter fullscreen mode
Exit fullscreen mode
When you request OFFSET 100000 , the database does not magically jump to row 100,001.…