HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

NEWSEQUENTIALID() resets sequence on server restart

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
newsequentialidrestartresetssequenceserver

Problem

MSDN learns me that NEWSEQUENTIALID():


Creates a GUID that is greater than any GUID previously generated by this function on a specified computer since Windows was started. After restarting Windows, the GUID can start again from a lower range, but is still globally unique.

So a newly generated GUID can be lower than a previously generated GUID. Isn't this highly undesirable in terms of index fragmentation and such?
And if so: is there some way to provide NEWSEQUENTIALID with a seed of some sort, to prevent this?

Or isn't this as bad as it seems as seeing the servers won't restart that often en we can deploy maintenance scripts for rebuilding indexes?

Solution

No way to seed it. That whole "globally unique" part gets in the way.

the bigger question here is "do you truly require this?"

GUIDs are big, GUIDs -even with newsequentialid, can lead to index fragmentation. If you need GUIDa where do you need them? They typically do not make great clustered index candidates. For both of these reasons and more.

Context

StackExchange Database Administrators Q#53617, answer score: 2

Revisions (0)

No revisions yet.