<?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: MySQL Can&#8217;t Use Index With Uncorrelated IN Subquery</title>
	<atom:link href="http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/</link>
	<description>News and views from Pythian DBAs</description>
	<lastBuildDate>Thu, 18 Mar 2010 00:27:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Alex Gorbachev</title>
		<link>http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/#comment-14285</link>
		<dc:creator>Alex Gorbachev</dc:creator>
		<pubDate>Thu, 11 Jan 2007 17:39:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery#comment-14285</guid>
		<description>&lt;i&gt;&quot;In my case both could be â€™solvedâ€™ by avoiding the subquery.&quot;&lt;/i&gt;
Once again a reminder to stick to the old rules.
Thanks for your comment Eric.</description>
		<content:encoded><![CDATA[<p><i>&#8220;In my case both could be â€™solvedâ€™ by avoiding the subquery.&#8221;</i><br />
Once again a reminder to stick to the old rules.<br />
Thanks for your comment Eric.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/#comment-14275</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 11 Jan 2007 17:07:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery#comment-14275</guid>
		<description>9.2.0.6
Most of them where correlated, a few were uncorrelated. In my case both could be &#039;solved&#039; by avoiding the subquery.</description>
		<content:encoded><![CDATA[<p>9.2.0.6<br />
Most of them where correlated, a few were uncorrelated. In my case both could be &#8217;solved&#8217; by avoiding the subquery.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Gorbachev</title>
		<link>http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/#comment-14255</link>
		<dc:creator>Alex Gorbachev</dc:creator>
		<pubDate>Thu, 11 Jan 2007 14:09:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery#comment-14255</guid>
		<description>Eric, this was custom written application. What version of Oracle were you on? Your IN subqueries were uncorrelated? I find that correlated subqueries often causes issues even in 10g and, perhaps, more often in 10g with introduction of few smart CBO features that don&#039;t seem to work well all the time.</description>
		<content:encoded><![CDATA[<p>Eric, this was custom written application. What version of Oracle were you on? Your IN subqueries were uncorrelated? I find that correlated subqueries often causes issues even in 10g and, perhaps, more often in 10g with introduction of few smart CBO features that don&#8217;t seem to work well all the time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/#comment-14247</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 11 Jan 2007 12:50:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery#comment-14247</guid>
		<description>Alex,

I had the exact same problem with a lot of queries like this in oracle. Not much of performance until we rewrote the subqueries as joins. Subqueries seem to be a bit of a problem for the oracle optimizer as well. The queries were of course somewhat more complex which did not make it easier for the optimizer. 
Maybe the optimizer for MySQL is not that bad after all? Or they both need some work to be done?

Where these queries generated through Hibernate by any chance? In my case they were and if IIRC you could &#039;teach&#039; Hibernate to generate the joins instead of the subqueries. But I do not remember how that was done. Probably to be found in the Hibernate docs.</description>
		<content:encoded><![CDATA[<p>Alex,</p>
<p>I had the exact same problem with a lot of queries like this in oracle. Not much of performance until we rewrote the subqueries as joins. Subqueries seem to be a bit of a problem for the oracle optimizer as well. The queries were of course somewhat more complex which did not make it easier for the optimizer.<br />
Maybe the optimizer for MySQL is not that bad after all? Or they both need some work to be done?</p>
<p>Where these queries generated through Hibernate by any chance? In my case they were and if IIRC you could &#8216;teach&#8217; Hibernate to generate the joins instead of the subqueries. But I do not remember how that was done. Probably to be found in the Hibernate docs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Noons</title>
		<link>http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/#comment-14002</link>
		<dc:creator>Noons</dc:creator>
		<pubDate>Wed, 10 Jan 2007 01:17:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery#comment-14002</guid>
		<description>In regard to Paul&#039;s comment: I have yet to see faster CPU hardware make a disk spin faster!   For as long as we have to use disks - or any storage technology outside the CPU itself - the performance limitation will be how fast we can get that data back into the main memory for processing by the CPU.  And that&#039;s where indexes, optimizers and other such kick in.  

Looking at volumetric trends shows us also that while disk performance and speed hasn&#039;t improved as much, disk capacity certainly has.  There is as such a current imbalance between how much you stack in a disk and how fast you can do it or get it.  And I don&#039;t see any hardware way of addressing that imbalance.  Other than solid state memory, which is a bit far away at the moment in terms of usable capacity.

All this to say that indexing and optimisers will be here for a long while yet.  In fact, looking at Jim Gray&#039;s  &quot;Petabyte&quot; musings, I&#039;d say you&#039;ll see even more interesting stuff happening in the field of large scale data storage cataloguing: someone, somehow, somewhere, has to be able to efficiently get at all those PBs!</description>
		<content:encoded><![CDATA[<p>In regard to Paul&#8217;s comment: I have yet to see faster CPU hardware make a disk spin faster!   For as long as we have to use disks &#8211; or any storage technology outside the CPU itself &#8211; the performance limitation will be how fast we can get that data back into the main memory for processing by the CPU.  And that&#8217;s where indexes, optimizers and other such kick in.  </p>
<p>Looking at volumetric trends shows us also that while disk performance and speed hasn&#8217;t improved as much, disk capacity certainly has.  There is as such a current imbalance between how much you stack in a disk and how fast you can do it or get it.  And I don&#8217;t see any hardware way of addressing that imbalance.  Other than solid state memory, which is a bit far away at the moment in terms of usable capacity.</p>
<p>All this to say that indexing and optimisers will be here for a long while yet.  In fact, looking at Jim Gray&#8217;s  &#8220;Petabyte&#8221; musings, I&#8217;d say you&#8217;ll see even more interesting stuff happening in the field of large scale data storage cataloguing: someone, somehow, somewhere, has to be able to efficiently get at all those PBs!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Gorbachev</title>
		<link>http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/#comment-13970</link>
		<dc:creator>Alex Gorbachev</dc:creator>
		<pubDate>Tue, 09 Jan 2007 22:25:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery#comment-13970</guid>
		<description>Gary,

Thanks for spotting the typo or rather c&amp;p error. This just a dirty example assuming that t2.c1 is a PK, for example. Obviously, I couldn&#039;t share real customer queries. The right statement should be:
&lt;pre&gt;SELECT t1.*
   FROM t1, t2
  WHERE t1.c1=t2.c1
    AND t2.c2=100;&lt;/pre&gt;

In addition to what you said, our customer expressed an interesting point today - would you prefer letting that mainframe software keep you credit card and account balance or it&#039;s fine to move it to Oracle? Now what about MySQL?

Perhaps, some people would answer yes to the second question now. In some time they might even answer yes to the second question.

However, there are people (in fact, majority) that would answer &quot;Why would I care?&quot;. Those are the people who don&#039;t need to know about mainframes, Oracle and MySQL but do need to know that they are able to take cash from the ATM machine anytime and they don&#039;t need to wait few minutes for that. Of course, they have some other requirements like no one else is able to manipulate their account.

If that can be delivered by MySQL at some point - why not?</description>
		<content:encoded><![CDATA[<p>Gary,</p>
<p>Thanks for spotting the typo or rather c&#038;p error. This just a dirty example assuming that t2.c1 is a PK, for example. Obviously, I couldn&#8217;t share real customer queries. The right statement should be:</p>
<pre>SELECT t1.*
   FROM t1, t2
  WHERE t1.c1=t2.c1
    AND t2.c2=100;</pre>
<p>In addition to what you said, our customer expressed an interesting point today &#8211; would you prefer letting that mainframe software keep you credit card and account balance or it&#8217;s fine to move it to Oracle? Now what about MySQL?</p>
<p>Perhaps, some people would answer yes to the second question now. In some time they might even answer yes to the second question.</p>
<p>However, there are people (in fact, majority) that would answer &#8220;Why would I care?&#8221;. Those are the people who don&#8217;t need to know about mainframes, Oracle and MySQL but do need to know that they are able to take cash from the ATM machine anytime and they don&#8217;t need to wait few minutes for that. Of course, they have some other requirements like no one else is able to manipulate their account.</p>
<p>If that can be delivered by MySQL at some point &#8211; why not?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/#comment-13966</link>
		<dc:creator>Gary</dc:creator>
		<pubDate>Tue, 09 Jan 2007 21:56:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery#comment-13966</guid>
		<description>I assume the mismatched bracket in the new query is just a typo, but can&#039;t help but point out that, if there can be multiple rows in &#039;t2&#039; with a &#039;c2&#039; of 100 and the same &#039;&#039;c1&#039; value, then the queries are not equivalent.
As for Paul&#039;s comment, the problem is that while CPUs are getting faster, and disk space is getting bigger/cheaper, disk access speed is pretty much static AND data volumes are increasing. As such, indexing and optimization innovations get more important not less. That assumes data volumes keep in-memory databases from the mainstream though.</description>
		<content:encoded><![CDATA[<p>I assume the mismatched bracket in the new query is just a typo, but can&#8217;t help but point out that, if there can be multiple rows in &#8216;t2&#8242; with a &#8216;c2&#8242; of 100 and the same &#8221;c1&#8242; value, then the queries are not equivalent.<br />
As for Paul&#8217;s comment, the problem is that while CPUs are getting faster, and disk space is getting bigger/cheaper, disk access speed is pretty much static AND data volumes are increasing. As such, indexing and optimization innovations get more important not less. That assumes data volumes keep in-memory databases from the mainstream though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Vallee</title>
		<link>http://www.pythian.com/news/355/mysql-cant-use-index-with-uncorrelated-in-subquery/#comment-13950</link>
		<dc:creator>Paul Vallee</dc:creator>
		<pubDate>Tue, 09 Jan 2007 19:55:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery#comment-13950</guid>
		<description>I exchanged an IM conversation with Alex about this and he suggested I post my thoughts on the blog. Here they are lightly edited:

gorbyx: http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery


Paul: interesting observation for you
the faster the underlying hardware, the less valuable oracle&#039;s indexing and optimizing innovations (not to mention patents) become
as as hardware is getting faster faster and faster, these issues become minor issues and then non-issues
this causes enormous depreciation of IBM&#039;s and oracle&#039;s technology and patent portfolios
so ultimately, especially following the millsap what&#039;s the business impact tuning method, these issues with databse platforms are meaningless. if it&#039;s not meaningless now, it&#039;ll be meaningless next year, or the year after that anyway.
in the meantime, it&#039;s cheaper to pay you to rewrite the query than it is to license oracle or db2
gorbyx: well, I see the point. I don&#039;t agree so far but what do I see in my life?
put you comment on the blog - it&#039;s interesting</description>
		<content:encoded><![CDATA[<p>I exchanged an IM conversation with Alex about this and he suggested I post my thoughts on the blog. Here they are lightly edited:</p>
<p>gorbyx: <a href="http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery" rel="nofollow">http://www.pythian.com/blogs/355/mysql-cant-use-index-with-uncorrelated-in-subquery</a></p>
<p>Paul: interesting observation for you<br />
the faster the underlying hardware, the less valuable oracle&#8217;s indexing and optimizing innovations (not to mention patents) become<br />
as as hardware is getting faster faster and faster, these issues become minor issues and then non-issues<br />
this causes enormous depreciation of IBM&#8217;s and oracle&#8217;s technology and patent portfolios<br />
so ultimately, especially following the millsap what&#8217;s the business impact tuning method, these issues with databse platforms are meaningless. if it&#8217;s not meaningless now, it&#8217;ll be meaningless next year, or the year after that anyway.<br />
in the meantime, it&#8217;s cheaper to pay you to rewrite the query than it is to license oracle or db2<br />
gorbyx: well, I see the point. I don&#8217;t agree so far but what do I see in my life?<br />
put you comment on the blog &#8211; it&#8217;s interesting</p>
]]></content:encoded>
	</item>
</channel>
</rss>
