<?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: How adding another table to JOIN can improve performance ?</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/</link>
	<description>Everything about MySQL Performance</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:23:57 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Howard</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-342049</link>
		<dc:creator>Howard</dc:creator>
		<pubDate>Thu, 07 Aug 2008 20:51:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-342049</guid>
		<description>Hi I&#039;m curious, wouldn&#039;t the performance of the query become unacceptable again with any manner of sorting (resulting in filesort/temp)?  You would almost certain sort from the info table rather than the joined date table.</description>
		<content:encoded><![CDATA[<p>Hi I&#8217;m curious, wouldn&#8217;t the performance of the query become unacceptable again with any manner of sorting (resulting in filesort/temp)?  You would almost certain sort from the info table rather than the joined date table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruslan Zakirov</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-340284</link>
		<dc:creator>Ruslan Zakirov</dc:creator>
		<pubDate>Tue, 05 Aug 2008 02:16:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-340284</guid>
		<description>Coincidence is surprising. Tired of workarounding so decided to push them into the tracker.</description>
		<content:encoded><![CDATA[<p>Coincidence is surprising. Tired of workarounding so decided to push them into the tracker.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-340221</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Tue, 05 Aug 2008 00:37:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-340221</guid>
		<description>Ruslan,

Why surprising ? Is it the first optimizer gotcha with MySQL you ran into ?</description>
		<content:encoded><![CDATA[<p>Ruslan,</p>
<p>Why surprising ? Is it the first optimizer gotcha with MySQL you ran into ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruslan Zakirov</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-340160</link>
		<dc:creator>Ruslan Zakirov</dc:creator>
		<pubDate>Mon, 04 Aug 2008 22:21:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-340160</guid>
		<description>Very surprised to see this in my RSS reader right after submitting http://bugs.mysql.com/bug.php?id=38550 that covers later cases in your research.</description>
		<content:encoded><![CDATA[<p>Very surprised to see this in my RSS reader right after submitting <a href="http://bugs.mysql.com/bug.php?id=38550" rel="nofollow">http://bugs.mysql.com/bug.php?id=38550</a> that covers later cases in your research.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-339480</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Sun, 03 Aug 2008 17:02:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-339480</guid>
		<description>Rob, 

Sure.  This is a bit different though. You are adding whole another dimension tables for things which can&#039;t be checked efficiently using index in original table (such as what day of the week it is) or which are not in the table (such as if it rained)  - in this case you&#039;ve got to add columns to fact table or dimension table as you did.    That is a great thing to do.

My main point was a bit different one would be perfectly find to check range on date and group_id from  the index on the table but MySQL Optimizer/Execution engine just not capable of doing so yet.</description>
		<content:encoded><![CDATA[<p>Rob, </p>
<p>Sure.  This is a bit different though. You are adding whole another dimension tables for things which can&#8217;t be checked efficiently using index in original table (such as what day of the week it is) or which are not in the table (such as if it rained)  &#8211; in this case you&#8217;ve got to add columns to fact table or dimension table as you did.    That is a great thing to do.</p>
<p>My main point was a bit different one would be perfectly find to check range on date and group_id from  the index on the table but MySQL Optimizer/Execution engine just not capable of doing so yet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-339374</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sun, 03 Aug 2008 09:18:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-339374</guid>
		<description>I go to &quot;a whole &#039;nother level&quot; with this. I include a table in my databases that includes :

dt date
yy smallint # YEAR()
qq tinyint # QUARTER()
yyqq int #
mm tinyint # 
dd tinyint
wknum1 tinyint # WEEK()
yywknum1 int # YEARWEEK()
wknum2 tinyint # some things define the first wk of the yr as the first wk with Sunday in that yr,
               # so you sometimes end up with 2 definitions for what week of the year it is.
yywknum2 int # yy * 1000 + wknum2
dow tinyint # DAYOFWEEK()
dom tinyint # DAYOFMONTH()
doy tinyint # DAYOFYEAR()
yymmdd int
# flag fields
wkend tinyint # handy, but not necessary - 
              # makes queries more natural language 
              # select gross_rev from rev, days where rev.dt = days.dt and days.wkend = 1 and days.yy = 2008
              # no where clause function calls, OMG!
fdom tinyint # first day of the month
ldom tinyint # last day of the month
fwdom tinyint # first work day of the month
lwdom tinyint # last work day of the month
fwdoy tinyint # first work day of the yr
lwdoy tinyint # last work day of the yr
usholiday tinyint # is this a US holiday?wh
rain tinyint # did it rain on this day?
snow tinyint # did it snow on this day?
over85 tinyint # was it over 85F on this day?
fire tinyint # were there wild fires in the area on this day?

I spin up records for as much of the past as needed and for the next 10 - 50 years. 


This gives you the ability to quickly do reporting that includes very complex date requirements:
show me the coffee shop gross revenues for Q1 of the past 3 years for the first workday of each month during those periods. 

For business that have business that changes substantially based on certain events, you can have flag fields for those. Screamin&#039; Mimi&#039;s Ice Cream might want to have a report comparing Summer Saturday revenue on day hotter than 85F vs days cooler than that. Outdoor restaurants, boat rentals, downtown store that caters to the work day crowds, etc.

For other queries, having an easy way to check if something is the last day of the month is a blessing. It is massively useful and I can&#039;t imagine design a system without it.</description>
		<content:encoded><![CDATA[<p>I go to &#8220;a whole &#8216;nother level&#8221; with this. I include a table in my databases that includes :</p>
<p>dt date<br />
yy smallint # YEAR()<br />
qq tinyint # QUARTER()<br />
yyqq int #<br />
mm tinyint #<br />
dd tinyint<br />
wknum1 tinyint # WEEK()<br />
yywknum1 int # YEARWEEK()<br />
wknum2 tinyint # some things define the first wk of the yr as the first wk with Sunday in that yr,<br />
               # so you sometimes end up with 2 definitions for what week of the year it is.<br />
yywknum2 int # yy * 1000 + wknum2<br />
dow tinyint # DAYOFWEEK()<br />
dom tinyint # DAYOFMONTH()<br />
doy tinyint # DAYOFYEAR()<br />
yymmdd int<br />
# flag fields<br />
wkend tinyint # handy, but not necessary &#8211;<br />
              # makes queries more natural language<br />
              # select gross_rev from rev, days where rev.dt = days.dt and days.wkend = 1 and days.yy = 2008<br />
              # no where clause function calls, OMG!<br />
fdom tinyint # first day of the month<br />
ldom tinyint # last day of the month<br />
fwdom tinyint # first work day of the month<br />
lwdom tinyint # last work day of the month<br />
fwdoy tinyint # first work day of the yr<br />
lwdoy tinyint # last work day of the yr<br />
usholiday tinyint # is this a US holiday?wh<br />
rain tinyint # did it rain on this day?<br />
snow tinyint # did it snow on this day?<br />
over85 tinyint # was it over 85F on this day?<br />
fire tinyint # were there wild fires in the area on this day?</p>
<p>I spin up records for as much of the past as needed and for the next 10 &#8211; 50 years. </p>
<p>This gives you the ability to quickly do reporting that includes very complex date requirements:<br />
show me the coffee shop gross revenues for Q1 of the past 3 years for the first workday of each month during those periods. </p>
<p>For business that have business that changes substantially based on certain events, you can have flag fields for those. Screamin&#8217; Mimi&#8217;s Ice Cream might want to have a report comparing Summer Saturday revenue on day hotter than 85F vs days cooler than that. Outdoor restaurants, boat rentals, downtown store that caters to the work day crowds, etc.</p>
<p>For other queries, having an easy way to check if something is the last day of the month is a blessing. It is massively useful and I can&#8217;t imagine design a system without it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-339334</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Sun, 03 Aug 2008 06:41:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-339334</guid>
		<description>Right. It does not only applies to between  &lt;, &gt;   complex combinations are all have the same issue.

As you can see the trick is - if we have AND for different index part we can put selections  on different tables instead and just use EQ join on the main fact table.</description>
		<content:encoded><![CDATA[<p>Right. It does not only applies to between  < , >   complex combinations are all have the same issue.</p>
<p>As you can see the trick is &#8211; if we have AND for different index part we can put selections  on different tables instead and just use EQ join on the main fact table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-339323</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Sun, 03 Aug 2008 06:14:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-339323</guid>
		<description>Maybe I misunderstood the nature of the problem here - is it not just between clauses, but any where clause that isn&#039;t direct equality or IN ?</description>
		<content:encoded><![CDATA[<p>Maybe I misunderstood the nature of the problem here &#8211; is it not just between clauses, but any where clause that isn&#8217;t direct equality or IN ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-339121</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Sat, 02 Aug 2008 17:12:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-339121</guid>
		<description>Scott,

Why would you expect having  ranges on different columns to help in this case ?</description>
		<content:encoded><![CDATA[<p>Scott,</p>
<p>Why would you expect having  ranges on different columns to help in this case ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/01/how-adding-another-table-to-join-can-improve-performance/comment-page-1/#comment-339120</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Sat, 02 Aug 2008 17:11:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=454#comment-339120</guid>
		<description>Ryan,

With optimizer we always find issues. Some of them are bugs others are just limitations in logic.  In this case it is exactly this case - Optimizer could consider and use such plans but it does not do it, as it can&#039;t do hash join, loose index scan etc.</description>
		<content:encoded><![CDATA[<p>Ryan,</p>
<p>With optimizer we always find issues. Some of them are bugs others are just limitations in logic.  In this case it is exactly this case &#8211; Optimizer could consider and use such plans but it does not do it, as it can&#8217;t do hash join, loose index scan etc.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
