{
  "id": 19677969,
  "title": "A created_at-only cursor lost 587 rows, even with clock_timestamp() and microseconds",
  "url": "https://urgent.news/2026/11/12/a-created-at-only-cursor-lost-587-rows-even-with-clock-timestamp-and",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-12T17:04:19.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/muhammad_adnan_61b78b9816/a-createdat-only-cursor-lost-587-rows-even-with-clocktimestamp-and-microseconds-12d0"
  },
  "original_language": "en",
  "account": "A reader inquired about the need for an `id` column in a pagination index. The author measured the effect of using `clock_timestamp()` instead of `now()` in a PostgreSQL 16 environment. The table was filled with concurrent inserts and a bulk insert. The author found that using only the timestamp column for pagination resulted in rows being lost. This was because when the cursor ended on a timestamp shared by other rows, those other rows were skipped on the next request. Adding the `id` column to the cursor and ordering by both timestamp and `id` resolved the issue, as the tuple comparison `(created_at, id)` ensured each row was returned uniquely. The author suggests encoding the timestamp and a unique tiebreaker in the cursor, and testing for any missing rows in the table.",
  "summary": "A reader on one of my Postgres posts asked a fair question: why put id in the pagination index at all? With clock_timestamp() instead of now() , it's hard to create two rows at exactly the same time. So I measured it. The setup PostgreSQL 16, a 4-vCPU machine. The table is the one every app has: CREATE TABLE concurrent ( id bigserial PRIMARY KEY , created_at timestamptz NOT NULL DEFAULT…",
  "key_points": [
    "Using clocktimestamp() instead of now() in PostgreSQL 16 caused lost rows.",
    "Pagination index lost 587 rows due to cursor ending on shared timestamps.",
    "Adding id column and ordering by (createdat, id) resolved row loss issue."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}