4 ms·
A database is also exceptionally good at doing transactional stuff like atomically incrementing something. I'd even say: This is something that belongs in the d
by seppel 6y ago
A database is also exceptionally good at doing transactional stuff like atomically incrementing something. I'd even say: This is something that belongs in the database and not in some brittle application logic.
- mtVessel 6y agoGenerally, I agree. But in many RDBMSs, auto-increment features explicitly do not guarantee gap-less sequential ordering. If anything throws, it's easy to end up with discarded numbers, in which case you need to catch all errors, inspect the state of the sequence and/or the entity you're populating, and re-seed the sequence. At this point, I'd argue you've already left the pristine gardens of set theory and wandered into the thorny brambles of app dev.
- LoSboccacc 6y agoah! TIL: MYSQL - https://stackoverflow.com/questions/449346/mysql-auto-increment-does-not-rollback https://stackoverflow.com/questions/449346/mysql-auto-increm... POSTGRES - https://stackoverflow.com/questions/2095917/sequences-not-affected-by-transactions https://stackoverflow.com/questions/2095917/sequences-not-af... thanks!