Wednesday, March 7, 2012

Identity columns

Can anyone describe how SQLServer calculates identitycolumns? Does it use some internal counter when generating the next identity,or something a little more mundane such as gets the highest existing identityvalue at the point of the insertion and increments it by the IDENT_INCR valueof the identity column?

I'm not worrying about reliability or gaps in values, but iam wondering if it would be less efficient for me to manually manage theidentity/primary key in the form of a counter in another table used to generatethe new identity, or simply let the DB do it for me. I dont mind if there aregaps in the sequence etc. so would it be less efficient for me to calculate thefield than SQLServer itself? Basically, is the overhead to the DB of me doingit greater than the overhead of the app doing it...

Thanks

Here's how the values are calculated:

http://blogs.msdn.com/sqlprogrammability/archive/2006/04/04/567724.aspx

It would take MUCH MORE time for you to do it than letting SQL Server manage it for you. By several orders of magnitude.

|||Thanks for that. how are the 'generated' in memory though without accessing the table?

No comments:

Post a Comment