Allocated sequence values can leave gaps while a primary key separately enforces stored-row uniqueness.

A sequence allocates numbers independently of rollback

A PostgreSQL sequence allocates numbers independently of whether the caller’s transaction eventually commits. That makes ordinary identifier generation practical under concurrency, but it also makes gaps normal. A sequence number describes an allocation; it does not prove that a row exists, that a transaction committed, or that every smaller number has been used. ...

April 12, 2027 · 5 min · XB Field Notes