<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; GUID vs INT &#8211; Your Opinion</title>
	<atom:link href="http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/</link>
	<description>SQL, SQL Server, MySQL, Big Data and NoSQL</description>
	<lastBuildDate>Wed, 19 Jun 2013 15:04:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Sowmya Murali</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-469787</link>
		<dc:creator><![CDATA[Sowmya Murali]]></dc:creator>
		<pubDate>Mon, 06 May 2013 06:35:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-469787</guid>
		<description><![CDATA[Kindly let me know what would be the recommended option for primary key, given the following scenario. 
 1. Table contains a UUID column and a ID column which is a decimal 
     (28,0)                      
 2. UUID generated is stored in 8 bytes using binary columns
 3. Not a distributed environment
 4. No of rows will be maximum tens of thousands

Is it true that modern recommendations  for table design suggest usage of UUID instead of sequences for security reasons?]]></description>
		<content:encoded><![CDATA[<p>Kindly let me know what would be the recommended option for primary key, given the following scenario.<br />
 1. Table contains a UUID column and a ID column which is a decimal<br />
     (28,0)<br />
 2. UUID generated is stored in 8 bytes using binary columns<br />
 3. Not a distributed environment<br />
 4. No of rows will be maximum tens of thousands</p>
<p>Is it true that modern recommendations  for table design suggest usage of UUID instead of sequences for security reasons?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #027 &#124; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-468660</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #027 &#124; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 04 May 2013 01:31:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-468660</guid>
		<description><![CDATA[[...] GUID vs INT – Your Opinion This is an age old problem and I want to compile the list stating the advantages and disadvantages of using GUID and INT as a Primary Key or Clustered Index or Both (the usual case). The epic intense debate is happening on this particular topic till today after 3 years. You can see there is a wealth of information on this blog which one can just learn reading the original blog post as well as comments associated with the blog post. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] GUID vs INT – Your Opinion This is an age old problem and I want to compile the list stating the advantages and disadvantages of using GUID and INT as a Primary Key or Clustered Index or Both (the usual case). The epic intense debate is happening on this particular topic till today after 3 years. You can see there is a wealth of information on this blog which one can just learn reading the original blog post as well as comments associated with the blog post. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: togakangaroo</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-437301</link>
		<dc:creator><![CDATA[togakangaroo]]></dc:creator>
		<pubDate>Thu, 14 Mar 2013 15:57:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-437301</guid>
		<description><![CDATA[Or just do two ids - a regular PK (int or guid) and a client guid.]]></description>
		<content:encoded><![CDATA[<p>Or just do two ids &#8211; a regular PK (int or guid) and a client guid.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-377245</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 20 Nov 2012 08:18:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-377245</guid>
		<description><![CDATA[Why do you want not to use unique identifier which is solely used for this purpose?]]></description>
		<content:encoded><![CDATA[<p>Why do you want not to use unique identifier which is solely used for this purpose?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bita</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-372090</link>
		<dc:creator><![CDATA[Bita]]></dc:creator>
		<pubDate>Sat, 10 Nov 2012 08:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-372090</guid>
		<description><![CDATA[How can I guarantee uniqueness across the server without using uniqueIdentifier?]]></description>
		<content:encoded><![CDATA[<p>How can I guarantee uniqueness across the server without using uniqueIdentifier?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick932</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-366998</link>
		<dc:creator><![CDATA[Nick932]]></dc:creator>
		<pubDate>Wed, 31 Oct 2012 11:49:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-366998</guid>
		<description><![CDATA[Well a GUID can give me a strong unique id in the world/cosmos for many many years to come.  Statistically, it would take trillions of years to get a duplicate if you would generate 1000s per second.

I should be able to use this uniqueness in many apps.]]></description>
		<content:encoded><![CDATA[<p>Well a GUID can give me a strong unique id in the world/cosmos for many many years to come.  Statistically, it would take trillions of years to get a duplicate if you would generate 1000s per second.</p>
<p>I should be able to use this uniqueness in many apps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Slavius</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-364490</link>
		<dc:creator><![CDATA[Slavius]]></dc:creator>
		<pubDate>Thu, 25 Oct 2012 20:50:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-364490</guid>
		<description><![CDATA[Comparing values that are larger than a CPU&#039;s register is always tricky and has to be performed inside full fences as it is a non-atomic operation.
Assume a 64bit variable on a 32bit system. Comparing it is a 2 step process that can be suspended in-between during regular thread preemption. So thread A is comparing 64bit variable to some other value and is suspended in the middle ater the first half (as only 32 bits fit into CPU&#039;s register at once) while some other thread that becomes alive after the first one gets asleep updates the same variable&#039;s value resulting in inconsistent comparison. This must not happen so a full fence is deployed which introduces performance hit somewhere around 10 - 40ns on 2010-era desktop. The same happens with GUIDs unless 128bit computers and servers become standard.]]></description>
		<content:encoded><![CDATA[<p>Comparing values that are larger than a CPU&#8217;s register is always tricky and has to be performed inside full fences as it is a non-atomic operation.<br />
Assume a 64bit variable on a 32bit system. Comparing it is a 2 step process that can be suspended in-between during regular thread preemption. So thread A is comparing 64bit variable to some other value and is suspended in the middle ater the first half (as only 32 bits fit into CPU&#8217;s register at once) while some other thread that becomes alive after the first one gets asleep updates the same variable&#8217;s value resulting in inconsistent comparison. This must not happen so a full fence is deployed which introduces performance hit somewhere around 10 &#8211; 40ns on 2010-era desktop. The same happens with GUIDs unless 128bit computers and servers become standard.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guy</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-306871</link>
		<dc:creator><![CDATA[Guy]]></dc:creator>
		<pubDate>Thu, 28 Jun 2012 08:49:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-306871</guid>
		<description><![CDATA[Using integer ranges instead of GUIDs:

Note this only works if you have control over every SQL Server to install ranges!!




An alternative to GUIDs is to use int/bigint with ranges on each server in a distrobuted environment.  A word of warning here though, identities do not work, they always take max(id)+1, you have to write a sequence solution or use sequences in SQL Server 2012.  I tried using identities and the first time you sych the data between 2 servers the identies start to clash, or you range constraints raise errors.

The solution I used on SQL Server 2008 was as follows:

1. create a table to hold your sequences {name, currentValue, MaxValue, Increment}

For each PK configure a named sequence (note current value should be initialised to the min of the range or if data exists the table max +1 within the range)  The name of the sequence is just the pk name, I found that the easiest way and most meaningful.

I then create a stored procedure with the following signature

GetNextSequenceValue @sequenceName varchar(128), @value int OUT

In the SP I simply do a lock for update select to get the currect value of the named sequence + 1, check if it is in range, update the sequnce table and set the out value.

I also created a scalar function

GetCurrentSequenceValue( @sequenceName varchar(128))

This simply gives you the current value of a named sequence

I then had to set the default value of the int PK columns in the table to 0 as we will never use a value of 0, it is just a flag to the trigger to get get the next sequence value.

Then I added an instead of insert trigger to the table, where if the PK value is 0 I get the next sequence value using the SP and then do the real insert.  This means that if the PK is not defined in the initial insert, the sequence value is used, if it is defined, the defined value is used, this allows sync to write the PK ids.

Note: no range constraints can be used on the tables, this will cause sync from other ranges to fail, the SP must control the range using the definition from the sequence table.

This solves all issues with guids and integers, except when you have no control over the sql servers are in your system, and configuring the ranges is not posible.

I suggest ranges as follows:

Central server: -2147483647 to -1 (use all negative values gives you the same range as a positive integer)

Client servers: 
First Client: 1 to 99999999
Second Client 100000001 to 199999999
...
Last client 9900000001 to 2147483647


You can always use negatives on clients if the central server makes more sense to have positive IDs.]]></description>
		<content:encoded><![CDATA[<p>Using integer ranges instead of GUIDs:</p>
<p>Note this only works if you have control over every SQL Server to install ranges!!</p>
<p>An alternative to GUIDs is to use int/bigint with ranges on each server in a distrobuted environment.  A word of warning here though, identities do not work, they always take max(id)+1, you have to write a sequence solution or use sequences in SQL Server 2012.  I tried using identities and the first time you sych the data between 2 servers the identies start to clash, or you range constraints raise errors.</p>
<p>The solution I used on SQL Server 2008 was as follows:</p>
<p>1. create a table to hold your sequences {name, currentValue, MaxValue, Increment}</p>
<p>For each PK configure a named sequence (note current value should be initialised to the min of the range or if data exists the table max +1 within the range)  The name of the sequence is just the pk name, I found that the easiest way and most meaningful.</p>
<p>I then create a stored procedure with the following signature</p>
<p>GetNextSequenceValue @sequenceName varchar(128), @value int OUT</p>
<p>In the SP I simply do a lock for update select to get the currect value of the named sequence + 1, check if it is in range, update the sequnce table and set the out value.</p>
<p>I also created a scalar function</p>
<p>GetCurrentSequenceValue( @sequenceName varchar(128))</p>
<p>This simply gives you the current value of a named sequence</p>
<p>I then had to set the default value of the int PK columns in the table to 0 as we will never use a value of 0, it is just a flag to the trigger to get get the next sequence value.</p>
<p>Then I added an instead of insert trigger to the table, where if the PK value is 0 I get the next sequence value using the SP and then do the real insert.  This means that if the PK is not defined in the initial insert, the sequence value is used, if it is defined, the defined value is used, this allows sync to write the PK ids.</p>
<p>Note: no range constraints can be used on the tables, this will cause sync from other ranges to fail, the SP must control the range using the definition from the sequence table.</p>
<p>This solves all issues with guids and integers, except when you have no control over the sql servers are in your system, and configuring the ranges is not posible.</p>
<p>I suggest ranges as follows:</p>
<p>Central server: -2147483647 to -1 (use all negative values gives you the same range as a positive integer)</p>
<p>Client servers:<br />
First Client: 1 to 99999999<br />
Second Client 100000001 to 199999999<br />
&#8230;<br />
Last client 9900000001 to 2147483647</p>
<p>You can always use negatives on clients if the central server makes more sense to have positive IDs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-302711</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Mon, 18 Jun 2012 07:49:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-302711</guid>
		<description><![CDATA[It dpends. Have you read the article with all comments?]]></description>
		<content:encoded><![CDATA[<p>It dpends. Have you read the article with all comments?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aditya</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-301254</link>
		<dc:creator><![CDATA[Aditya]]></dc:creator>
		<pubDate>Thu, 14 Jun 2012 14:14:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-301254</guid>
		<description><![CDATA[Which is the best option between INT and UniqueID?]]></description>
		<content:encoded><![CDATA[<p>Which is the best option between INT and UniqueID?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nobody</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-286931</link>
		<dc:creator><![CDATA[nobody]]></dc:creator>
		<pubDate>Mon, 21 May 2012 21:50:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-286931</guid>
		<description><![CDATA[Is re-indexing a problem anymore? It would seem to me that INT would have a disadvantage should an event ever occur that caused re-indexing to be necessary.]]></description>
		<content:encoded><![CDATA[<p>Is re-indexing a problem anymore? It would seem to me that INT would have a disadvantage should an event ever occur that caused re-indexing to be necessary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-259398</link>
		<dc:creator><![CDATA[Christopher]]></dc:creator>
		<pubDate>Sun, 04 Mar 2012 12:06:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-259398</guid>
		<description><![CDATA[I have a problem with this sentence about the GUID: &quot;String values are not as optimal as integer values for performance when used in joins, indexes and conditions.&quot;
My problem is: GUID&#039;s are not stored or prosessed as string. The GUID or UUID is usually just a 128-bit Integer that is displayed (for human readability) as a Hexadecimal string. It&#039;s identical to how IPv4 adresses are actually just 32 bit that are shown a decimal values with points (so please don&#039;t store them as Varchar(15), use 1 INT or 4 tinyint&#039;s) or IPv6 uses a 128-bit Integer. Or a single char/nchar 8 and 16 bit integers repsectively.
The only real difference between GUID and a normal 128-bit Integer, is how the next number is generated - randomly, rather than sequentially.

Also, regarding the Integers disadvantage:
If a 32 bit singed Integer is to small, you can easily use a 64-bit integer instead. If you have a 64-bit system, there won&#039;t be any performance issues. It will still be faster than guid/uuid, as they only need 8 bit in on this disk (and thus when beign read or written).but it&#039;s much harder to run out of numbers than with 32-bit (9,223,372,036,854,775,807 - when it is singed).]]></description>
		<content:encoded><![CDATA[<p>I have a problem with this sentence about the GUID: &#8220;String values are not as optimal as integer values for performance when used in joins, indexes and conditions.&#8221;<br />
My problem is: GUID&#8217;s are not stored or prosessed as string. The GUID or UUID is usually just a 128-bit Integer that is displayed (for human readability) as a Hexadecimal string. It&#8217;s identical to how IPv4 adresses are actually just 32 bit that are shown a decimal values with points (so please don&#8217;t store them as Varchar(15), use 1 INT or 4 tinyint&#8217;s) or IPv6 uses a 128-bit Integer. Or a single char/nchar 8 and 16 bit integers repsectively.<br />
The only real difference between GUID and a normal 128-bit Integer, is how the next number is generated &#8211; randomly, rather than sequentially.</p>
<p>Also, regarding the Integers disadvantage:<br />
If a 32 bit singed Integer is to small, you can easily use a 64-bit integer instead. If you have a 64-bit system, there won&#8217;t be any performance issues. It will still be faster than guid/uuid, as they only need 8 bit in on this disk (and thus when beign read or written).but it&#8217;s much harder to run out of numbers than with 32-bit (9,223,372,036,854,775,807 &#8211; when it is singed).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ZackyJ</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-250411</link>
		<dc:creator><![CDATA[ZackyJ]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 11:24:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-250411</guid>
		<description><![CDATA[My Thoughts - GUID has its place.  I prefer it used for Authentication of User only.  Outside of this I like to have the DB provide INT / BIGINT sequential ID&#039;s for each new entry.  I work with web apps that theoretically will have lots of users and lots of look ups over time.  Indexing on the transactions is very important.  As for the users, they need to be authenticated to do anything and then again authorized at each level.  GUID gives flexibility here for he user, but I fear using it outside of the &quot;User Authentication&quot; table.  The nice thing about Integer based types in the database is that as they are created the numbers can increase by one.  This means that if I have one million rows of transactions I do not need to return them all.  Chances are the lower numbers are old and outdated.  This also helps with faster indexing and Joins.

Authentication - Consider GUID
Other Tables - Lean toward Integer (TINYINT / SMALLINT / INT / BIGINT as needed).]]></description>
		<content:encoded><![CDATA[<p>My Thoughts &#8211; GUID has its place.  I prefer it used for Authentication of User only.  Outside of this I like to have the DB provide INT / BIGINT sequential ID&#8217;s for each new entry.  I work with web apps that theoretically will have lots of users and lots of look ups over time.  Indexing on the transactions is very important.  As for the users, they need to be authenticated to do anything and then again authorized at each level.  GUID gives flexibility here for he user, but I fear using it outside of the &#8220;User Authentication&#8221; table.  The nice thing about Integer based types in the database is that as they are created the numbers can increase by one.  This means that if I have one million rows of transactions I do not need to return them all.  Chances are the lower numbers are old and outdated.  This also helps with faster indexing and Joins.</p>
<p>Authentication &#8211; Consider GUID<br />
Other Tables &#8211; Lean toward Integer (TINYINT / SMALLINT / INT / BIGINT as needed).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farhang Amary</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-177563</link>
		<dc:creator><![CDATA[Farhang Amary]]></dc:creator>
		<pubDate>Tue, 11 Oct 2011 14:26:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-177563</guid>
		<description><![CDATA[convert GUID to int:

Sure you can, but it&#039;s better with long to get the most value because a guid uses 16 bytes:


 byte[] gb = Guid.NewGuid().ToByteArray();


int i = BitConverter.ToInt32(gb,0);

long l = BitConverter.ToInt64(gb,0);

.]]></description>
		<content:encoded><![CDATA[<p>convert GUID to int:</p>
<p>Sure you can, but it&#8217;s better with long to get the most value because a guid uses 16 bytes:</p>
<p> byte[] gb = Guid.NewGuid().ToByteArray();</p>
<p>int i = BitConverter.ToInt32(gb,0);</p>
<p>long l = BitConverter.ToInt64(gb,0);</p>
<p>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-155572</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Wed, 10 Aug 2011 01:36:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-155572</guid>
		<description><![CDATA[Hi Pdohara,

Yes, I will have a new post out soon.]]></description>
		<content:encoded><![CDATA[<p>Hi Pdohara,</p>
<p>Yes, I will have a new post out soon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pdohara</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-155537</link>
		<dc:creator><![CDATA[pdohara]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 22:44:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-155537</guid>
		<description><![CDATA[I am using this article to create my benchmarks:
http://community.ugiss.org/blogs/dmauri/archive/2008/59/23/utilizzo-di-guid-pro-e-contro.aspx

You can view the English translation here:
http://translate.google.com/translate?js=y&amp;prev=_t&amp;hl=en&amp;ie=UTF-8&amp;layout=1&amp;eotf=1&amp;u=http%3A%2F%2Fcommunity.ugiss.org%2Fblogs%2Fdmauri%2Farchive%2F2008%2F59%2F23%2Futilizzo-di-guid-pro-e-contro.aspx&amp;sl=it&amp;tl=en&amp;swap=1

I changed the GUID table to use NEWSEQUENCIALID rather than NEWID.

I am seeing similar difference in the insertions (note that Sprecher is a little faster than the machine they used. )
INT	12ms
GUID	23ms
Still the ratio is about 2 to 1 on many sequential inserts.

The clustering is less problematic by far:

table_name	index_id	index_type_desc	index_depth	avg_fragmentation_in_percent	page_count
TestGuid	1	CLUSTERED INDEX	2	14.8148148148148	27
TestGuid	2	NONCLUSTERED INDEX	2	33.3333333333333	9
TestInt	1	CLUSTERED INDEX	2	9.52380952380952	21
TestInt	2	NONCLUSTERED INDEX	2	33.3333333333333	3

The 300% increase is troubling, but not nearly so troubling as the 1000% increase of the original article.

Similarly the space usage is not as dire:
index_name	type_desc	space_used_in_kb
PK__TestGuid__3213E83F59063A47	CLUSTERED	216.0
PK__TestInt__3213E83F5DCAEF64	CLUSTERED	168.0
uix__TestInt__fk	NONCLUSTERED	24.0
uix__TestGuid__fk	NONCLUSTERED	72.0

While he was getting 2 to 1 cluster and 4 to 1 not clustered, my numbers are more like plus 30% and 3 to 1.  So space is an issue, but performance is likely not.

In addition I created a set of single row selects from both tables.  The set included every row value (I created 2048 rows in both tables).  The results are:
INT	29ms
GUID	52ms
As we see the performance is not quite 2 to one, but remember that this represents 2048 individual selects.  The performance difference per select would be difficult to measure.

The result is that though there is a difference it is not particularly dire for my use case.  Perhaps for yours it is.  As with most things it depends on what you plan to do with it.

Pat O]]></description>
		<content:encoded><![CDATA[<p>I am using this article to create my benchmarks:<br />
<a href="http://community.ugiss.org/blogs/dmauri/archive/2008/59/23/utilizzo-di-guid-pro-e-contro.aspx" rel="nofollow">http://community.ugiss.org/blogs/dmauri/archive/2008/59/23/utilizzo-di-guid-pro-e-contro.aspx</a></p>
<p>You can view the English translation here:<br />
<a href="http://translate.google.com/translate?js=y&#038;prev=_t&#038;hl=en&#038;ie=UTF-8&#038;layout=1&#038;eotf=1&#038;u=http%3A%2F%2Fcommunity.ugiss.org%2Fblogs%2Fdmauri%2Farchive%2F2008%2F59%2F23%2Futilizzo-di-guid-pro-e-contro.aspx&#038;sl=it&#038;tl=en&#038;swap=1" rel="nofollow">http://translate.google.com/translate?js=y&#038;prev=_t&#038;hl=en&#038;ie=UTF-8&#038;layout=1&#038;eotf=1&#038;u=http%3A%2F%2Fcommunity.ugiss.org%2Fblogs%2Fdmauri%2Farchive%2F2008%2F59%2F23%2Futilizzo-di-guid-pro-e-contro.aspx&#038;sl=it&#038;tl=en&#038;swap=1</a></p>
<p>I changed the GUID table to use NEWSEQUENCIALID rather than NEWID.</p>
<p>I am seeing similar difference in the insertions (note that Sprecher is a little faster than the machine they used. )<br />
INT	12ms<br />
GUID	23ms<br />
Still the ratio is about 2 to 1 on many sequential inserts.</p>
<p>The clustering is less problematic by far:</p>
<p>table_name	index_id	index_type_desc	index_depth	avg_fragmentation_in_percent	page_count<br />
TestGuid	1	CLUSTERED INDEX	2	14.8148148148148	27<br />
TestGuid	2	NONCLUSTERED INDEX	2	33.3333333333333	9<br />
TestInt	1	CLUSTERED INDEX	2	9.52380952380952	21<br />
TestInt	2	NONCLUSTERED INDEX	2	33.3333333333333	3</p>
<p>The 300% increase is troubling, but not nearly so troubling as the 1000% increase of the original article.</p>
<p>Similarly the space usage is not as dire:<br />
index_name	type_desc	space_used_in_kb<br />
PK__TestGuid__3213E83F59063A47	CLUSTERED	216.0<br />
PK__TestInt__3213E83F5DCAEF64	CLUSTERED	168.0<br />
uix__TestInt__fk	NONCLUSTERED	24.0<br />
uix__TestGuid__fk	NONCLUSTERED	72.0</p>
<p>While he was getting 2 to 1 cluster and 4 to 1 not clustered, my numbers are more like plus 30% and 3 to 1.  So space is an issue, but performance is likely not.</p>
<p>In addition I created a set of single row selects from both tables.  The set included every row value (I created 2048 rows in both tables).  The results are:<br />
INT	29ms<br />
GUID	52ms<br />
As we see the performance is not quite 2 to one, but remember that this represents 2048 individual selects.  The performance difference per select would be difficult to measure.</p>
<p>The result is that though there is a difference it is not particularly dire for my use case.  Perhaps for yours it is.  As with most things it depends on what you plan to do with it.</p>
<p>Pat O</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pdohara</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-155513</link>
		<dc:creator><![CDATA[pdohara]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 21:02:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-155513</guid>
		<description><![CDATA[BTW, Please comment here when you create the new Post with all these thoughts consolidated.  I found this quite informative, though somewhat laborious to read.]]></description>
		<content:encoded><![CDATA[<p>BTW, Please comment here when you create the new Post with all these thoughts consolidated.  I found this quite informative, though somewhat laborious to read.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pdohara</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-155512</link>
		<dc:creator><![CDATA[pdohara]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 21:00:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-155512</guid>
		<description><![CDATA[A couple of comments.  First, a googling of the performance hit of sequencial GUID in a DB turns up a typical answer in the 5-10% range.  In other works operations that take 1 unit of type with INT take approximately 1.05 to 1.1 unit of time with GUIDs.  This is obvisouly significant, but not necessarily a show stopper.  You should construct your own benchmark and find out what the effect is for your own data.  The same is true for the additional storage.  Yes consuming four time the storage for the idenitfier is worth noting.  On a table with several (I think the number was 8) keys this is even more significant.  On the other hand if the table has a few string columns (i.e. nvarchar(150)), then the storage of the index has become a fairly small percentage of the overall table size.
There is another advantage of GUIDs that has not been mentioned here.  They solve the cross table refence bug.  In this bug a peice of code gets an ID from table A and then erroneously uses it as a foriegn key in table B.  The bug is that the foriegn key column in Table B references Table C.  So let&#039;s say that there is an invoice and an invoice detail table.  There is also a customer table.  It is possible to write code that incorrectly uses the customer id value in the invoice details table as a reference to the invoice that detail row should be associated with.  Using sequenctial integers for ids this will almost always work.  Using GUID this will almost always fail.]]></description>
		<content:encoded><![CDATA[<p>A couple of comments.  First, a googling of the performance hit of sequencial GUID in a DB turns up a typical answer in the 5-10% range.  In other works operations that take 1 unit of type with INT take approximately 1.05 to 1.1 unit of time with GUIDs.  This is obvisouly significant, but not necessarily a show stopper.  You should construct your own benchmark and find out what the effect is for your own data.  The same is true for the additional storage.  Yes consuming four time the storage for the idenitfier is worth noting.  On a table with several (I think the number was 8) keys this is even more significant.  On the other hand if the table has a few string columns (i.e. nvarchar(150)), then the storage of the index has become a fairly small percentage of the overall table size.<br />
There is another advantage of GUIDs that has not been mentioned here.  They solve the cross table refence bug.  In this bug a peice of code gets an ID from table A and then erroneously uses it as a foriegn key in table B.  The bug is that the foriegn key column in Table B references Table C.  So let&#8217;s say that there is an invoice and an invoice detail table.  There is also a customer table.  It is possible to write code that incorrectly uses the customer id value in the invoice details table as a reference to the invoice that detail row should be associated with.  Using sequenctial integers for ids this will almost always work.  Using GUID this will almost always fail.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pdohara</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-155509</link>
		<dc:creator><![CDATA[pdohara]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 20:48:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-155509</guid>
		<description><![CDATA[a GUID is not alphanumeric.  Your rookie is showing.  :-)]]></description>
		<content:encoded><![CDATA[<p>a GUID is not alphanumeric.  Your rookie is showing.  :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ABooth</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-138480</link>
		<dc:creator><![CDATA[ABooth]]></dc:creator>
		<pubDate>Thu, 02 Jun 2011 21:16:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-138480</guid>
		<description><![CDATA[INT primary keys (especially identity seeds) being human readable are also a disadvantage as queries that should be date based, often use the identity seed based on the assumption that a lower ID was created earlier, which may not be true. Also, presenting a primary key as a reference code to a user, may have negative implications when master table references need to be reordered, which would require changing the primary key of the master and updating all tables where the key was a foreign key. It&#039;s much better to have a key where a developer can not make this mistake and is required to add a reference column and a unique index to the table, that would only require the master table be updated, should such a scenario occur.

Joins are no easier using ints

As for insertion order, you can create sequential GUIDS

See above about why using the primary key as a Customer code is a terrible idea.

Here&#039;s one real question you should ask when deciding on GUIDS: Will I want to transfer the data in this record, back and forth to other systems? If so, GUIDS are great because you can insert the row into the other system without changing the key or worrying about sending a BigInt to a system with INT as the PK. You don&#039;t even need to see if the other system has a duplicate key when inserting because unlike identity seeds, GUIDs are unique across all tables and systems.

The time I would not consider a GUID is when I have local lookup tables that are never intended to be exported.]]></description>
		<content:encoded><![CDATA[<p>INT primary keys (especially identity seeds) being human readable are also a disadvantage as queries that should be date based, often use the identity seed based on the assumption that a lower ID was created earlier, which may not be true. Also, presenting a primary key as a reference code to a user, may have negative implications when master table references need to be reordered, which would require changing the primary key of the master and updating all tables where the key was a foreign key. It&#8217;s much better to have a key where a developer can not make this mistake and is required to add a reference column and a unique index to the table, that would only require the master table be updated, should such a scenario occur.</p>
<p>Joins are no easier using ints</p>
<p>As for insertion order, you can create sequential GUIDS</p>
<p>See above about why using the primary key as a Customer code is a terrible idea.</p>
<p>Here&#8217;s one real question you should ask when deciding on GUIDS: Will I want to transfer the data in this record, back and forth to other systems? If so, GUIDS are great because you can insert the row into the other system without changing the key or worrying about sending a BigInt to a system with INT as the PK. You don&#8217;t even need to see if the other system has a duplicate key when inserting because unlike identity seeds, GUIDs are unique across all tables and systems.</p>
<p>The time I would not consider a GUID is when I have local lookup tables that are never intended to be exported.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ABooth</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-138475</link>
		<dc:creator><![CDATA[ABooth]]></dc:creator>
		<pubDate>Thu, 02 Jun 2011 21:05:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-138475</guid>
		<description><![CDATA[Guids are guaranteed unique because they are generated from server specific characteristics such as MAC address, server time, disk serial number, randomization etc

As the MAC address is unique, no 2 servers will create the same GUID and as no 2 GUIDS can be created in the same clock tick, No 2 guids can be created on the same server. Even if you set the internal clock back, the added randomization, coupled with the clock tick, a disk id etc, the chances of creating the exact same id in the same clock tick is effectively impossible.

As for their format, they are nothing more than a collection of  8 &amp; 16 byte ints, as if it were a 16 byte BigInt with groups of its bits populated from different sources.]]></description>
		<content:encoded><![CDATA[<p>Guids are guaranteed unique because they are generated from server specific characteristics such as MAC address, server time, disk serial number, randomization etc</p>
<p>As the MAC address is unique, no 2 servers will create the same GUID and as no 2 GUIDS can be created in the same clock tick, No 2 guids can be created on the same server. Even if you set the internal clock back, the added randomization, coupled with the clock tick, a disk id etc, the chances of creating the exact same id in the same clock tick is effectively impossible.</p>
<p>As for their format, they are nothing more than a collection of  8 &amp; 16 byte ints, as if it were a 16 byte BigInt with groups of its bits populated from different sources.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Swanand Pol</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-123327</link>
		<dc:creator><![CDATA[Swanand Pol]]></dc:creator>
		<pubDate>Tue, 15 Mar 2011 13:06:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-123327</guid>
		<description><![CDATA[Hi,
Recently, I was working on GUID. And GUID seems a big horror for me. That&#039;s becuase I wasnt able to convert string value to GUID. Everytime stucked with the same error Conversion failed while converting GUID to string. So what&#039;s the solution now?]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
Recently, I was working on GUID. And GUID seems a big horror for me. That&#8217;s becuase I wasnt able to convert string value to GUID. Everytime stucked with the same error Conversion failed while converting GUID to string. So what&#8217;s the solution now?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Galt</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-114431</link>
		<dc:creator><![CDATA[John Galt]]></dc:creator>
		<pubDate>Wed, 26 Jan 2011 14:18:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-114431</guid>
		<description><![CDATA[Chuck:

If you&#039;d bothered to read the rest of the thread what you just wrote was already covered.

Yes, random GUIDs are bad. However sequential ones are not, and are only double the side of int64. Thus there is very little negative effect in using them. Either use newsequentialid or create your own function that does the same and you&#039;re golden.]]></description>
		<content:encoded><![CDATA[<p>Chuck:</p>
<p>If you&#8217;d bothered to read the rest of the thread what you just wrote was already covered.</p>
<p>Yes, random GUIDs are bad. However sequential ones are not, and are only double the side of int64. Thus there is very little negative effect in using them. Either use newsequentialid or create your own function that does the same and you&#8217;re golden.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chuck Clifford</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-114302</link>
		<dc:creator><![CDATA[Chuck Clifford]]></dc:creator>
		<pubDate>Wed, 26 Jan 2011 04:38:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-114302</guid>
		<description><![CDATA[All relational database engines are optimized to work with indexes on columns whose value increments after insertions (such as with in integer) - this is knows as a &#039;natural progression.&#039; 

Relation database engines are NOT optimized to work with indexes on columns whose value is assigned a random value upon insertion (such as with a GUID, or any other alphanumeric string) - this is known as an &#039;unnatural progression&#039;.

If you are implementing a solution that uses a relational database engine to store your data, whenever you are choosing a data type for either an index column or for a table&#039;s primary key ALWAYS choose an integer (of the appropriate size).

Choosing a GUID or some other alphanumeric data type for an index column or for a primary key is now and has always been a rookie&#039;s mistake.]]></description>
		<content:encoded><![CDATA[<p>All relational database engines are optimized to work with indexes on columns whose value increments after insertions (such as with in integer) &#8211; this is knows as a &#8216;natural progression.&#8217; </p>
<p>Relation database engines are NOT optimized to work with indexes on columns whose value is assigned a random value upon insertion (such as with a GUID, or any other alphanumeric string) &#8211; this is known as an &#8216;unnatural progression&#8217;.</p>
<p>If you are implementing a solution that uses a relational database engine to store your data, whenever you are choosing a data type for either an index column or for a table&#8217;s primary key ALWAYS choose an integer (of the appropriate size).</p>
<p>Choosing a GUID or some other alphanumeric data type for an index column or for a primary key is now and has always been a rookie&#8217;s mistake.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oakcool</title>
		<link>http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/#comment-106356</link>
		<dc:creator><![CDATA[oakcool]]></dc:creator>
		<pubDate>Fri, 17 Dec 2010 18:16:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=8811#comment-106356</guid>
		<description><![CDATA[Yes, thats the real reason you should use GUIDs, you may be able to handle with begint, by portioning the numbers, so branch 1 takes number from 1 to 2 billion, branch 2 goes from 2 billion and 1 to 4 billion, and so on. But then branch 1 run out of numbers, then what you do? Take the next available series, and now branch 1 has 1 to 2 billion and 6 to 8 billion, that works, but can get quite confusing and hard to manage.
If you that not real case, just remember the very way you got to this post... An IP address, have you ever though about it. 000.000.000.000 to 255.255.255.255 that a very large amount of number to pick from, but we are running out of them, and guess what IPv6 is a GUID, why?, one would wonder. Why?]]></description>
		<content:encoded><![CDATA[<p>Yes, thats the real reason you should use GUIDs, you may be able to handle with begint, by portioning the numbers, so branch 1 takes number from 1 to 2 billion, branch 2 goes from 2 billion and 1 to 4 billion, and so on. But then branch 1 run out of numbers, then what you do? Take the next available series, and now branch 1 has 1 to 2 billion and 6 to 8 billion, that works, but can get quite confusing and hard to manage.<br />
If you that not real case, just remember the very way you got to this post&#8230; An IP address, have you ever though about it. 000.000.000.000 to 255.255.255.255 that a very large amount of number to pick from, but we are running out of them, and guess what IPv6 is a GUID, why?, one would wonder. Why?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
