<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Are GUIDs Really the Way to Go?</title>
	<atom:link href="http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go</link>
	<description>(permanently in beta)</description>
	<lastBuildDate>Mon, 09 Jan 2012 20:21:24 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Strider</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-5118</link>
		<dc:creator>Strider</dc:creator>
		<pubDate>Wed, 28 Jul 2010 12:22:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-5118</guid>
		<description>You are missing a HUUUUUGE pro of using GUID&#039;s. When having to persist entities to a DB that reference each other, you can generate the PK in code without having to go to the DB first to try and find your next available sequence. 

e.g.    PK = GUID.NewGuid()
         insertPerson(PK,&#039;john&#039;)
         insertChild(GUID.NewGuid(),&#039;peter&#039;,PK) =&gt; peter is now a child of john

with an integer sequence, you would have had to do a query first to determine the next sequence to use as PK, instead of using GUID.NewGuid().</description>
		<content:encoded><![CDATA[<p>You are missing a HUUUUUGE pro of using GUID&#8217;s. When having to persist entities to a DB that reference each other, you can generate the PK in code without having to go to the DB first to try and find your next available sequence. </p>
<p>e.g.    PK = GUID.NewGuid()<br />
         insertPerson(PK,&#8217;john&#8217;)<br />
         insertChild(GUID.NewGuid(),&#8217;peter&#8217;,PK) => peter is now a child of john</p>
<p>with an integer sequence, you would have had to do a query first to determine the next sequence to use as PK, instead of using GUID.NewGuid().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Larry Groove</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-4923</link>
		<dc:creator>Larry Groove</dc:creator>
		<pubDate>Tue, 12 Jan 2010 05:57:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-4923</guid>
		<description>After supporting several C# apps that were heavily GUIDed on the database side I am with you. There are clearly situations where a GUID is a very useful feature. Useful enough to make it worth using such cryptic IDs. 

As much as possible I still find a way to tie a GUID to an integer ID they are just easier to work with remember and COMMUNICATE. I cannot emphasize enough the value of these attributes in troubleshooting situations. In the end I agree that </description>
		<content:encoded><![CDATA[<p>After supporting several C# apps that were heavily GUIDed on the database side I am with you. There are clearly situations where a GUID is a very useful feature. Useful enough to make it worth using such cryptic IDs. </p>
<p>As much as possible I still find a way to tie a GUID to an integer ID they are just easier to work with remember and COMMUNICATE. I cannot emphasize enough the value of these attributes in troubleshooting situations. In the end I agree that</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ritchie Annand</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-4843</link>
		<dc:creator>Ritchie Annand</dc:creator>
		<pubDate>Mon, 11 May 2009 16:25:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-4843</guid>
		<description>The major appeal of GUIDs to me ended up being their ease of use in a distributed system - e.g. a whole mess of remote-area laptops and a couple of satellite offices, apart from the main office.

You no longer have to check out key ranges from a central repository or, worse yet, deal with the after-effects of someone installing, getting a key range, and then *ghosting the machine*. That&#039;s not fun.

There are other schemes for merging data in non-ranged, non-GUID systems, but they&#039;re not pretty.</description>
		<content:encoded><![CDATA[<p>The major appeal of GUIDs to me ended up being their ease of use in a distributed system &#8211; e.g. a whole mess of remote-area laptops and a couple of satellite offices, apart from the main office.</p>
<p>You no longer have to check out key ranges from a central repository or, worse yet, deal with the after-effects of someone installing, getting a key range, and then *ghosting the machine*. That&#8217;s not fun.</p>
<p>There are other schemes for merging data in non-ranged, non-GUID systems, but they&#8217;re not pretty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-3675</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Wed, 28 May 2008 14:54:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-3675</guid>
		<description>If you&#039;re interested, we did a podcast about UUIDs in the database:

http://www.basementcoders.com/2008/5/12/episode-2-uuids

Enjoy!</description>
		<content:encoded><![CDATA[<p>If you&#8217;re interested, we did a podcast about UUIDs in the database:</p>
<p><a href="http://www.basementcoders.com/2008/5/12/episode-2-uuids" rel="nofollow">http://www.basementcoders.com/2008/5/12/episode-2-uuids</a></p>
<p>Enjoy!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian H.</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-3667</link>
		<dc:creator>Brian H.</dc:creator>
		<pubDate>Mon, 26 May 2008 19:56:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-3667</guid>
		<description>It is not at all unusual to use chars as primary keys in some situations (for example, a well-defined code universe, such as states, country codes, sex codes, race codes, etc.). In fact, this is the correct modeling technique (natural keys) in many situations. It would be retarded to create a reference table where 17 stands for New York state instead of &quot;NY&quot;. (No, this is not the same situation as using a natural key in a master table, such as using an SSN for an Employees table. Different table types call for different considerations.) Your statement that DBMS architects &quot;really had integers in mind for primary keys&quot;, that anything other than integers is &quot;flirting with a less-well-tested-use-case&quot; is wrong, very wrong, on both the technical and the relational-theory level, and reveals you as a someone who has not done much reading. You would strengthen your post by removing this claim.

Also, for SQL Server at least, GUIDS have their own 128-bit type called &quot;uniqueidentifier&quot;. The Microsoft middleware layers (OLE-DB, ADO.NET, the CLR) also have this type. So on that platform at least, your varchar argument doesn&#039;t hold water. The argument against GUIDS on that platform is that 128 bits is more than 32 bits, and GUIDS do not cluster as nicely as an auto-incrementing integer.</description>
		<content:encoded><![CDATA[<p>It is not at all unusual to use chars as primary keys in some situations (for example, a well-defined code universe, such as states, country codes, sex codes, race codes, etc.). In fact, this is the correct modeling technique (natural keys) in many situations. It would be retarded to create a reference table where 17 stands for New York state instead of &#8220;NY&#8221;. (No, this is not the same situation as using a natural key in a master table, such as using an SSN for an Employees table. Different table types call for different considerations.) Your statement that DBMS architects &#8220;really had integers in mind for primary keys&#8221;, that anything other than integers is &#8220;flirting with a less-well-tested-use-case&#8221; is wrong, very wrong, on both the technical and the relational-theory level, and reveals you as a someone who has not done much reading. You would strengthen your post by removing this claim.</p>
<p>Also, for SQL Server at least, GUIDS have their own 128-bit type called &#8220;uniqueidentifier&#8221;. The Microsoft middleware layers (OLE-DB, ADO.NET, the CLR) also have this type. So on that platform at least, your varchar argument doesn&#8217;t hold water. The argument against GUIDS on that platform is that 128 bits is more than 32 bits, and GUIDS do not cluster as nicely as an auto-incrementing integer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose Noheda</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-2512</link>
		<dc:creator>Jose Noheda</dc:creator>
		<pubDate>Fri, 16 Nov 2007 08:22:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-2512</guid>
		<description>@Peter: Yes, thank you. We took another approach with custom user types. We noticed it when loaded a couple million rows in a table :-)</description>
		<content:encoded><![CDATA[<p>@Peter: Yes, thank you. We took another approach with custom user types. We noticed it when loaded a couple million rows in a table <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Mularien</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-2511</link>
		<dc:creator>Peter Mularien</dc:creator>
		<pubDate>Fri, 16 Nov 2007 01:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-2511</guid>
		<description>@Jose - one thing to be careful of with Oracle and RAW datatypes with GUIDs is implicit conversion of Strings to RAW and vice-versa. We ran into performance problems with the exact same setup as you until we created function-based indexes with RAWTOHEX on the RAW columns. Just something to be aware of :)</description>
		<content:encoded><![CDATA[<p>@Jose &#8211; one thing to be careful of with Oracle and RAW datatypes with GUIDs is implicit conversion of Strings to RAW and vice-versa. We ran into performance problems with the exact same setup as you until we created function-based indexes with RAWTOHEX on the RAW columns. Just something to be aware of <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-2505</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Thu, 08 Nov 2007 18:49:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-2505</guid>
		<description>@Jay
Just for the record, in your situation I would be very much *in favor* of using GUIDs.  :-)  When you&#039;ve got a setup that&#039;s permuted across multiple disparate servers like that, I think it&#039;d probably be most flexible to go with something more &quot;guaranteed unique&quot; than an auto-incremented BIGINT.</description>
		<content:encoded><![CDATA[<p>@Jay<br />
Just for the record, in your situation I would be very much *in favor* of using GUIDs.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   When you&#8217;ve got a setup that&#8217;s permuted across multiple disparate servers like that, I think it&#8217;d probably be most flexible to go with something more &#8220;guaranteed unique&#8221; than an auto-incremented BIGINT.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Levitt</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-2504</link>
		<dc:creator>Jay Levitt</dc:creator>
		<pubDate>Thu, 08 Nov 2007 18:44:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-2504</guid>
		<description>@rektide: Just saw your post above.  Permuting the GUID doesn&#039;t help, though; if the application&#039;s permuting it, then the application still has to know which DB it wrote to before finalizing the GUID.  And if the database is permuting it, then the application still has to wait for the database response to find out the GUID.  Either way, you don&#039;t get the &quot;I can make [fewer] round trips to the database&quot; benefit that the Gospels promise us.

@Daniel: Yep, you understand exactly.  Maybe that&#039;s not generally needed anymore; at the time, database-layer clustering solutions were immature and not very performant.  Still, I have to figure that at some level - either in the application, or hidden in the clustering layer - that&#039;s what&#039;s happening.  I mean, somehow, when I SELECT by primary key, some layer has to be able to find that record from among multiple servers.

I think you&#039;re right - that the database has to generate the GUID, just as we did it.  Which removes the big GUID &quot;win&quot; of &quot;Hey, now I don&#039;t have to wait for the database to respond with its auto-generated ID!&quot;.

So I&#039;m curious to hear how the pro-GUID camp handles that... rektide, Ryan?</description>
		<content:encoded><![CDATA[<p>@rektide: Just saw your post above.  Permuting the GUID doesn&#8217;t help, though; if the application&#8217;s permuting it, then the application still has to know which DB it wrote to before finalizing the GUID.  And if the database is permuting it, then the application still has to wait for the database response to find out the GUID.  Either way, you don&#8217;t get the &#8220;I can make [fewer] round trips to the database&#8221; benefit that the Gospels promise us.</p>
<p>@Daniel: Yep, you understand exactly.  Maybe that&#8217;s not generally needed anymore; at the time, database-layer clustering solutions were immature and not very performant.  Still, I have to figure that at some level &#8211; either in the application, or hidden in the clustering layer &#8211; that&#8217;s what&#8217;s happening.  I mean, somehow, when I SELECT by primary key, some layer has to be able to find that record from among multiple servers.</p>
<p>I think you&#8217;re right &#8211; that the database has to generate the GUID, just as we did it.  Which removes the big GUID &#8220;win&#8221; of &#8220;Hey, now I don&#8217;t have to wait for the database to respond with its auto-generated ID!&#8221;.</p>
<p>So I&#8217;m curious to hear how the pro-GUID camp handles that&#8230; rektide, Ryan?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go/comment-page-1#comment-2502</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Thu, 08 Nov 2007 18:19:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go#comment-2502</guid>
		<description>Whew!  Complicated setup.  :-)

If I understand you correctly, you&#039;re letting the database generate the int and then ORing it with a shifted database id (in this case, maybe 57 &lt;&lt; 12, depending on how many keys you want to accommodate).  This way you can just mask off the top few bits of the id and know which database you&#039;re looking at.

In such a situation, I think the only way you could keep your round-robin working is to have the database generate a GUID based on an algorithm which would ensure some mathematical property of the GUID was reversable to the database index.  For example, taking the GUID MOD num_databases could return the database index, or something like that.  This could be done using some sort of stored procedure.  When you try the INSERT, you would then pass that stored procedure a parameter giving the database number, which it would use as a seed then in the GUID generation.

Does that make any sense?  Basically, the trick is the same (being able to find the database number from the primary key value), and you absolutely *must* have the key generated on the database server, be it auto incremented or GUID.</description>
		<content:encoded><![CDATA[<p>Whew!  Complicated setup.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>If I understand you correctly, you&#8217;re letting the database generate the int and then ORing it with a shifted database id (in this case, maybe 57 << 12, depending on how many keys you want to accommodate).  This way you can just mask off the top few bits of the id and know which database you&#8217;re looking at.</p>
<p>In such a situation, I think the only way you could keep your round-robin working is to have the database generate a GUID based on an algorithm which would ensure some mathematical property of the GUID was reversable to the database index.  For example, taking the GUID MOD num_databases could return the database index, or something like that.  This could be done using some sort of stored procedure.  When you try the INSERT, you would then pass that stored procedure a parameter giving the database number, which it would use as a seed then in the GUID generation.</p>
<p>Does that make any sense?  Basically, the trick is the same (being able to find the database number from the primary key value), and you absolutely *must* have the key generated on the database server, be it auto incremented or GUID.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

