views:

364

answers:

2

In a database where all of your primary keys are GUIDs, what are the differences/implications and/or pros and cons using newid() versus newsequentialid() as the "default value or binding".

The only difference that I know of is that newid() creates a new random GUID as opposed to newsequentialid() creates a new GUID based on the last one that is in the table in an incremented fashion.

+2  A: 

As I understand it, when you perform an insert in a row the DB, it will be inserted in order relative to the other PK's in the table. With a normal guid, this could be anywhere in the table. A newsequentialid() will always be added to the end of the table.

So the performance of inserts is improved.

This site explains the differences and benchmarks between the two different methods.

DaRKoN_
Huh? If they are generated sequantially How can it be guarneteed that the GUID generated is actually unique, instead of just being something that looks like a GUID?
Kragen
A: 

as i konw, NEWID() generates the GUID in random order and NEWSEQUENTIALID() generates the GUID in sequential order.NEWSEQUENTIALID() can be used ONLY in default clause of a table.

prince bhardwaj