<?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: Indexing isn&#8217;t hard</title>
	<atom:link href="http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/feed/" rel="self" type="application/rss+xml" />
	<link>http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/</link>
	<description>Wherein I write some stuff  that you may like to read. Or not, its up to you really.</description>
	<lastBuildDate>Fri, 11 Nov 2011 18:30:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Steve Holden</title>
		<link>http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/comment-page-1/#comment-23518</link>
		<dc:creator>Steve Holden</dc:creator>
		<pubDate>Tue, 04 Dec 2007 03:50:12 +0000</pubDate>
		<guid isPermaLink="false">http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/#comment-23518</guid>
		<description>Gary:

You don&#039;t necessarily want to ditch your database if it doesn&#039;t automatically create a primary index. For example. if you have a bulk load of millions of rows to perform then adding the data first and creating the index after the load will typically be quicker than creating the index as the data is added.

Much depends on the indexing and the data access patterns. The classic order line actually represents a may-to-many relationship between order and product, with a primary key of (orderID, productID). If you build an index on the primary key that&#039;s great for looking up the products for a particular order, but doesn&#039;t help if you want to know about all the orders for a particular product.

In that case, a separate index on the productID foreign key would be exactly what you&#039;d need, but no additional index would be needed on orderID because the primary key index would serve (since orderID is the dominant column). Andrew&#039;s advice is sound because it implies specific lookup patterns.

So, as is so often the case in the database world, you can&#039;t be too dogmatic about what&#039;s right for a specific application without measuring performance under real application load. That&#039;s why it&#039;s a good thing to have a DBA who can do the performance measurement and tune the physical model long after the logical model designers have moved on to the next project. The line number isn&#039;t that relevant in most cases, though you are correct that a separate index that allowed you to locate all the line ones wouldn&#039;t be useful, and in fact not all order processing systems bother to number the lines.</description>
		<content:encoded><![CDATA[<p>Gary:</p>
<p>You don&#8217;t necessarily want to ditch your database if it doesn&#8217;t automatically create a primary index. For example. if you have a bulk load of millions of rows to perform then adding the data first and creating the index after the load will typically be quicker than creating the index as the data is added.</p>
<p>Much depends on the indexing and the data access patterns. The classic order line actually represents a may-to-many relationship between order and product, with a primary key of (orderID, productID). If you build an index on the primary key that&#8217;s great for looking up the products for a particular order, but doesn&#8217;t help if you want to know about all the orders for a particular product.</p>
<p>In that case, a separate index on the productID foreign key would be exactly what you&#8217;d need, but no additional index would be needed on orderID because the primary key index would serve (since orderID is the dominant column). Andrew&#8217;s advice is sound because it implies specific lookup patterns.</p>
<p>So, as is so often the case in the database world, you can&#8217;t be too dogmatic about what&#8217;s right for a specific application without measuring performance under real application load. That&#8217;s why it&#8217;s a good thing to have a DBA who can do the performance measurement and tune the physical model long after the logical model designers have moved on to the next project. The line number isn&#8217;t that relevant in most cases, though you are correct that a separate index that allowed you to locate all the line ones wouldn&#8217;t be useful, and in fact not all order processing systems bother to number the lines.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/comment-page-1/#comment-23506</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Tue, 04 Dec 2007 01:45:06 +0000</pubDate>
		<guid isPermaLink="false">http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/#comment-23506</guid>
		<description>I think you have to be careful with the compound indexes. The two largest objects in my accounting package&#039;s db are indexes on the main AR tables.</description>
		<content:encoded><![CDATA[<p>I think you have to be careful with the compound indexes. The two largest objects in my accounting package&#8217;s db are indexes on the main AR tables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: G D Milner</title>
		<link>http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/comment-page-1/#comment-23490</link>
		<dc:creator>G D Milner</dc:creator>
		<pubDate>Tue, 04 Dec 2007 01:06:01 +0000</pubDate>
		<guid isPermaLink="false">http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/#comment-23490</guid>
		<description>Hi, Andrew.

In MS SQL Server, (Since SQL Server 2000) the query optimizer will usually aggregate separately indexed columns for you and take advantage of them as if they were composite indexes. So, at least in that RDBMS, the idea of _having_ to have composite keys is not so relevant. 

I am not sure about MYSQL, PostgreSQL and Oracle as I primarily work in MSSQL. 

Just thought you might want to know. 

Cheers. 

G. D. Milner
Portland, OR</description>
		<content:encoded><![CDATA[<p>Hi, Andrew.</p>
<p>In MS SQL Server, (Since SQL Server 2000) the query optimizer will usually aggregate separately indexed columns for you and take advantage of them as if they were composite indexes. So, at least in that RDBMS, the idea of _having_ to have composite keys is not so relevant. </p>
<p>I am not sure about MYSQL, PostgreSQL and Oracle as I primarily work in MSSQL. </p>
<p>Just thought you might want to know. </p>
<p>Cheers. </p>
<p>G. D. Milner<br />
Portland, OR</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gary</title>
		<link>http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/comment-page-1/#comment-23484</link>
		<dc:creator>gary</dc:creator>
		<pubDate>Mon, 03 Dec 2007 23:08:19 +0000</pubDate>
		<guid isPermaLink="false">http://halfcooked.com/blog/2007/12/04/indexing-isnt-hard/#comment-23484</guid>
		<description>&quot;If your database doesn’t do it automatically, add indexes to all of your primary key columns&quot;
Shouldn&#039;t this be
&quot;If your database doesn’t automatically index primary keys, change your database software&quot;

Seriously, if you have multi-column primary keys, you want one index on all columns. So the classic &quot;order line&quot; table would have one index of &quot;order_no, line_no&quot;. Having a separate index on line_no is probably unhelpful.</description>
		<content:encoded><![CDATA[<p>&#8220;If your database doesn’t do it automatically, add indexes to all of your primary key columns&#8221;<br />
Shouldn&#8217;t this be<br />
&#8220;If your database doesn’t automatically index primary keys, change your database software&#8221;</p>
<p>Seriously, if you have multi-column primary keys, you want one index on all columns. So the classic &#8220;order line&#8221; table would have one index of &#8220;order_no, line_no&#8221;. Having a separate index on line_no is probably unhelpful.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

