I must be cursed! It's been nearly 3 years on all the projects on which I stand, the perennial
troll
of Guid vs Identity
back to haunt me.
Let our cap dba (I know ... yuck!) The Guid is evil (except for replication or it has no choice) ... because:
The perfs are just rotten compared to those that would be obtained with an int. I've heard them more than a sneer and ready to support me otherwise .... Well! Visit this
benchmark, and even take 10 minutes to start the test at home ... it's obvious! What is surprising is that many developers, including very bright people, spend beside the point ... I have some already argued to the contrary ... help!
- Let our hat developer:
-
- boulga
and then I close the lid, it works every time with ... it's great the GUID. In a layered architecture, I can generate id in my client layer, associate entities between them ... then:
If I want to continue, no worries, not going back with the third persistence (database), my credentials are certainly unique.
If I want to cancel everything I do, I hide methodically bah everything under the carpet (read: I leave work the garbage collector). While a
Int as identifier, what is annoying ... I create an entity on my client but as I did not go back with my database I have no way of knowing its identifier ... You want to associate a product and product category while two newly created? Possible, but we'll have to write some code and make roundtrips to the database. Anyway ... seen from the above identity is boring ... we agree.
PS To those I would say we are not obliged to make applications in separate layers ... well .... They are right, but on a large project a minimum ca soon becomes difficult to maintain code in any form (as well as web win) ... need you to take a look at TDD.
That is the beginning that I believe our real work. We must consider the advantages and disadvantages of both approaches, and make a choice between pure performance of the base and roughly the speed of application development at a time ... or the word agility and mouth all, the choice is quickly made ... Mister y 'promised some time I managed to still do the splits ...
Well all this is fine, but then someone could explain why it happens to fall on a basis that are riddled with GUID (only data type used as the primary key table) when they are attacked by an application client-server mode? Frankly, beyond me!
Well, go for those who managed to read me so far, here are some additional links on the topic:
The roots of the problems with the GUID Clustered indexes
the SQL-SERVER NEWSEQUENTIALID ()
if we love the GUID in SQL and we can not do without. And the best for last, I let you think about the following sentence found in the MSDN
:
Consider using the Identity property When global uniqueness is Not required, or When Having a serially incrementing Key is preferred.
course, if some of you we want to troll on the subject ... the comments are made for that:)
0 comments:
Post a Comment