Generating identifiers.
WHAT AN AUTOINCREMENT COLUMN DOES
Assigns the next number automatically.
WHAT TO KNOW ABOUT GAPS
They are normal and expected.
WHY THEY OCCUR
Rolled back transactions consume values Failed inserts consume values Bulk inserts reserve ranges
WHY THAT MATTERS
Treating identifiers as a count is wrong.
WHAT TO NEVER DO
Rely on them being contiguous Reuse deleted values Expose them where volume is sensitive
WHAT EXPOSING THEM REVEALS
How many records exist, and how fast they grow.
WHAT HAPPENS WHEN THE TYPE RUNS OUT
Inserts fail entirely.
WHY THAT IS A REAL RISK
A small integer type exhausts sooner than people expect on busy tables.
WHAT TO CHECK
The current value against the type's maximum.
WHAT TO DO ABOUT IT
Change the type, before it happens.
WHY BEFORE
The change on a large table takes time you will not have during an outage.
WHAT SEQUENCES PROVIDE IN OTHER DATABASES
Independent generators, usable across tables.
WHAT TO BE CAREFUL WITH IN REPLICATION
Auto-increment offsets, when several servers accept writes.
WHAT TO USE FOR DISTRIBUTED GENERATION
Identifiers designed for it, rather than coordinating counters.
WHAT TO CONSIDER
Whether inserts must remain ordered, which random identifiers break.