Does anyone ever use database sequences that count down from 2^64-1

identitysequence

Does anyone ever use database sequences that count down from 2^64-1, rather than up from 1, for assigning ids to rows?

The motivation for doing this would be to ensure that any application consuming these ids does not encounter an overflow bug at some bit width < 64, the most obvious being trying to use a 32-bit int to hold the id. If you start at the top, problems should arise sooner during development.

Best Answer

Never seen it done, certainly not for that reason.

Speaking for SQL Server, it would work fine with a Bigint Identity column. But you'd have to ask whether it's worth the confusion it could cause, and the need to remember to define the clustered index descending to prevent fragmentation, etc.