Hacker News new | ask | show | jobs
by lcnPylGDnU4H9OF 370 days ago
> For one, if your IDs are approaching the 2^31 signed integer limit, then by definition, you have nearly two billion rows

Just wanted to nitpick this; this is not actually definitively true. A failed insert in some systems will increment the counter and deleting rows usually does not allow the deleted ID to be re-used (new inserts use the current counter). Of course, that is beside the point: the typical case of a table approaching this limit is a very large table.

1 comments

It's actually fairly common to see this problem crop up in systems that are using a database table as a queue (which is a bad idea for many reasons, but people still do it) in which case the number of live rows in the table can be fairly small.
If a SQLServer instance is killed unceremoniously it adds 1000 to the pk increment.
I'm trying not to imagine the poor SQL Server that has crashed one or two million times and hence pushed the ID values into the billions!
haha—somewhere out there it’s crashing right now. Keep it in your thoughts.