<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: NOT IN</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2007/02/25/not-in/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Thu, 23 May 2013 12:47:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: peatoo</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-40766</link>
		<dc:creator><![CDATA[peatoo]]></dc:creator>
		<pubDate>Wed, 15 Jun 2011 07:55:44 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-40766</guid>
		<description><![CDATA[I couldn&#039;t get results from query with WHERE starement &quot;and colx not in (select col from table)&quot;. Thanks for info.]]></description>
		<content:encoded><![CDATA[<p>I couldn&#8217;t get results from query with WHERE starement &#8220;and colx not in (select col from table)&#8221;. Thanks for info.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: things2note4</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-35173</link>
		<dc:creator><![CDATA[things2note4]]></dc:creator>
		<pubDate>Thu, 07 Jan 2010 16:36:25 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-35173</guid>
		<description><![CDATA[Thanks for this info! It helped troubleshoot my issue....
Keep up the good work!]]></description>
		<content:encoded><![CDATA[<p>Thanks for this info! It helped troubleshoot my issue&#8230;.<br />
Keep up the good work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hemant K Chitale</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-30858</link>
		<dc:creator><![CDATA[Hemant K Chitale]]></dc:creator>
		<pubDate>Thu, 17 Apr 2008 06:32:24 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-30858</guid>
		<description><![CDATA[A google search when trying to tune a NOT EXISTS  query had led me to Rogher Schrag&#039;s
paper at  http://www.dbspecialists.com/presentations/semijoins.html
Worth a good (detailed) reading.]]></description>
		<content:encoded><![CDATA[<p>A google search when trying to tune a NOT EXISTS  query had led me to Rogher Schrag&#8217;s<br />
paper at  <a href="http://www.dbspecialists.com/presentations/semijoins.html" rel="nofollow">http://www.dbspecialists.com/presentations/semijoins.html</a><br />
Worth a good (detailed) reading.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Purple</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-30830</link>
		<dc:creator><![CDATA[Purple]]></dc:creator>
		<pubDate>Fri, 11 Apr 2008 10:46:39 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-30830</guid>
		<description><![CDATA[You should use NVL, which replace null values by a given value to solve this issue.

select * from scott.emp
where NVL(comm,&#039; &#039;) not in (Null,300,500);]]></description>
		<content:encoded><![CDATA[<p>You should use NVL, which replace null values by a given value to solve this issue.</p>
<p>select * from scott.emp<br />
where NVL(comm,&#8217; &#8216;) not in (Null,300,500);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prerequisites for using Oracle’s anti-join access paths &#171; H.Tonguç YILMAZ Oracle Blog</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3709</link>
		<dc:creator><![CDATA[Prerequisites for using Oracle’s anti-join access paths &#171; H.Tonguç YILMAZ Oracle Blog]]></dc:creator>
		<pubDate>Fri, 02 Mar 2007 06:31:55 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3709</guid>
		<description><![CDATA[[...] Refences Used : &#8220;NOT IN in SQL&#8221; thread on AskTom Metalink Note:28934.1 &#8220;Use of indexes with NOT IN subquery&#8221; “Speeding Up Queries with Semi-Joins and Anti-Joins: How Oracle Evaluates EXISTS, NOT EXISTS, IN, and NOT IN,” by Roger Schrag (December 2004) Jonathan Lewis&#8217;s NOT IN Blog Entry [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Refences Used : &#8220;NOT IN in SQL&#8221; thread on AskTom Metalink Note:28934.1 &#8220;Use of indexes with NOT IN subquery&#8221; “Speeding Up Queries with Semi-Joins and Anti-Joins: How Oracle Evaluates EXISTS, NOT EXISTS, IN, and NOT IN,” by Roger Schrag (December 2004) Jonathan Lewis&#8217;s NOT IN Blog Entry [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mihajlo Tekic</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3668</link>
		<dc:creator><![CDATA[Mihajlo Tekic]]></dc:creator>
		<pubDate>Mon, 26 Feb 2007 22:11:08 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3668</guid>
		<description><![CDATA[Jonathan, That is just another option.]]></description>
		<content:encoded><![CDATA[<p>Jonathan, That is just another option.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3667</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 26 Feb 2007 21:48:09 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3667</guid>
		<description><![CDATA[Mihajlo, If it&#039;s legal to do so, then adding &lt;em&gt;&quot;is not null&quot;&lt;/em&gt; at both ends of the comparison should allow the optimizer to convert the &lt;em&gt;&lt;strong&gt;not in&lt;/strong&gt;&lt;/em&gt; to a &lt;em&gt;&lt;strong&gt;not exists&lt;/strong&gt;&lt;/em&gt;, then on to an &lt;em&gt;&lt;strong&gt;anti-join&lt;/strong&gt;&lt;/em&gt;. 
In outline:
&lt;code&gt;
where
&#160;&#160;&#160;&#160;colX is not null 
and colX not in (
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;select colY from ... where ... and colY is not null
&#160;&#160;&#160;&#160;)
&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>Mihajlo, If it&#8217;s legal to do so, then adding <em>&#8220;is not null&#8221;</em> at both ends of the comparison should allow the optimizer to convert the <em><strong>not in</strong></em> to a <em><strong>not exists</strong></em>, then on to an <em><strong>anti-join</strong></em>.<br />
In outline:<br />
<code><br />
where<br />
&nbsp;&nbsp;&nbsp;&nbsp;colX is not null<br />
and colX not in (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select colY from ... where ... and colY is not null<br />
&nbsp;&nbsp;&nbsp;&nbsp;)<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mihajlo Tekic</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3665</link>
		<dc:creator><![CDATA[Mihajlo Tekic]]></dc:creator>
		<pubDate>Mon, 26 Feb 2007 18:35:38 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3665</guid>
		<description><![CDATA[Jonathan,

I must say that from my experience NOT IN is very popular among the developers. 
For them maybe it is the easiest why to write a query that will select records from a table where some field does not belong in some set of values. Very often this set of values is query.
Although some of them know the effect of having NULL values in the list, many of them do not know how NOT IN can impact the performances.
A query with NOT IN, if it is not written properly, will perform very badly, even though it is sure that the sub-query cannot return nulls. 
And here the problem is. We know (about the nulls), but does the optimizer knows?
Such a query will perform a lot of consistent gets, which can be very painful.
As a workaround we have to make sure that no result column can return null. This can be done either with making the columns not null (which is not always good solution) or using NVL (I read about this some discussion on ASKTOM, but I don&#039;t remember the link). With this workaround optimizer will consider use of ANTI JOIN that will reduce consistent gets dramatically.

--Mihajlo]]></description>
		<content:encoded><![CDATA[<p>Jonathan,</p>
<p>I must say that from my experience NOT IN is very popular among the developers.<br />
For them maybe it is the easiest why to write a query that will select records from a table where some field does not belong in some set of values. Very often this set of values is query.<br />
Although some of them know the effect of having NULL values in the list, many of them do not know how NOT IN can impact the performances.<br />
A query with NOT IN, if it is not written properly, will perform very badly, even though it is sure that the sub-query cannot return nulls.<br />
And here the problem is. We know (about the nulls), but does the optimizer knows?<br />
Such a query will perform a lot of consistent gets, which can be very painful.<br />
As a workaround we have to make sure that no result column can return null. This can be done either with making the columns not null (which is not always good solution) or using NVL (I read about this some discussion on ASKTOM, but I don&#8217;t remember the link). With this workaround optimizer will consider use of ANTI JOIN that will reduce consistent gets dramatically.</p>
<p>&#8211;Mihajlo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zhu1 (木匠)</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3663</link>
		<dc:creator><![CDATA[zhu1 (木匠)]]></dc:creator>
		<pubDate>Mon, 26 Feb 2007 18:23:57 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3663</guid>
		<description><![CDATA[Try these 2 SQL, you will see the result.

--
select * from scott.emp
where comm not in (300,500);

select * from scott.emp
where comm not in (Null,300,500);]]></description>
		<content:encoded><![CDATA[<p>Try these 2 SQL, you will see the result.</p>
<p>&#8211;<br />
select * from scott.emp<br />
where comm not in (300,500);</p>
<p>select * from scott.emp<br />
where comm not in (Null,300,500);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3655</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 26 Feb 2007 11:46:29 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2007/02/25/not-in/#comment-3655</guid>
		<description><![CDATA[Toon,  you are, of course, correct. 

The IN test short-circuits its workload because it can answer the question &quot;Should I keep the current row&quot; with a YES on the first hit.

The NOT IN test short-circuits its workload because it can answer the question &quot;Should I keep the current row&quot; with a NO on the first hit.

I was too busy thinking about the cost of getting the YES, and forgetting that NO can be an equally useful answer.

Which reflects the mantra - if you want to be efficient it&#039;s best to understand your data.]]></description>
		<content:encoded><![CDATA[<p>Toon,  you are, of course, correct. </p>
<p>The IN test short-circuits its workload because it can answer the question &#8220;Should I keep the current row&#8221; with a YES on the first hit.</p>
<p>The NOT IN test short-circuits its workload because it can answer the question &#8220;Should I keep the current row&#8221; with a NO on the first hit.</p>
<p>I was too busy thinking about the cost of getting the YES, and forgetting that NO can be an equally useful answer.</p>
<p>Which reflects the mantra &#8211; if you want to be efficient it&#8217;s best to understand your data.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
