Pagination is the practice of dividing a large list of results into smaller chunks, called pages, that are fetched and shown one at a time. It applies to web page listings, database queries and API responses alike.
Why it matters
Returning thousands of rows at once wastes bandwidth, memory and time. Pagination keeps responses fast and predictable. Two common styles exist. Offset pagination uses page and limit (or OFFSET), which is simple but gets slower on deep pages and can skip or repeat items if data changes between requests. Cursor pagination returns a token pointing to the last item seen, which stays efficient and consistent for large or fast-changing data. For websites, crawlable paginated links also matter to search engines.
Example
GET /api/sites?limit=50&cursor=eyJpZCI6MTIzfQ
{
"data": [ ... 50 items ... ],
"next_cursor": "eyJpZCI6MTczfQ"
}
SELECT * FROM sites WHERE id > 123 ORDER BY id LIMIT 50;
Common mistakes
- Paginating without a stable sort order, so pages overlap.
- Using large
OFFSETvalues on huge tables. - Not enforcing a maximum page size.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.