Offset Pagination
ELI5 — The Vibe Check
Offset pagination is the classic 'skip X rows and give me the next Y rows' approach. Page 3 of 20 results means skip 40 rows and give me 20. It's simple and predictable but can get slow on huge tables and can show duplicate results if data changes between pages.
Real Talk
Offset pagination uses LIMIT and OFFSET in SQL queries (or equivalent) to skip a specified number of records and return the next batch. Simple to implement and understand, but performance degrades on large offsets and results can be inconsistent with live data changes.
Show Me The Code
// Page 3 with 20 items per page
SELECT * FROM posts
ORDER BY created_at DESC
LIMIT 20 OFFSET 40;
When You'll Hear This
"Offset pagination works fine for the admin tables." / "Avoid offset pagination on tables with millions of rows — it's slow."
Related Terms
Cursor Pagination
Cursor pagination uses a 'you are here' bookmark instead of page numbers. After getting results, you get a cursor (pointer) to the last item.
Pagination
Pagination is splitting a huge list of results into pages.
Query Builder
A query builder lets you build database queries by chaining methods instead of writing raw SQL. It's like assembling a sentence with Lego blocks — `.