<?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: For those who don&#8217;t use SQL too much, just like me.</title>
	<atom:link href="http://pko.ch/2008/06/17/for-those-who-dont-use-sql-too-much-just-like-me/feed/" rel="self" type="application/rss+xml" />
	<link>http://pko.ch/2008/06/17/for-those-who-dont-use-sql-too-much-just-like-me/</link>
	<description>Reflections about reflection</description>
	<lastBuildDate>Tue, 01 Sep 2009 23:39:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: pkoch</title>
		<link>http://pko.ch/2008/06/17/for-those-who-dont-use-sql-too-much-just-like-me/comment-page-1/#comment-76</link>
		<dc:creator>pkoch</dc:creator>
		<pubDate>Thu, 19 Feb 2009 00:07:23 +0000</pubDate>
		<guid isPermaLink="false">http://pko.ch/?p=12#comment-76</guid>
		<description>Hmm. I&#039;ll run some benchmarks and post them.

About the style, it varies. NOT IN is sometimes more legible, sometimes it&#039;s NOT EXISTS.</description>
		<content:encoded><![CDATA[<p>Hmm. I&#8217;ll run some benchmarks and post them.</p>
<p>About the style, it varies. NOT IN is sometimes more legible, sometimes it&#8217;s NOT EXISTS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: André Restivo</title>
		<link>http://pko.ch/2008/06/17/for-those-who-dont-use-sql-too-much-just-like-me/comment-page-1/#comment-75</link>
		<dc:creator>André Restivo</dc:creator>
		<pubDate>Wed, 18 Feb 2009 00:56:12 +0000</pubDate>
		<guid isPermaLink="false">http://pko.ch/?p=12#comment-75</guid>
		<description>Imagine this query from the link you gave above:

SELECT DISTINCT store_type FROM stores
  WHERE NOT EXISTS (SELECT * FROM cities_stores
                    WHERE cities_stores.store_type = stores.store_type);

For each line of the outer query the inner query has to be computed again because stores.store_type changes. Of course MySQL can have an intelligent caching mechanism, but if the number of stores is very big it won&#039;t be enough. If MySQL is really intelligent it will transform the query into something similar to what I proposed. I know for a fact that PostgreSQL doesn&#039;t like this type of queries very much.

In the example I wrote before. The inner query has to be performed only once and then it&#039;s just a matter of using the index wisely.

Have you tried both approaches with some big chunks of data? You won&#039;t notice the difference with small tables.

IMHO I think that the NOT IN clause is easier to understand than the NOT EXISTS clause and also more elegant. But it&#039;s a matter of taste really ...</description>
		<content:encoded><![CDATA[<p>Imagine this query from the link you gave above:</p>
<p>SELECT DISTINCT store_type FROM stores<br />
  WHERE NOT EXISTS (SELECT * FROM cities_stores<br />
                    WHERE cities_stores.store_type = stores.store_type);</p>
<p>For each line of the outer query the inner query has to be computed again because stores.store_type changes. Of course MySQL can have an intelligent caching mechanism, but if the number of stores is very big it won&#8217;t be enough. If MySQL is really intelligent it will transform the query into something similar to what I proposed. I know for a fact that PostgreSQL doesn&#8217;t like this type of queries very much.</p>
<p>In the example I wrote before. The inner query has to be performed only once and then it&#8217;s just a matter of using the index wisely.</p>
<p>Have you tried both approaches with some big chunks of data? You won&#8217;t notice the difference with small tables.</p>
<p>IMHO I think that the NOT IN clause is easier to understand than the NOT EXISTS clause and also more elegant. But it&#8217;s a matter of taste really &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pkoch</title>
		<link>http://pko.ch/2008/06/17/for-those-who-dont-use-sql-too-much-just-like-me/comment-page-1/#comment-74</link>
		<dc:creator>pkoch</dc:creator>
		<pubDate>Wed, 18 Feb 2009 00:24:33 +0000</pubDate>
		<guid isPermaLink="false">http://pko.ch/?p=12#comment-74</guid>
		<description>Hmm, that&#039;s contradictory to my MySQL experience. How/where did you observe that behaviour?</description>
		<content:encoded><![CDATA[<p>Hmm, that&#8217;s contradictory to my MySQL experience. How/where did you observe that behaviour?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: André Restivo</title>
		<link>http://pko.ch/2008/06/17/for-those-who-dont-use-sql-too-much-just-like-me/comment-page-1/#comment-73</link>
		<dc:creator>André Restivo</dc:creator>
		<pubDate>Tue, 17 Feb 2009 23:24:10 +0000</pubDate>
		<guid isPermaLink="false">http://pko.ch/?p=12#comment-73</guid>
		<description>select * from category
where category.id not in (select cat_id from cat_post where post_id = $the_post_id)

This way seems easier and it&#039;s probably faster as DB usually don&#039;t cope well with &#039;exists&#039; clauses.</description>
		<content:encoded><![CDATA[<p>select * from category<br />
where category.id not in (select cat_id from cat_post where post_id = $the_post_id)</p>
<p>This way seems easier and it&#8217;s probably faster as DB usually don&#8217;t cope well with &#8216;exists&#8217; clauses.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
