Hacker News new | ask | show | jobs
by slotrans 1026 days ago
Heh, this is pretty great. Is it good or bad that I know almost all of these?

Not sure "SERIAL is non-transactional" belongs at the bottom, I thought that was common knowledge... but that might be from years doing Oracle where sequences are more explicit.

1 comments

Many databases including PostgreSQL have a second reason “serial” sequences may have missing numbers. It’s too inefficient to write to the disk every time you get a new value from the sequence, so sequence transactions use up a batch of consecutive values, not just one. The set of values in the batch is then maintained in memory. If (when) the database crashes, the leftovers can’t be restored to the sequence (since there’s no finer-grained log of them). So on average the sequence will permanently skip half of the batch size on each crash.