<?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: Memo: Avoid Nested Queries in MySQL at all costs	</title>
	<atom:link href="https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/</link>
	<description>Java/J2EE Software Development and Technology Discussion Blog</description>
	<lastBuildDate>Sat, 25 Jul 2015 01:03:37 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>
		By: H. Shing		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-159143</link>

		<dc:creator><![CDATA[H. Shing]]></dc:creator>
		<pubDate>Sat, 25 Jul 2015 01:03:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-159143</guid>

					<description><![CDATA[I changed the nested queries:

SELECT id, sender
FROM msgTable
WHERE sender=&#039;John&#039;
OR id IN (SELECT id FROM receiverTable WHERE receiver=&#039;John&#039;)

to the query with JOIN:

SELECT M.id, M.sender
FROM msgTable M LEFT JOIN receiverTable R ON M.id=R.id
WHERE M.sender=&#039;John&#039;
OR R.receiver=&#039;John&#039;

The OR&#039;ed conditions worry me.  Will the database smart enough to use the conditions separately for each table to limit the join size, or will it end up creating a large join table before applying the OR&#039;ed conditions in WHERE?  If it is the latter, will it better to just use nested queries, rather than JOIN?]]></description>
			<content:encoded><![CDATA[<p>I changed the nested queries:</p>
<p>SELECT id, sender<br />
FROM msgTable<br />
WHERE sender=&#8217;John&#8217;<br />
OR id IN (SELECT id FROM receiverTable WHERE receiver=&#8217;John&#8217;)</p>
<p>to the query with JOIN:</p>
<p>SELECT M.id, M.sender<br />
FROM msgTable M LEFT JOIN receiverTable R ON M.id=R.id<br />
WHERE M.sender=&#8217;John&#8217;<br />
OR R.receiver=&#8217;John&#8217;</p>
<p>The OR&#8217;ed conditions worry me.  Will the database smart enough to use the conditions separately for each table to limit the join size, or will it end up creating a large join table before applying the OR&#8217;ed conditions in WHERE?  If it is the latter, will it better to just use nested queries, rather than JOIN?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Scott Selikoff		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-156686</link>

		<dc:creator><![CDATA[Scott Selikoff]]></dc:creator>
		<pubDate>Mon, 08 Jun 2015 03:41:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-156686</guid>

					<description><![CDATA[@ The Lone Man

Nested queries are still considered a poor practice in general, even if MySQL did close this issue.  For general performance reasons, you should still avoid them in all DBMS&#039;s whenever possible.]]></description>
			<content:encoded><![CDATA[<p>@ The Lone Man</p>
<p>Nested queries are still considered a poor practice in general, even if MySQL did close this issue.  For general performance reasons, you should still avoid them in all DBMS&#8217;s whenever possible.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: The Lone Man		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-156224</link>

		<dc:creator><![CDATA[The Lone Man]]></dc:creator>
		<pubDate>Tue, 02 Jun 2015 13:52:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-156224</guid>

					<description><![CDATA[They closed the bug you mentioned in the article SIX years and seven months later it was opened:

http://bugs.mysql.com/bug.php?id=17952

Better late than ever. Can you please update your article as well?]]></description>
			<content:encoded><![CDATA[<p>They closed the bug you mentioned in the article SIX years and seven months later it was opened:</p>
<p><a href="http://bugs.mysql.com/bug.php?id=17952" rel="nofollow ugc">http://bugs.mysql.com/bug.php?id=17952</a></p>
<p>Better late than ever. Can you please update your article as well?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Chen Asraf		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-155098</link>

		<dc:creator><![CDATA[Chen Asraf]]></dc:creator>
		<pubDate>Thu, 07 May 2015 07:15:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-155098</guid>

					<description><![CDATA[Is this still true in 2015 or did they improve optimization or did something about this?]]></description>
			<content:encoded><![CDATA[<p>Is this still true in 2015 or did they improve optimization or did something about this?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Andrew Willis		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-5006</link>

		<dc:creator><![CDATA[Andrew Willis]]></dc:creator>
		<pubDate>Fri, 18 May 2012 00:01:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-5006</guid>

					<description><![CDATA[I was using a nested query to re-order results:

&quot;SELECT *
FROM (
SELECT *
FROM messages
ORDER BY message_id DESC
LIMIT 15
)
ORDER BY message_id ASC&quot;

Is it possible to write this as a join? I tried for hours but had to resort to this!]]></description>
			<content:encoded><![CDATA[<p>I was using a nested query to re-order results:</p>
<p>&#8220;SELECT *<br />
FROM (<br />
SELECT *<br />
FROM messages<br />
ORDER BY message_id DESC<br />
LIMIT 15<br />
)<br />
ORDER BY message_id ASC&#8221;</p>
<p>Is it possible to write this as a join? I tried for hours but had to resort to this!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Rene Verheij		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-4920</link>

		<dc:creator><![CDATA[Rene Verheij]]></dc:creator>
		<pubDate>Sat, 11 Feb 2012 11:29:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-4920</guid>

					<description><![CDATA[thank you for this! I was already doing a little bit of joining, but preferred writing nested queries for the sake of simplicity ... now things were getting more complicated and I&#039;m glad to have read this ...

time difference for me: -0.005458 seconds compared to -0.545683 ... That&#039;s a 100 times faster!

Before:
SELECT * FROM `content` 
WHERE `content`.`predicate_id` = &#039;3&#039; 
AND `content`.`object_id` IN (&#039;x&#039;,&#039;y&#039;,&#039;z&#039;)
AND `content`.`subject_id` IN 
 (SELECT `subject_id` FROM `content` 
 WHERE `content`.`predicate_id` = &#039;some_var&#039;
 AND `content`.`object_id` = &#039;:some_value&#039;)

time: -0.545683

With join:
SELECT * FROM `content` 
LEFT JOIN `content` AS `content2` on `content`.`subject_id` = `content2`.`subject_id` 
WHERE `content`.`predicate_id` = &#039;3&#039; 
AND `content`.`object_id` IN (&#039;x&#039;,&#039;y&#039;,&#039;z&#039;)  
AND `content2`.`predicate_id` = &#039;some_var&#039;
AND `content2`.`object_id` = &#039;:some_value&#039;

time: -0.005458!]]></description>
			<content:encoded><![CDATA[<p>thank you for this! I was already doing a little bit of joining, but preferred writing nested queries for the sake of simplicity &#8230; now things were getting more complicated and I&#8217;m glad to have read this &#8230;</p>
<p>time difference for me: -0.005458 seconds compared to -0.545683 &#8230; That&#8217;s a 100 times faster!</p>
<p>Before:<br />
SELECT * FROM `content`<br />
WHERE `content`.`predicate_id` = &#8216;3&#8217;<br />
AND `content`.`object_id` IN (&#8216;x&#8217;,&#8217;y&#8217;,&#8217;z&#8217;)<br />
AND `content`.`subject_id` IN<br />
 (SELECT `subject_id` FROM `content`<br />
 WHERE `content`.`predicate_id` = &#8216;some_var&#8217;<br />
 AND `content`.`object_id` = &#8216;:some_value&#8217;)</p>
<p>time: -0.545683</p>
<p>With join:<br />
SELECT * FROM `content`<br />
LEFT JOIN `content` AS `content2` on `content`.`subject_id` = `content2`.`subject_id`<br />
WHERE `content`.`predicate_id` = &#8216;3&#8217;<br />
AND `content`.`object_id` IN (&#8216;x&#8217;,&#8217;y&#8217;,&#8217;z&#8217;)<br />
AND `content2`.`predicate_id` = &#8216;some_var&#8217;<br />
AND `content2`.`object_id` = &#8216;:some_value&#8217;</p>
<p>time: -0.005458!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Scott Selikoff		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-4891</link>

		<dc:creator><![CDATA[Scott Selikoff]]></dc:creator>
		<pubDate>Sun, 08 Jan 2012 12:00:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-4891</guid>

					<description><![CDATA[You should focus on learning Database Joins, not MySQL Joins, as the concepts are the same across databases.  I&#039;d spend time learning the theory behind joins and then it won&#039;t seem to complicated.]]></description>
			<content:encoded><![CDATA[<p>You should focus on learning Database Joins, not MySQL Joins, as the concepts are the same across databases.  I&#8217;d spend time learning the theory behind joins and then it won&#8217;t seem to complicated.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Simon		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-4890</link>

		<dc:creator><![CDATA[Simon]]></dc:creator>
		<pubDate>Sun, 08 Jan 2012 11:56:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-4890</guid>

					<description><![CDATA[I&#039;m just starting to get into more complicated MYSQL queries as my job requires this but I can&#039;t understand them at all! does anyone know a good resource for learning about joining in mysql queries?]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m just starting to get into more complicated MYSQL queries as my job requires this but I can&#8217;t understand them at all! does anyone know a good resource for learning about joining in mysql queries?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Are lots of queries faster in MySql than a big JOIN? &#124; Smash Company		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-2837</link>

		<dc:creator><![CDATA[Are lots of queries faster in MySql than a big JOIN? &#124; Smash Company]]></dc:creator>
		<pubDate>Sat, 25 Sep 2010 00:21:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-2837</guid>

					<description><![CDATA[[...] find this hard to believe, but I&#8217;ve now read it in several places. Some people seem to think that lots of queries are faster than big JOINs, in MySql. [...]]]></description>
			<content:encoded><![CDATA[<p>[&#8230;] find this hard to believe, but I&#8217;ve now read it in several places. Some people seem to think that lots of queries are faster than big JOINs, in MySql. [&#8230;]</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: MySQL and nested queries &#171; Ablue Blog		</title>
		<link>https://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/comment-page-1/#comment-2746</link>

		<dc:creator><![CDATA[MySQL and nested queries &#171; Ablue Blog]]></dc:creator>
		<pubDate>Sun, 05 Sep 2010 12:50:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.selikoff.net/blog/?p=652#comment-2746</guid>

					<description><![CDATA[[...] Here is a good blog post that describes the problem. [...]]]></description>
			<content:encoded><![CDATA[<p>[&#8230;] Here is a good blog post that describes the problem. [&#8230;]</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
