A five-value reservation marks returned one and three, rolled-back two, and never-returned four and five, with a clean-exit abandonment bracket and next backend starting at six.

Postgres sequences hand out numbers with a cache

A PostgreSQL sequence cache reserves values for a database backend, not for an application object or one transaction. The distinction explains why the sequence’s stored state can run ahead of values actually returned, why reconnecting can create holes, and why making CACHE smaller cannot make identifiers gapless. Start by separating allocation state from the rows the application successfully committed. ...

August 2, 2027 · 5 min · XB Field Notes