Guid is a horrible, worst case choice for a clustered index. You are splitting pages every time a new record is inserted, leading to fragmentation and inefficient lookups. A clustered index key should be narrow and monotomically increasing. Use an identity column for the clustered key, and have another index for the GUID that you use to actually locate records. You will find that space requirements decrease, and performance increases.
David
marrowyung
ASKER
aneeshattingal:
You mean using SEQUENTIALID() for the value on that colume instead of GUID ? That function only availble on SQL 2012 or SQL 2008 SP3?
anyoneis:
so you mean on that colume with GUID to replace with identity colume? or SEQUENTIALID() as what aneeshattingal said ?
I don't understand why spliting page everytime a new record is insert, please explain further. It seems that rebuilt index can help on this if defragementation can help, right?
This make a lot of sense to me as the GUID originally is not in order, that's why a new GUID created, we don't where the clustered key created and it MAY have a lotof chance that it has to insert between physical page, as the clustered key will be very large, page split will happen, is that right ?
I attended the TechEd about the SEQUENTIALID(), it exists since SQL 2012.
Anthony Perkins
I attended the TechEd about the SEQUENTIALID(), it exists since SQL 2012.
Then you appear to have totally misunderstood what was presented:
NEWSEQUENTIALID() has been around since SQL Server 2005 and unlike NEWID() is a an incremental GUID that avoids some of the problems of using NEWID() as a clustered index. You can read about it here: http://msdn.microsoft.com/en-us/library/ms189786(v=sql.90).aspx
What SQL Server 2012 introduced was a SEQUENCE object (not a function). This allows you to create an incremental numeric (not a GUID) that is global (and not tied to a table). You can read about it here: http://msdn.microsoft.com/en-us/library/ff878091.aspx
internally, it's some datetime part, some machine "id" part, and some "random" part.
for the newsequentialid, this is solved a bit differently, but still ...
hope this helps
marrowyung
ASKER
angelIII,
"but still ..."
oh,, it means it still got problem.
We are trying to take it off as this is the old design. AHAHAHA
Guy Hengel [angelIII / a3]
well, as written previously:
UUID field is usually not the field to be the clustered index.
change that, and the problem should be solved?!
David