Guid vs Guid.Comb - what is the difference?

864 views
Skip to first unread message

Felipe Oriani

unread,
Feb 25, 2016, 1:58:31 PM2/25/16
to nhu...@googlegroups.com
Hi everyone. I have a simple question. 

Toda, we can use an Id as a Guid (16-bytes data structure), but, in NHibernate we have two algoritms to use this strategy for Ids. The Guid and Guid.Comb. Look at the code, the Guid just use Guid.NewGuid() from .Net Framework and Guid.Comb has an algorithm that I don't understand very much, but I would like to know more about this topic.

In the Nhibernate Docs I found this about Guids

The guid identifier is generated by calling Guid.NewGuid(). To address some of the performance concerns with using Guids as primary keys, foreign keys, and as part of indexes with MS SQL the guid.comb can be used. The benefit of using the guid.comb with other databases that support GUIDs has not been measured.

What is the major difference? What situation should I use one or other? Is there any difference in the performance? I know it's difficult but can we have conflicts using Guid mapping instead using Guid.Comb in any database? 

The projects we develop uses Ms Sql Server, Oracle and Mysql.

Thank you.

--
______________________________________
Felipe B Oriani

Fran Knebels

unread,
Feb 25, 2016, 2:10:50 PM2/25/16
to nhu...@googlegroups.com
I'd say just google for it.


there's enough information out there about why you'd want to use such a strategy and the performance implications.  

TL;DR; is comb.guid's are seqential so they are better for inserts and indices in relational databases.

What is the major difference? 

comb.guids are sequential

What situation should I use one or other?

I always use comb.guids (sql server and oracle) //i've never used mysql.

Is there any difference in the performance? 

comb.guids should be faster than guid's but not as fast as sql identities

I know it's difficult but can we have conflicts using Guid mapping instead using Guid.Comb in any database? 

comb guids are generated by your code so you can't go inserting records directly into your db without going through your nh layer without messing up the sequential-ness.


--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+u...@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

frederic...@free.fr

unread,
Mar 14, 2018, 11:57:29 AM3/14/18
to nhusers
Better late than never, but one must know that NHibernate guid.comb is sequential from the viewpoint of SQL-Server implementation only. Other databases may sort them differently, and then will not have guid.comb sequentially generated in regard to their implementation.
Reply all
Reply to author
Forward
0 new messages