<?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: Correlation oddity</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Wed, 22 May 2013 12:40:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/#comment-43704</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Wed, 28 Dec 2011 20:10:07 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7897#comment-43704</guid>
		<description><![CDATA[About the last, I&#039;ve not created SR yet, but I&#039;ve asked the question. About the problem with restart - I know only internal bug number.]]></description>
		<content:encoded><![CDATA[<p>About the last, I&#8217;ve not created SR yet, but I&#8217;ve asked the question. About the problem with restart &#8211; I know only internal bug number.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/#comment-43702</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Wed, 28 Dec 2011 19:20:08 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7897#comment-43702</guid>
		<description><![CDATA[Valentin,

Thanks for all the follow-ups and links. It&#039;s fascinating how small variations in SQL can find different paths through the Oracle code for &quot;no apparent reason&quot;.  I particularly like the way you&#039;ve managed to strip the problem down to such a tiny example in the last post - have you tried sending it in as an SR to see what Oracle Corp. say about it ?]]></description>
		<content:encoded><![CDATA[<p>Valentin,</p>
<p>Thanks for all the follow-ups and links. It&#8217;s fascinating how small variations in SQL can find different paths through the Oracle code for &#8220;no apparent reason&#8221;.  I particularly like the way you&#8217;ve managed to strip the problem down to such a tiny example in the last post &#8211; have you tried sending it in as an SR to see what Oracle Corp. say about it ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/#comment-43603</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Sun, 25 Dec 2011 14:41:52 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7897#comment-43603</guid>
		<description><![CDATA[The simplest example is
[sourcecode]drop table t1 purge;

create table t1 as select &#039;X&#039; small_vc from dual connect by level &lt;= 2;

--alter session set events &#039;10221 trace name context forever, level 7&#039;; 

update  t1 set small_vc = (select max(&#039;1&#039;) from dual group by 1);
commit;
 
update  t1 set small_vc = (select max(&#039;1&#039;) from dual /*group by 1*/);
commit;[/sourcecode]
And we can find in the trace that for the first update &quot;array update&quot; is used, while for the second - LKR+URP.]]></description>
		<content:encoded><![CDATA[<p>The simplest example is</p>
<pre class="brush: plain; title: ; notranslate">drop table t1 purge;

create table t1 as select 'X' small_vc from dual connect by level &lt;= 2;

--alter session set events '10221 trace name context forever, level 7'; 

update  t1 set small_vc = (select max('1') from dual group by 1);
commit;
 
update  t1 set small_vc = (select max('1') from dual /*group by 1*/);
commit;</pre>
<p>And we can find in the trace that for the first update &#8220;array update&#8221; is used, while for the second &#8211; LKR+URP.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/#comment-43602</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Sun, 25 Dec 2011 14:24:37 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7897#comment-43602</guid>
		<description><![CDATA[If we add dummy &quot;group by 1&quot; into the subquery we will see &quot;SORT GROUP BY NOSORT&quot; in the plan and get array update as well:

[sourcecode]SQL&gt; update  t1
  2  set small_vc = (
  3          select
  4              max(small_vc)
  5          from
  6              t2
  7          where   t2.id = t1.id
  8          group by 1
  9      )
 10  where
 11      mod(id,100) = 0
 12  ;

100 rows updated.


Execution Plan
----------------------------------------------------------
Plan hash value: 3230996198

---------------------------------------------------------------------------------------
&#124; Id  &#124; Operation                     &#124; Name  &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
---------------------------------------------------------------------------------------
&#124;   0 &#124; UPDATE STATEMENT              &#124;       &#124;   100 &#124;  1500 &#124;   351  (29)&#124; 00:00:05 &#124;
&#124;   1 &#124;  UPDATE                       &#124; T1    &#124;       &#124;       &#124;            &#124;          &#124;
&#124;*  2 &#124;   TABLE ACCESS FULL           &#124; T1    &#124;   100 &#124;  1500 &#124;    51   (0)&#124; 00:00:01 &#124;
&#124;   3 &#124;   SORT GROUP BY NOSORT        &#124;       &#124;     1 &#124;    15 &#124;     2   (0)&#124; 00:00:01 &#124;
&#124;   4 &#124;    TABLE ACCESS BY INDEX ROWID&#124; T2    &#124;     1 &#124;    15 &#124;     2   (0)&#124; 00:00:01 &#124;
&#124;*  5 &#124;     INDEX RANGE SCAN          &#124; T2_I1 &#124;     1 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter(MOD(&quot;ID&quot;,100)=0)
   5 - access(&quot;T2&quot;.&quot;ID&quot;=:B1)

Statistics
----------------------------------------------------------
          0  recursive calls
        106  db block gets
        489  consistent gets
          0  physical reads
      34564  redo size
        682  bytes sent via SQL*Net to client
        746  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
        100  rows processed[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>If we add dummy &#8220;group by 1&#8243; into the subquery we will see &#8220;SORT GROUP BY NOSORT&#8221; in the plan and get array update as well:</p>
<pre class="brush: plain; title: ; notranslate">SQL&gt; update  t1
  2  set small_vc = (
  3          select
  4              max(small_vc)
  5          from
  6              t2
  7          where   t2.id = t1.id
  8          group by 1
  9      )
 10  where
 11      mod(id,100) = 0
 12  ;

100 rows updated.


Execution Plan
----------------------------------------------------------
Plan hash value: 3230996198

---------------------------------------------------------------------------------------
| Id  | Operation                     | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------
|   0 | UPDATE STATEMENT              |       |   100 |  1500 |   351  (29)| 00:00:05 |
|   1 |  UPDATE                       | T1    |       |       |            |          |
|*  2 |   TABLE ACCESS FULL           | T1    |   100 |  1500 |    51   (0)| 00:00:01 |
|   3 |   SORT GROUP BY NOSORT        |       |     1 |    15 |     2   (0)| 00:00:01 |
|   4 |    TABLE ACCESS BY INDEX ROWID| T2    |     1 |    15 |     2   (0)| 00:00:01 |
|*  5 |     INDEX RANGE SCAN          | T2_I1 |     1 |       |     1   (0)| 00:00:01 |
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter(MOD(&quot;ID&quot;,100)=0)
   5 - access(&quot;T2&quot;.&quot;ID&quot;=:B1)

Statistics
----------------------------------------------------------
          0  recursive calls
        106  db block gets
        489  consistent gets
          0  physical reads
      34564  redo size
        682  bytes sent via SQL*Net to client
        746  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
        100  rows processed</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/#comment-43593</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Sat, 24 Dec 2011 22:32:53 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7897#comment-43593</guid>
		<description><![CDATA[I have two post where discussed the problems of restart, caused by undo management and effect of this in 11g.

http://www.sql.ru/forum/actualthread.aspx?tid=833618

http://www.sql.ru/forum/actualthread.aspx?tid=843081

The certain mechanics of the restart isn&#039;t important (I try to get dynamic snapshots for v$rollstat and dba_undo_extents). It&#039;s only one important conclusion - the probability of restart tends to 1 with growth of undo.

Triggers in this context are only the method to disable &quot;array update&quot; with &quot;heavy&quot; restart for that.

And it is not the case of &quot;write consistency” restart. It&#039;s general code for restart that can be initialized by different way. 

I know two type of the restart - for all statement and row-level. Undo-restart had row-level signs (without significant additional redo generation) until &quot;array update&quot; appeared in 11g.]]></description>
		<content:encoded><![CDATA[<p>I have two post where discussed the problems of restart, caused by undo management and effect of this in 11g.</p>
<p><a href="http://www.sql.ru/forum/actualthread.aspx?tid=833618" rel="nofollow">http://www.sql.ru/forum/actualthread.aspx?tid=833618</a></p>
<p><a href="http://www.sql.ru/forum/actualthread.aspx?tid=843081" rel="nofollow">http://www.sql.ru/forum/actualthread.aspx?tid=843081</a></p>
<p>The certain mechanics of the restart isn&#8217;t important (I try to get dynamic snapshots for v$rollstat and dba_undo_extents). It&#8217;s only one important conclusion &#8211; the probability of restart tends to 1 with growth of undo.</p>
<p>Triggers in this context are only the method to disable &#8220;array update&#8221; with &#8220;heavy&#8221; restart for that.</p>
<p>And it is not the case of &#8220;write consistency” restart. It&#8217;s general code for restart that can be initialized by different way. </p>
<p>I know two type of the restart &#8211; for all statement and row-level. Undo-restart had row-level signs (without significant additional redo generation) until &#8220;array update&#8221; appeared in 11g.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/#comment-43537</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 23 Dec 2011 08:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7897#comment-43537</guid>
		<description><![CDATA[Valentin,

Thanks for the two observations - the one about the impact of triggers is one that I don&#039;t think I&#039;ve seen mentioned anywhere in the last 10 years or so, since Steve Adams first mentioned it. It&#039;s definitely time for someone to take a closer look at it and expand on his &lt;em&gt;&lt;strong&gt;&lt;a href=&quot;http://www.ixora.com.au/q+a/redo.htm&quot; rel=&quot;nofollow&quot;&gt;short note&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt; on Trigger Performance. 

The peculiarity of a long update (by tablescan, at least) resulting in a rollback and restart is one that appeared in 10.1, I think. It looks almost like an example of Tom Kyte&#039;s &lt;em&gt;&lt;strong&gt;&lt;a href=&quot;http://tkyte.blogspot.com/2005/08/something-different-part-i-of-iii.html&quot; rel=&quot;nofollow&quot;&gt;&quot;write consistency&quot;&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt; problem - but I&#039;ve never got around to looking at it closely. If you&#039;ve written anything more about it (even if it&#039;s in Russian), please feel free to supply a URL.
]]></description>
		<content:encoded><![CDATA[<p>Valentin,</p>
<p>Thanks for the two observations &#8211; the one about the impact of triggers is one that I don&#8217;t think I&#8217;ve seen mentioned anywhere in the last 10 years or so, since Steve Adams first mentioned it. It&#8217;s definitely time for someone to take a closer look at it and expand on his <em><strong><a href="http://www.ixora.com.au/q+a/redo.htm" rel="nofollow">short note</a></strong></em> on Trigger Performance. </p>
<p>The peculiarity of a long update (by tablescan, at least) resulting in a rollback and restart is one that appeared in 10.1, I think. It looks almost like an example of Tom Kyte&#8217;s <em><strong><a href="http://tkyte.blogspot.com/2005/08/something-different-part-i-of-iii.html" rel="nofollow">&#8220;write consistency&#8221;</a></strong></em> problem &#8211; but I&#8217;ve never got around to looking at it closely. If you&#8217;ve written anything more about it (even if it&#8217;s in Russian), please feel free to supply a URL.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #251, A Carnival of the Vanities for DBAs &#124; The Pythian Blog</title>
		<link>http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/#comment-43532</link>
		<dc:creator><![CDATA[Log Buffer #251, A Carnival of the Vanities for DBAs &#124; The Pythian Blog]]></dc:creator>
		<pubDate>Fri, 23 Dec 2011 06:01:26 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7897#comment-43532</guid>
		<description><![CDATA[[...] Jonathan Lewis is demonstrating a correlation oddity in a friendly way. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Jonathan Lewis is demonstrating a correlation oddity in a friendly way. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://jonathanlewis.wordpress.com/2011/12/19/correlation-oddity/#comment-43368</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Mon, 19 Dec 2011 20:55:29 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7897#comment-43368</guid>
		<description><![CDATA[Any trigger (statement or row level) will also cause the LKR + URP instead of Array update. But array update leads (in a large amount of undo) to restart with total rollback and LKR + URP/Array update (in different versions) in repeating.

Here is the test

[sourcecode]
drop table t purge;

create table t  as
select level id, lpad(level,40,&#039; &#039;) padding
from dual connect by level &lt;= 10000;

exec dbms_stats.gather_table_stats(user, &#039;t&#039;, estimate_percent =&gt; null, method_opt =&gt; &#039;for all columns size 1&#039;)

--alter session set events &#039;10221 trace name context forever, level 3&#039;;
--alter session set events &#039;10014 trace name context forever; name savepoints&#039;;

update /*+ dynamic_sampling(0) gather_plan_statistics */ t set padding = padding;
commit;

select * from table(dbms_xplan.display_cursor(null,null,&#039;ALLSTATS LAST&#039;));
[/sourcecode]

And this is result from 11.2.0.1:

[sourcecode]  
SQL_ID  8jud166qmnbxb, child number 0
-------------------------------------
update /*+ dynamic_sampling(0) gather_plan_statistics */ t set padding = padding
 
Plan hash value: 931696821
 
-------------------------------------------------------------------------------------
&#124; Id  &#124; Operation          &#124; Name &#124; Starts &#124; E-Rows &#124; A-Rows &#124;   A-Time   &#124; Buffers &#124;
-------------------------------------------------------------------------------------
&#124;   0 &#124; UPDATE STATEMENT   &#124;      &#124;      3 &#124;        &#124;      0 &#124;00:00:01.70 &#124;   10618 &#124;
&#124;   1 &#124;  UPDATE            &#124; T    &#124;      3 &#124;        &#124;      0 &#124;00:00:01.70 &#124;   10618 &#124;
&#124;   2 &#124;   TABLE ACCESS FULL&#124; T    &#124;      3 &#124;  10000 &#124;  22427 &#124;00:00:00.02 &#124;     166 &#124;
-------------------------------------------------------------------------------------
[/sourcecode]

So here 22427 = 21(???) + 2406(Array update before restart (from trace)) + 10000(LCR after rollback) + 10000(Array update after locking).]]></description>
		<content:encoded><![CDATA[<p>Any trigger (statement or row level) will also cause the LKR + URP instead of Array update. But array update leads (in a large amount of undo) to restart with total rollback and LKR + URP/Array update (in different versions) in repeating.</p>
<p>Here is the test</p>
<pre class="brush: plain; title: ; notranslate">
drop table t purge;

create table t  as
select level id, lpad(level,40,' ') padding
from dual connect by level &lt;= 10000;

exec dbms_stats.gather_table_stats(user, 't', estimate_percent =&gt; null, method_opt =&gt; 'for all columns size 1')

--alter session set events '10221 trace name context forever, level 3';
--alter session set events '10014 trace name context forever; name savepoints';

update /*+ dynamic_sampling(0) gather_plan_statistics */ t set padding = padding;
commit;

select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
</pre>
<p>And this is result from 11.2.0.1:</p>
<pre class="brush: plain; title: ; notranslate">  
SQL_ID  8jud166qmnbxb, child number 0
-------------------------------------
update /*+ dynamic_sampling(0) gather_plan_statistics */ t set padding = padding
 
Plan hash value: 931696821
 
-------------------------------------------------------------------------------------
| Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
-------------------------------------------------------------------------------------
|   0 | UPDATE STATEMENT   |      |      3 |        |      0 |00:00:01.70 |   10618 |
|   1 |  UPDATE            | T    |      3 |        |      0 |00:00:01.70 |   10618 |
|   2 |   TABLE ACCESS FULL| T    |      3 |  10000 |  22427 |00:00:00.02 |     166 |
-------------------------------------------------------------------------------------
</pre>
<p>So here 22427 = 21(???) + 2406(Array update before restart (from trace)) + 10000(LCR after rollback) + 10000(Array update after locking).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
