Wednesday, January 27, 2010

NewSequentialID() vs NewID() – SQL Server 2005+

I was not aware of this! – “…using NEWSEQUENTIALID can be faster than using the NEWID function. This is because the NEWID function causes random activity and uses fewer cached data pages. Using NEWSEQUENTIALID also helps to completely fill the data and index pages.”

Update: After the initial euphoria wore off, my more experienced peers were quick to point out that “…the bummer is if you want to generate guids from the app and the database then you can't use sequential –Gregg Stark”… i.e. typically in these scenarios the reason you’re using a GUID in the first place is exactly because you need to generate the IDs from outside of the central database server context where the NewSequentialID() works it’s magic… so you really don’t get to take advantage of it’s index defragging potential (duh :(

0 comments: