<?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: Optimizing MySQL: Importance of JOIN Order</title>
	<atom:link href="http://www.webdevelopmentstuff.com/119/optimizing-mysql-importance-of-join-order.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.webdevelopmentstuff.com/119/optimizing-mysql-importance-of-join-order.html</link>
	<description>ready-to-use resources, tutorials, tips and many other web development related stuff</description>
	<lastBuildDate>Mon, 01 Feb 2010 20:19:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Karthik Murugan</title>
		<link>http://www.webdevelopmentstuff.com/119/optimizing-mysql-importance-of-join-order.html/comment-page-1#comment-351</link>
		<dc:creator>Karthik Murugan</dc:creator>
		<pubDate>Sun, 20 Dec 2009 16:17:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdevelopmentstuff.com/?p=119#comment-351</guid>
		<description>Simple but great stuff. I hit with the same problem and your article helped me. Thanks Teddy.</description>
		<content:encoded><![CDATA[<p>Simple but great stuff. I hit with the same problem and your article helped me. Thanks Teddy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Teddy</title>
		<link>http://www.webdevelopmentstuff.com/119/optimizing-mysql-importance-of-join-order.html/comment-page-1#comment-200</link>
		<dc:creator>Teddy</dc:creator>
		<pubDate>Sun, 09 Aug 2009 09:20:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdevelopmentstuff.com/?p=119#comment-200</guid>
		<description>Why? Is there something wrong with it?</description>
		<content:encoded><![CDATA[<p>Why? Is there something wrong with it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobias J</title>
		<link>http://www.webdevelopmentstuff.com/119/optimizing-mysql-importance-of-join-order.html/comment-page-1#comment-199</link>
		<dc:creator>Tobias J</dc:creator>
		<pubDate>Sun, 09 Aug 2009 07:26:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdevelopmentstuff.com/?p=119#comment-199</guid>
		<description>Do you proof read your articles?
If so, you should have someone else do it for you.

Good topic though.</description>
		<content:encoded><![CDATA[<p>Do you proof read your articles?<br />
If so, you should have someone else do it for you.</p>
<p>Good topic though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Teddy</title>
		<link>http://www.webdevelopmentstuff.com/119/optimizing-mysql-importance-of-join-order.html/comment-page-1#comment-196</link>
		<dc:creator>Teddy</dc:creator>
		<pubDate>Thu, 30 Jul 2009 07:05:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdevelopmentstuff.com/?p=119#comment-196</guid>
		<description>I absolutely understand what you are writing about, Fred. But in this case I&#039;ve just pasted whole statement as it was originaly writen by the authors of that software. I realize that there are more deficiencies, but this one was used for demonstration purposes only. Nevertheless, I appreciate your comment, I&#039;m sure it will be helpfull for all readers.</description>
		<content:encoded><![CDATA[<p>I absolutely understand what you are writing about, Fred. But in this case I&#8217;ve just pasted whole statement as it was originaly writen by the authors of that software. I realize that there are more deficiencies, but this one was used for demonstration purposes only. Nevertheless, I appreciate your comment, I&#8217;m sure it will be helpfull for all readers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred</title>
		<link>http://www.webdevelopmentstuff.com/119/optimizing-mysql-importance-of-join-order.html/comment-page-1#comment-192</link>
		<dc:creator>Fred</dc:creator>
		<pubDate>Wed, 29 Jul 2009 02:51:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdevelopmentstuff.com/?p=119#comment-192</guid>
		<description>unix_timestamp(art.StartDate) = unix_timestamp(now())

will NEVER use the fields index,
because the date is calculated/converted.

The indexed field must be &quot;pure&quot;,
for instance, if you have an indexed datetime field and do date comparison with it, it won&#039;t uses the index on that field.

You should rewrite it as:

art.StartDate &gt;= current_date
art.ExpiryDate &gt;= current_date

or if it&#039;s a DateTime

art.StartDate &gt;= now()
art.ExpiryDate &gt;= now()


If you really need some calculation to be done, then you must rewrite the condition such that the indexed field is pure and the condition is not and can be computed before the index is used...

For instance:

DATE_SUB(CURRENT_DATE,INTERVAL 30 DAY) &lt;= art.ExpiryDate;

== (constant &lt;= field)

is faster than:

CURRENT_DATE &lt;= DATE_ADD(art.ExpiryDate,INTERVAL 30 DAY);

== (constant &lt;= computed(field))


Also, you are using two fields to be ordered by which are not &quot;explicitly&quot; being stated in your SELECT uncomputed...

Normally you should never uses *,
except for debugging, if you upgrade your schema, then your application logic may break.

Did you try EXPLAIN SELECT ?</description>
		<content:encoded><![CDATA[<p>unix_timestamp(art.StartDate) = unix_timestamp(now())</p>
<p>will NEVER use the fields index,<br />
because the date is calculated/converted.</p>
<p>The indexed field must be &#8220;pure&#8221;,<br />
for instance, if you have an indexed datetime field and do date comparison with it, it won&#8217;t uses the index on that field.</p>
<p>You should rewrite it as:</p>
<p>art.StartDate &gt;= current_date<br />
art.ExpiryDate &gt;= current_date</p>
<p>or if it&#8217;s a DateTime</p>
<p>art.StartDate &gt;= now()<br />
art.ExpiryDate &gt;= now()</p>
<p>If you really need some calculation to be done, then you must rewrite the condition such that the indexed field is pure and the condition is not and can be computed before the index is used&#8230;</p>
<p>For instance:</p>
<p>DATE_SUB(CURRENT_DATE,INTERVAL 30 DAY) &lt;= art.ExpiryDate;</p>
<p>== (constant &lt;= field)</p>
<p>is faster than:</p>
<p>CURRENT_DATE &lt;= DATE_ADD(art.ExpiryDate,INTERVAL 30 DAY);</p>
<p>== (constant &lt;= computed(field))</p>
<p>Also, you are using two fields to be ordered by which are not &quot;explicitly&quot; being stated in your SELECT uncomputed&#8230;</p>
<p>Normally you should never uses *,<br />
except for debugging, if you upgrade your schema, then your application logic may break.</p>
<p>Did you try EXPLAIN SELECT ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
