LLBLGen wrote:
...But performance is the key for any software to be successful. So is Using GUID a bad choice? Please advise...
FWIW, here is my 2-cents-worth.
I am sorry; but, I have never personally tested the difference between lookup times on a PK-INT versus a PK-GUID. Not formally. Shame on me.
However, I have used PK-GUID and it works great. Small-to-medium size schema, highly-normalized, small-to-medium number of rows, SQL Server 2000. I loved it. So, regarding performance, I did not see a problem in my projects. There are, however, many significant, clear, benefits to using PK-GUID.
Some upsides are...
...PK-GUIDs can be generated in the middle-tier easily, which supports "real" in-memory object creation... which makes building in-memory hierarchies easier... which makes saving in-memory hierarchies easier (probably faster?)... and so on...
...replication, and cross-database data sharing in general, is virutally automatically supported...
...offline applications can create "real" data and sync later without collision...
...the PK is not human-readable and that's good IMHO because no one should be looking at them, mucking with them, creating them in an ad-hoc manner such as in Query Analyzer, and so on... they are a pure abstraction and generally should do their job and stay out of sight and out of mind...
...database design is MUCH easier and the overall model is much more flexible given that an existing database, with data in it, can be refactored completely and seriously without having to worry about how to move and relate data for the new version... this is huge benefit, especially if you are developing RAD/ XP/ Agile style, with lots of versions and lots of courageous changes and lots of refactoring... (that is to say, the way development should be done, BTW)....
...and I think that there a few other upsides...
Some downsides are...
...Oracle does not support/ auto-generate/ use PK-GUID easily, at least not in Version 9, and at least not as far as I could find...
...(BUT, I am sure there is a workaround for this AND this is more of an Oracle-problem than a PK-GUID problem AND one can hope that Oracle moved out of the dark ages (such as all capital column names???) and now supports PK-GUID in Version 10 but I am afraid to check)...
...the PK is not human-readable, and that is bad (according to some) because making data-insert scripts, seeding code tables for initialization, making test data insert scripts, and the like can be tricky...
...(BUT, as I note above, this is actually a good thing and not a bad thing)...
...indexing is slower...
...(BUT, I have heard varying opinions on this, so I really am not so sure about it and have not seen any noticable slowdown AND if your querying takes that long, I say, you might want to revisit the underlying design AND whatever happened to the "no more than N joins per query" rule???... and so on)....
...the datatype itself takes up more room than an int...
...(BUT I stopped caring much about that, for most practical applications, the day people started saying things like "we have to use nvarchar instead of varchar everywhere", I mean sheesh, we just doubled the space requirements so don't cry to me if we use a PK-GUID)...
...and I think that there a few other (alledged) downsides...
The main obstacle that I have found to using PK-GUID is DBAs and developer's who don't like the idea because it is "non standard". Coincidentally, this is the same "pro SPs" crowd who think someone is crazy if they say "let's eliminate 90% of our SPs and, along with them, 90% of our database headaches". Oh well. Its going to take some time for some people to come around.
For me, if I had my druthers, I would use PK-GUID virtually everywhere and virtually always.
IMHO.
(Caveat-- As always, I recognize the fact that I may be wrong. As such, I reserve the right to change my mind. But, I will probably have to "prove it with code" to be convinced.)
HTH.
Thank you.
--Mark Kamoski