<?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: Process the whole world, or just one item</title>
	<atom:link href="http://www.neilkodner.com/2009/11/process-the-whole-world-or-just-one-item/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.neilkodner.com/2009/11/process-the-whole-world-or-just-one-item/</link>
	<description>Data Driven.  Since 1971.</description>
	<lastBuildDate>Tue, 17 Jan 2012 21:37:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: admin</title>
		<link>http://www.neilkodner.com/2009/11/process-the-whole-world-or-just-one-item/comment-page-1/#comment-6</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 06 Nov 2009 14:37:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilkodner.com/?p=37#comment-6</guid>
		<description>@chet this is interesting - i tried the method you suggested and wound up with more LIO and PIO.  I didn&#039;t expect that-I did a double take and then an ALTER SYSTEM FLUSH SHARED_POOL and ran it again.  Same result.  Here are results for where a value is supplied for in_party_id:

SELECT PRTY_ID , DBA_NAME , CREATED_DT
FROM
 PARTIES A WHERE PRTY_ID = NVL(:B1 ,PRTY_ID)


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.01       0.04          0          0          0           0
Fetch        1      0.01       0.00          0          4          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        3      0.02       0.04          0          4          0           1

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 49     (recursive depth: 1)

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  CONCATENATION  (cr=4 pr=0 pw=0 time=84 us)
      0   FILTER  (cr=0 pr=0 pw=0 time=6 us)
      0    TABLE ACCESS FULL PARTIES (cr=0 pr=0 pw=0 time=0 us)
      1   FILTER  (cr=4 pr=0 pw=0 time=70 us)
      1    TABLE ACCESS BY INDEX ROWID PARTIES (cr=4 pr=0 pw=0 time=68 us)
      1     INDEX UNIQUE SCAN PARTIES_PK (cr=3 pr=0 pw=0 time=39 us)(object id 125098)

********************************************************************************

SELECT PRTY_ID , DBA_NAME , CREATED_DT
FROM
 PARTIES A WHERE (PRTY_ID = :B1 OR :B1 IS NULL)


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        1      1.23       1.22      12582      12596          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        3      1.23       1.23      12582      12596          0           1

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 49     (recursive depth: 1)

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  TABLE ACCESS FULL PARTIES (cr=12596 pr=12582 pw=0 time=1227765 us)</description>
		<content:encoded><![CDATA[<p>@chet this is interesting &#8211; i tried the method you suggested and wound up with more LIO and PIO.  I didn&#8217;t expect that-I did a double take and then an ALTER SYSTEM FLUSH SHARED_POOL and ran it again.  Same result.  Here are results for where a value is supplied for in_party_id:</p>
<p>SELECT PRTY_ID , DBA_NAME , CREATED_DT<br />
FROM<br />
 PARTIES A WHERE PRTY_ID = NVL(:B1 ,PRTY_ID)</p>
<p>call     count       cpu    elapsed       disk      query    current        rows<br />
&#8212;&#8212;- &#8212;&#8212;  &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-  &#8212;&#8212;&#8212;-<br />
Parse        1      0.00       0.00          0          0          0           0<br />
Execute      1      0.01       0.04          0          0          0           0<br />
Fetch        1      0.01       0.00          0          4          0           1<br />
&#8212;&#8212;- &#8212;&#8212;  &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-  &#8212;&#8212;&#8212;-<br />
total        3      0.02       0.04          0          4          0           1</p>
<p>Misses in library cache during parse: 1<br />
Misses in library cache during execute: 1<br />
Optimizer mode: ALL_ROWS<br />
Parsing user id: 49     (recursive depth: 1)</p>
<p>Rows     Row Source Operation<br />
&#8212;&#8212;-  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
      1  CONCATENATION  (cr=4 pr=0 pw=0 time=84 us)<br />
      0   FILTER  (cr=0 pr=0 pw=0 time=6 us)<br />
      0    TABLE ACCESS FULL PARTIES (cr=0 pr=0 pw=0 time=0 us)<br />
      1   FILTER  (cr=4 pr=0 pw=0 time=70 us)<br />
      1    TABLE ACCESS BY INDEX ROWID PARTIES (cr=4 pr=0 pw=0 time=68 us)<br />
      1     INDEX UNIQUE SCAN PARTIES_PK (cr=3 pr=0 pw=0 time=39 us)(object id 125098)</p>
<p>********************************************************************************</p>
<p>SELECT PRTY_ID , DBA_NAME , CREATED_DT<br />
FROM<br />
 PARTIES A WHERE (PRTY_ID = :B1 OR :B1 IS NULL)</p>
<p>call     count       cpu    elapsed       disk      query    current        rows<br />
&#8212;&#8212;- &#8212;&#8212;  &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-  &#8212;&#8212;&#8212;-<br />
Parse        1      0.00       0.00          0          0          0           0<br />
Execute      1      0.00       0.00          0          0          0           0<br />
Fetch        1      1.23       1.22      12582      12596          0           1<br />
&#8212;&#8212;- &#8212;&#8212;  &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-  &#8212;&#8212;&#8212;-<br />
total        3      1.23       1.23      12582      12596          0           1</p>
<p>Misses in library cache during parse: 1<br />
Misses in library cache during execute: 1<br />
Optimizer mode: ALL_ROWS<br />
Parsing user id: 49     (recursive depth: 1)</p>
<p>Rows     Row Source Operation<br />
&#8212;&#8212;-  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
      1  TABLE ACCESS FULL PARTIES (cr=12596 pr=12582 pw=0 time=1227765 us)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.neilkodner.com/2009/11/process-the-whole-world-or-just-one-item/comment-page-1/#comment-5</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 06 Nov 2009 14:22:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilkodner.com/?p=37#comment-5</guid>
		<description>@Bob_Watkins thoughtful question.  I built an unscientific test case and it looks like the answer to your question is a no.  I created two procedures, one that selects all rows, the other using the NVL() technique outlined above.  This is an unscientific test against a non-idle system so I take the disk and elapsed numbers with a huge grain of salt.  Interesting that LIO was the same across both queries.

[sql]
SELECT PRTY_ID , DBA_NAME , CREATED_DT
FROM
 PARTIES A WHERE PRTY_ID = NVL(:B1 ,PRTY_ID)


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch     9711      5.70       6.53      12396      22172          0      971084
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total     9713      5.70       6.53      12396      22172          0      971084

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 49     (recursive depth: 1)

Rows     Row Source Operation
-------  ---------------------------------------------------
 971084  CONCATENATION  (cr=22172 pr=12396 pw=0 time=3899891 us)
 971084   FILTER  (cr=22172 pr=12396 pw=0 time=3899589 us)
 971084    TABLE ACCESS FULL PARTIES (cr=22172 pr=12396 pw=0 time=2928149 us)
      0   FILTER  (cr=0 pr=0 pw=0 time=5 us)
      0    TABLE ACCESS BY INDEX ROWID PARTIES (cr=0 pr=0 pw=0 time=0 us)
      0     INDEX UNIQUE SCAN PARTIES_PK (cr=0 pr=0 pw=0 time=0 us)(object id 125098)


Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  db file scattered read                        879        0.08          0.70
  db file sequential read                        16        0.00          0.00
********************************************************************************

SELECT PRTY_ID , DBA_NAME , CREATED_DT
FROM
 PARTIES A


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch     9711      4.69       4.81      12366      22171          0      971084
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total     9713      4.69       4.81      12366      22171          0      971084

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 49     (recursive depth: 1)

Rows     Row Source Operation
-------  ---------------------------------------------------
 971084  TABLE ACCESS FULL PARTIES (cr=22171 pr=12366 pw=0 time=2914439 us)


Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  db file scattered read                        885        0.00          0.17
  db file sequential read                        15        0.00          0.00
********************************************************************************
[/sql]</description>
		<content:encoded><![CDATA[<p>@Bob_Watkins thoughtful question.  I built an unscientific test case and it looks like the answer to your question is a no.  I created two procedures, one that selects all rows, the other using the NVL() technique outlined above.  This is an unscientific test against a non-idle system so I take the disk and elapsed numbers with a huge grain of salt.  Interesting that LIO was the same across both queries.</p>
<pre class="brush: sql; title: ; notranslate">
SELECT PRTY_ID , DBA_NAME , CREATED_DT
FROM
 PARTIES A WHERE PRTY_ID = NVL(:B1 ,PRTY_ID)

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch     9711      5.70       6.53      12396      22172          0      971084
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total     9713      5.70       6.53      12396      22172          0      971084

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 49     (recursive depth: 1)

Rows     Row Source Operation
-------  ---------------------------------------------------
 971084  CONCATENATION  (cr=22172 pr=12396 pw=0 time=3899891 us)
 971084   FILTER  (cr=22172 pr=12396 pw=0 time=3899589 us)
 971084    TABLE ACCESS FULL PARTIES (cr=22172 pr=12396 pw=0 time=2928149 us)
      0   FILTER  (cr=0 pr=0 pw=0 time=5 us)
      0    TABLE ACCESS BY INDEX ROWID PARTIES (cr=0 pr=0 pw=0 time=0 us)
      0     INDEX UNIQUE SCAN PARTIES_PK (cr=0 pr=0 pw=0 time=0 us)(object id 125098)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  db file scattered read                        879        0.08          0.70
  db file sequential read                        16        0.00          0.00
********************************************************************************

SELECT PRTY_ID , DBA_NAME , CREATED_DT
FROM
 PARTIES A

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch     9711      4.69       4.81      12366      22171          0      971084
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total     9713      4.69       4.81      12366      22171          0      971084

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 49     (recursive depth: 1)

Rows     Row Source Operation
-------  ---------------------------------------------------
 971084  TABLE ACCESS FULL PARTIES (cr=22171 pr=12366 pw=0 time=2914439 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  db file scattered read                        885        0.00          0.17
  db file sequential read                        15        0.00          0.00
********************************************************************************
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob Watkins</title>
		<link>http://www.neilkodner.com/2009/11/process-the-whole-world-or-just-one-item/comment-page-1/#comment-4</link>
		<dc:creator>Bob Watkins</dc:creator>
		<pubDate>Fri, 06 Nov 2009 12:46:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilkodner.com/?p=37#comment-4</guid>
		<description>I wonder if the optimizer is smart enough to see the WHERE clause as including all rows, and eliminate it? Have you looked at the execution plan that results from this approach (versus using an IF statement to test for null, then submitting two different SELECTS)?</description>
		<content:encoded><![CDATA[<p>I wonder if the optimizer is smart enough to see the WHERE clause as including all rows, and eliminate it? Have you looked at the execution plan that results from this approach (versus using an IF statement to test for null, then submitting two different SELECTS)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jd long</title>
		<link>http://www.neilkodner.com/2009/11/process-the-whole-world-or-just-one-item/comment-page-1/#comment-3</link>
		<dc:creator>jd long</dc:creator>
		<pubDate>Fri, 06 Nov 2009 02:53:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilkodner.com/?p=37#comment-3</guid>
		<description>I&#039;m glad you are blogging about your tips and tricks. These are great ideas and help me improve my own code. Keep it up!</description>
		<content:encoded><![CDATA[<p>I&#8217;m glad you are blogging about your tips and tricks. These are great ideas and help me improve my own code. Keep it up!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chet</title>
		<link>http://www.neilkodner.com/2009/11/process-the-whole-world-or-just-one-item/comment-page-1/#comment-2</link>
		<dc:creator>chet</dc:creator>
		<pubDate>Thu, 05 Nov 2009 22:55:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilkodner.com/?p=37#comment-2</guid>
		<description>having looked at nothing but NVLs lately, even when not used in any way, shape or form, I prefer explicitly stating it like this:

WHERE ( emp.employer_id = in_employer_id
    OR in_employer_id IS NULL )</description>
		<content:encoded><![CDATA[<p>having looked at nothing but NVLs lately, even when not used in any way, shape or form, I prefer explicitly stating it like this:</p>
<p>WHERE ( emp.employer_id = in_employer_id<br />
    OR in_employer_id IS NULL )</p>
]]></content:encoded>
	</item>
</channel>
</rss>

