Jimmy Nilsson discusses his COMB guid concept here. This concept is popular in NHibernate, among other circles, for its supposed performance value over standard GUIDs which are typically far more random.
However, in testing, this does not appear to be the case. Am I missing something?
Test case:
I have a table called temp (not a temp table, just a table named "temp") with 585,000 rows in it. I have a new table called Codes, and wish to copy all 585,000 code values from the temp table to the codes table. The test SQL I executed was:
set statistics time on;
truncate table codes;
DBCC DBREINDEX ('codes', '', 90);
insert into codes (codeid, codevalue)
select newid(), codevalue from temp
truncate table codes;
DBCC DBREINDEX ('codes', '', 90);
insert into codes (codeid, codevalue)
select CAST(CAST(NEWID() AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER), codevalue from temp
Performance with standard GUID values:
SQL Server Execution Times: CPU time = 17250 ms, elapsed time = 15735 ms.
(585000 row(s) affected)
Performance with COMB GUID values:
SQL Server Execution Times: CPU time = 17500 ms, elapsed time = 16419 ms.
(585000 row(s) affected)
What am I missing? the COMB GUID values resulted in slightly longer times, presumably because of the additional conversions. I thought the point was to reduce the insert time by semi-ordering the GUIDS using the date for the last 6 bytes, but the performance gain appears non-existent.