Maxim Mironjuk
-
October 23, 2025
Few behaviors of auto-increment sequences unsettle developers as reliably as an ID column with missing values. The reflex to treat that as a bug and fix it with extra logic almost always causes more problems than it solves: locked tables, blocked transactions, and worse scalability. This article explains why gaps are a structurally unavoidable consequence of rollbacks, sequence caching, and concurrent transaction execution, why that is completely harmless in the vast majority of cases, and where the rare, legitimate exceptions lie.