Discussion:
[nhusers] Guid vs Guid.Comb - what is the difference?
Felipe Oriani
2016-02-25 18:58:04 UTC
Permalink
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
***@gmail.com
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Fran Knebels
2016-02-25 19:10:40 UTC
Permalink
I'd say just google for it.

https://www.google.com/search?q=guid.comb+performance&oq=guid.comb+performance&aqs=chrome..69i57.4210j0j7&sourceid=chrome&es_sm=122&ie=UTF-8

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.
Post by Felipe Oriani
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
--
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
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
f***@free.fr
2018-03-14 15:24:54 UTC
Permalink
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.
Post by Fran Knebels
I'd say just google for it.
https://www.google.com/search?q=guid.comb+performance&oq=guid.comb+performance&aqs=chrome..69i57.4210j0j7&sourceid=chrome&es_sm=122&ie=UTF-8
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.
Post by Felipe Oriani
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
--
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
<javascript:>.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Loading...