1

I used to have a table with about 1000W data, the primary key column's datatype is uniqueidentifier, and the default value is Newid(). Now there is a performance problem, and I want to change the default value to NEWSEQUENTIALID().

Is it possible for the GUID generated by NEWSEQUENTIALID() to duplicate the data previously saved (previously generated by NewId())?

L.Tim
  • 61
  • 3
  • Keep in mind that `newsequentialid()` creates values "greater than any GUID previously generated by this function on a specified computer since Windows was started". When the OS is restarted, you'll get a new seed value, which may be lower than the previous one, causing index fragmentation. See [this discussion](https://dba.stackexchange.com/q/53617). Also, it specifically mentions windows--not sure how it behaves on Linux. – Bill Jetzer Jul 23 '20 at 15:58

1 Answers1

1

NEWSEQUENTIALID effectively creates a Version 1 UUID.

NEWID creates a Version 4 UUID.

Although NEWSEQUENTIALID does apply some byte scrambling, it does leave the version nybble intact. This means that there's no chance of a collision between a NEWSEQUENTIALID created guid and a NEWID one.

Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448