<?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: Database indexes are your friend</title>
	<atom:link href="http://lostechies.com/jimmybogard/2010/08/27/database-indexes-are-your-friend/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2010/08/27/database-indexes-are-your-friend/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Sun, 19 May 2013 03:22:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Ray</title>
		<link>http://lostechies.com/jimmybogard/2010/08/27/database-indexes-are-your-friend/#comment-2567</link>
		<dc:creator>Ray</dc:creator>
		<pubDate>Tue, 31 Aug 2010 08:40:28 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/08/26/database-indexes-are-your-friend.aspx#comment-2567</guid>
		<description>There is a simple reason why foreign keys should not get the index built automatically - they aren&#039;t unique (usually). Imagine if there are only few possible values for the foreign key and one of them is used 90% of time on multi-million table. The index not only won&#039;t improve the search, it will also create an overhead.</description>
		<content:encoded><![CDATA[<p>There is a simple reason why foreign keys should not get the index built automatically &#8211; they aren&#8217;t unique (usually). Imagine if there are only few possible values for the foreign key and one of them is used 90% of time on multi-million table. The index not only won&#8217;t improve the search, it will also create an overhead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arnis L.</title>
		<link>http://lostechies.com/jimmybogard/2010/08/27/database-indexes-are-your-friend/#comment-2566</link>
		<dc:creator>Arnis L.</dc:creator>
		<pubDate>Sat, 28 Aug 2010 08:58:25 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/08/26/database-indexes-are-your-friend.aspx#comment-2566</guid>
		<description>I&#039;ve been there too. Only I had little experience back then and it took awhile to figure it out. Query that couldn&#039;t finish in minutes started to work in milliseconds.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been there too. Only I had little experience back then and it took awhile to figure it out. Query that couldn&#8217;t finish in minutes started to work in milliseconds.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill R.</title>
		<link>http://lostechies.com/jimmybogard/2010/08/27/database-indexes-are-your-friend/#comment-2565</link>
		<dc:creator>Bill R.</dc:creator>
		<pubDate>Sat, 28 Aug 2010 01:16:32 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/08/26/database-indexes-are-your-friend.aspx#comment-2565</guid>
		<description>One can in fact imagine a scenario in which a foreign key might exist but no query will ever be executed against the table either selecting or sorting by that foreign key, thus excusing its absence.

However, not to do so begs so many questions balanced ONLY against the &quot;cost&quot; or &quot;storage&quot; of building that index that one has to wonder about whether the database engine has been updated in any meaningful way since the 1980&#039;s, when disk storage was thousands of dollars per Megabyte.

Today, a 5 Terabyte RAID DASD server can be had for &lt; $1,000.  You have to be lazy, ignorant, severely thick-headed, or have some incredibly esoteric reason NOT to build the obvious indexes on a table.</description>
		<content:encoded><![CDATA[<p>One can in fact imagine a scenario in which a foreign key might exist but no query will ever be executed against the table either selecting or sorting by that foreign key, thus excusing its absence.</p>
<p>However, not to do so begs so many questions balanced ONLY against the &#8220;cost&#8221; or &#8220;storage&#8221; of building that index that one has to wonder about whether the database engine has been updated in any meaningful way since the 1980&#8242;s, when disk storage was thousands of dollars per Megabyte.</p>
<p>Today, a 5 Terabyte RAID DASD server can be had for < $1,000.  You have to be lazy, ignorant, severely thick-headed, or have some incredibly esoteric reason NOT to build the obvious indexes on a table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Noel</title>
		<link>http://lostechies.com/jimmybogard/2010/08/27/database-indexes-are-your-friend/#comment-2564</link>
		<dc:creator>Noel</dc:creator>
		<pubDate>Fri, 27 Aug 2010 13:50:48 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/08/26/database-indexes-are-your-friend.aspx#comment-2564</guid>
		<description>In SQL Server , by default the primary key is created as the clustered index.  It doesn&#039;t have to be however and you can cluster by any field you like, even non-unique fields.  You can take advantage of this if you are often doing scans on a foreign key (ie all order items for an order).  You can cluster dbo.OrderItem on [OrderItem].[OrderID] to keep all the order items together which will optimise this particular lookup.</description>
		<content:encoded><![CDATA[<p>In SQL Server , by default the primary key is created as the clustered index.  It doesn&#8217;t have to be however and you can cluster by any field you like, even non-unique fields.  You can take advantage of this if you are often doing scans on a foreign key (ie all order items for an order).  You can cluster dbo.OrderItem on [OrderItem].[OrderID] to keep all the order items together which will optimise this particular lookup.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego F.</title>
		<link>http://lostechies.com/jimmybogard/2010/08/27/database-indexes-are-your-friend/#comment-2563</link>
		<dc:creator>Diego F.</dc:creator>
		<pubDate>Fri, 27 Aug 2010 13:29:50 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/08/26/database-indexes-are-your-friend.aspx#comment-2563</guid>
		<description>&quot;I mean, a primary key is a clustered index, why wouldn’t a foreign key also create an index?&quot;

Simply because they serve different purposes. A primary key defines the identity of a row, so it&#039;s very likely it&#039;ll be used for searches, updates and deletes.

Foreign key is a normal field with a constraint that creates a reference to a foreign primary key. The foreign primary key is indexed. So if you have a select of A inner join B you will be searching B&#039;s primary key for the value of the foreign key. Why would you need to search A? You don&#039;t, by default.


Indexes are costly, use it carefuly, they will become your enemies very fast if you don&#039;t use it wisely. :)</description>
		<content:encoded><![CDATA[<p>&#8220;I mean, a primary key is a clustered index, why wouldn’t a foreign key also create an index?&#8221;</p>
<p>Simply because they serve different purposes. A primary key defines the identity of a row, so it&#8217;s very likely it&#8217;ll be used for searches, updates and deletes.</p>
<p>Foreign key is a normal field with a constraint that creates a reference to a foreign primary key. The foreign primary key is indexed. So if you have a select of A inner join B you will be searching B&#8217;s primary key for the value of the foreign key. Why would you need to search A? You don&#8217;t, by default.</p>
<p>Indexes are costly, use it carefuly, they will become your enemies very fast if you don&#8217;t use it wisely. <img src='http://lostechies.com/jimmybogard/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://lostechies.com/jimmybogard/2010/08/27/database-indexes-are-your-friend/#comment-2562</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Fri, 27 Aug 2010 13:25:56 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/08/26/database-indexes-are-your-friend.aspx#comment-2562</guid>
		<description>Paul,

Even on a foreign key?  I mean, I believe in YAGNI as much as the next guy, but key&#039;s should in all but the most extreme situation be indexed.

</description>
		<content:encoded><![CDATA[<p>Paul,</p>
<p>Even on a foreign key?  I mean, I believe in YAGNI as much as the next guy, but key&#8217;s should in all but the most extreme situation be indexed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul S</title>
		<link>http://lostechies.com/jimmybogard/2010/08/27/database-indexes-are-your-friend/#comment-2561</link>
		<dc:creator>Paul S</dc:creator>
		<pubDate>Fri, 27 Aug 2010 07:30:38 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/08/26/database-indexes-are-your-friend.aspx#comment-2561</guid>
		<description>Despite your bad experience here, I believe this is still the right way to go about doing things: Indexes should be added only when it&#039;s observed that they are needed.  Adding them before is just premature optimisation.

Good post, thanks.</description>
		<content:encoded><![CDATA[<p>Despite your bad experience here, I believe this is still the right way to go about doing things: Indexes should be added only when it&#8217;s observed that they are needed.  Adding them before is just premature optimisation.</p>
<p>Good post, thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
