Pagination that survives inserts

Back to list2026-07-30
You

Offset pagination skips rows when new ones arrive.

ChatGPT

Use a keyset: order by a stable column plus the primary key, and pass the last seen values as the cursor. Offsets are computed against a moving table, which is precisely why rows appear twice or vanish.

Tool steps: 3 (reasoning summary, call to python, execution output)
reasoning summary
Checked the query plan, then compared index options.
call to python
rows = run_sql("EXPLAIN (ANALYZE) SELECT ...")
print(rows[:3])
execution output
Seq Scan on events  (cost=0.00..812431.00 rows=41203122 width=16)
  Rows Removed by Filter: 38996878
Planning Time: 0.214 ms
Execution Time: 11842.663 ms
You

What should an API error body contain?

ChatGPT

A stable machine-readable code, a human sentence, and, when the fault is the client's, which field. Stack traces help nobody outside your team, and a bare 400 turns every integration into guesswork.

You

Path versioning or headers?

ChatGPT

Path versioning, for a small team. It is visible in logs, cacheable, and trivially explained. Header negotiation is more elegant and is the version people get wrong in curl, in caches and in the one client that matters.