In my application code i am generating GUID using System.Guid.NewGuid() and saving this to SQL server DB.
I have few questions regarding the GUID generation:
- when I ran the program I did not find any problem with this in terms of performance, but I still wanted to know whether we have any other better way to generate GUID.
System.Guid.NewGuid()is this the only way to create GUID in .NET
code?
The GUIDs generated by
Guid.NewGuidare not sequential according to SQL Servers sort order. This means you are inserting randomly into your indexes which is a disaster for performance. It might not matter, if the write volume is small enough.You can use SQL Servers
NEWSEQUENTIALGUID()function to create sequential ones, or just use an int.