System Design ($200k+) · STORAGE · Distributed Systems Core · 2026

Keyset (Cursor) Pagination vs SQL OFFSET Pagination

Quick Decision Rule: When Paginating a live 50M-row activity feed where new rows insert continuously and users scroll deeply, choose Keyset / cursor pagination (`WHERE (created_at, id) < ($1, $2) ORDER BY created_at DESC, id DESC LIMIT 50`).

Trigger ConditionPaginating a live 50M-row activity feed where new rows insert continuously and users scroll deeply
Recommended ChoiceKeyset / cursor pagination (`WHERE (created_at, id) < ($1, $2) ORDER BY created_at DESC, id DESC LIMIT 50`)
Classic Trap`OFFSET 500000` forces the database to scan and discard 500k rows AND causes duplicate/skipped items whenever new records are inserted at the top.
VerificationAudited on 2026-11-23 · Distributed Systems Core · 2026

30-SECOND DECISION TRAP CHECK · STORAGE

Test your instinct

An activity feed table holds 80M rows with constant inserts. Page 500 (`ORDER BY created_at DESC LIMIT 50 OFFSET 25000`) takes 4.2 seconds and shows duplicate posts as users scroll. What fixes both issues?

Primary Engineering Documentation

Related Storage Decision Guides