So in the middle of basic coding and testing we saw a huge non-patterned jump in Identity values for multiple tables. We are unaware of any server blips or attempted bulk operations, but DBAs are looking into logs.
The gaps are not the typical 1,000 or 10,000 seen with server restarts and such.
The gap for Application_NO
is 10,410,345 for a table with 2,320 rows
Transaction_Payment_NO
jumped an astonishing 1,712,149,313 for a table with 685 records.
Any ideas on what could be causing such large and seemingly arbitrary jumps?
Best Answer
Some possible culprits:
This seems like the most likely reason, as you mentioned you're currently doing testing. Perhaps there are some automated tests being run that make changes to those tables, verify the results, and then roll back the changes.
Identity values are not reused after a transaction has been rolled back, which is what causes you to see large gaps in this scenario.
RESEED
commandYou can manually change the current "next identity" value with this command:
This one seems less likely, because you or one of the admins would have to go out of their way to do it. Similarly...
You can insert whatever you like into an
IDENTITY
column by first running this statement:You mentioned this in the question, but just for completeness - SQL Server caches identity values in order to improve performance. But those pre-allocated identity values can be lost if the service restarts or an AG failover occurs. This leads to more predictable gaps though (10,000 on modern versions of SQL Server).