<?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 Tuning</title>
	<atom:link href="http://www.barneyb.com/barneyblog/2009/04/30/mysql-tuning/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.barneyb.com/barneyblog/2009/04/30/mysql-tuning/</link>
	<description>Thoughts, rants, and even some code from the mind of Barney Boisvert.</description>
	<lastBuildDate>Thu, 11 Sep 2014 09:58:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Matthew Lesko</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/30/mysql-tuning/comment-page-1/#comment-176298</link>
		<dc:creator>Matthew Lesko</dc:creator>
		<pubDate>Mon, 04 May 2009 17:41:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=892#comment-176298</guid>
		<description>Some thoughts and notes from my own experiences working with MySQL: 

#1. The blog you&#039;ve mentioned is very helpful and their book &quot;High Performance MySQL&quot; is worth purchasing. This is a very good book on databases in general and provides specific information about when to use the different backing engines that MySQL supports. 

#2. As of version 5.1, nested subquery performance is exponentially slow. The following query will go exponentially slower as the number of records increases in TableA. 

SELECT A.ID
FROM TableA A
WHERE 
    A.ID IN (
        SELECT B.FK_ID
        FROM TableB B 	
        WHERE B.OTHER_COLUMN = &#039;[Some Value]&#039;
    )

Reference link regarding performance: http://www.selikoff.net/blog/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/ 

Note, this is being addressed in 5.4 (see: http://dev.mysql.com/tech-resources/articles/mysql-54.html Subquery Optimizations). 

Yes, the query could be rewritten as an inner join (note EXISTS does not improve performance for this on MySQL). But reality is that there is a lot of SQL written this way. SQL that works just fine with SQL Server and Oracle. So caveat emptor. 

#3. The slow query log is invaluable for finding said lousy queries (see: http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html). What&#039;s even nicer is that as of 5.1 it can be turned on and off at runtime (i.e. no server restart required).</description>
		<content:encoded><![CDATA[<p>Some thoughts and notes from my own experiences working with MySQL: </p>
<p>#1. The blog you've mentioned is very helpful and their book "High Performance MySQL" is worth purchasing. This is a very good book on databases in general and provides specific information about when to use the different backing engines that MySQL supports. </p>
<p>#2. As of version 5.1, nested subquery performance is exponentially slow. The following query will go exponentially slower as the number of records increases in TableA. </p>
<p>SELECT A.ID<br />
FROM TableA A<br />
WHERE<br />
    A.ID IN (<br />
        SELECT B.FK_ID<br />
        FROM TableB B<br />
        WHERE B.OTHER_COLUMN = '[Some Value]'<br />
    )</p>
<p>Reference link regarding performance: <a href="http://www.selikoff.net/blog/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/" rel="nofollow">http://www.selikoff.net/blog/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/</a> </p>
<p>Note, this is being addressed in 5.4 (see: <a href="http://dev.mysql.com/tech-resources/articles/mysql-54.html" rel="nofollow">http://dev.mysql.com/tech-resources/articles/mysql-54.html</a> Subquery Optimizations). </p>
<p>Yes, the query could be rewritten as an inner join (note EXISTS does not improve performance for this on MySQL). But reality is that there is a lot of SQL written this way. SQL that works just fine with SQL Server and Oracle. So caveat emptor. </p>
<p>#3. The slow query log is invaluable for finding said lousy queries (see: <a href="http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html)" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html)</a>. What's even nicer is that as of 5.1 it can be turned on and off at runtime (i.e. no server restart required).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
