GUID vs IDENTITY + Bigint for Insert Performance

  • Hi Everyone. I was wondering what the opinions were regarding the use of GUIDs vs IDENTITY as the table PK. Insert performance is top priority. I realize that generating GUIDs is expensive but for a multithreaded application I don’t suffer a serialization problem, one at a time, getting the next Identity value. Maybe the serialization problem doesn’t really exist because the value is generated directly at insert time?

     

    Any thoughts appreciated.

  • Assuming the PK is also a clustered index, using a GUID will lead to a lot of page splits.  It will also take 16 bytes in any indexes that reference it, instead of 4 for an int or 8 for a bigint (although that is more of a concern on read performance).

    If you are doing all of the inserts as a batch, you could possibly generate an int key outside of SQL - although I don't know whether this would be quicker than an identity field.  I would make life easier if you needed to know the key value for some other purpose though, as you wouldn't need to retrieve that value from SQL over and over.

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply