<?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: Explaining the number of Consistent Gets</title>
	<atom:link href="http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/feed/" rel="self" type="application/rss+xml" />
	<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/</link>
	<description>By: Harald van Breederode</description>
	<lastBuildDate>Wed, 19 Jun 2013 15:32:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Blogroll Report 30/10/2009-06/11/2009 &#171; Coskan&#8217;s Approach to Oracle</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-227</link>
		<dc:creator><![CDATA[Blogroll Report 30/10/2009-06/11/2009 &#171; Coskan&#8217;s Approach to Oracle]]></dc:creator>
		<pubDate>Tue, 10 Nov 2009 18:17:20 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-227</guid>
		<description><![CDATA[[...] Harald van Breederode-Explaining the number of Consistent Gets [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Harald van Breederode-Explaining the number of Consistent Gets [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald van Breederode</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-226</link>
		<dc:creator><![CDATA[Harald van Breederode]]></dc:creator>
		<pubDate>Tue, 10 Nov 2009 16:09:20 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-226</guid>
		<description><![CDATA[Hi Narendra,

I don&#039;t know what is causing this when you try it. You are correct that dbms_xplan reports the actual number of consistent gets in the buffers column. The only explanation I have is that somehow your arraysize gets reset back to 15.

If you omit the call to dbms_stats there will be no statistics and Oracle10g/11g will use dynamic sampling during the parse call. However the effects of dynamic sampling are not reported by dbms_xplan.
-Harald]]></description>
		<content:encoded><![CDATA[<p>Hi Narendra,</p>
<p>I don&#8217;t know what is causing this when you try it. You are correct that dbms_xplan reports the actual number of consistent gets in the buffers column. The only explanation I have is that somehow your arraysize gets reset back to 15.</p>
<p>If you omit the call to dbms_stats there will be no statistics and Oracle10g/11g will use dynamic sampling during the parse call. However the effects of dynamic sampling are not reported by dbms_xplan.<br />
-Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald van Breederode</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-225</link>
		<dc:creator><![CDATA[Harald van Breederode]]></dc:creator>
		<pubDate>Tue, 10 Nov 2009 15:57:29 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-225</guid>
		<description><![CDATA[Narendra,

No it has nothing to do with an anonymous transaction, I just used a regular transaction and rolled it back. While inserting the rows, the high-water mark gets pushed up. Upon transaction rollback the rows are deleted but the HWM remains at its new position.
-Harald]]></description>
		<content:encoded><![CDATA[<p>Narendra,</p>
<p>No it has nothing to do with an anonymous transaction, I just used a regular transaction and rolled it back. While inserting the rows, the high-water mark gets pushed up. Upon transaction rollback the rows are deleted but the HWM remains at its new position.<br />
-Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Narendra</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-224</link>
		<dc:creator><![CDATA[Narendra]]></dc:creator>
		<pubDate>Tue, 10 Nov 2009 10:55:39 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-224</guid>
		<description><![CDATA[Harald,

Not sure why but here is what I noticed.
While running the example, I was frequently doing the following to reset the HWM (so that I can start from the scratch; number of buffers as 4)
&lt;code&gt;
ALTER TABLE foo MOVE;
EXEC dbms_stats.gather_table_stats(user, &#039;FOO&#039;);
&lt;/code&gt;

What I could not understand is why is the stats collection needed after the ALTER TABLE..MOVE? Without stats collection, the number of buffers reported (by DBMS_XPLAN.DISPLAY_CURSOR) were 8 and never went back to 4. My understanding is the outcome of DBMS_XPLAN.DISPLAY_CURSOR reports facts and not the guesses (based on statistics). In that case, how did the stats collection affect the actual work done?]]></description>
		<content:encoded><![CDATA[<p>Harald,</p>
<p>Not sure why but here is what I noticed.<br />
While running the example, I was frequently doing the following to reset the HWM (so that I can start from the scratch; number of buffers as 4)<br />
<code><br />
ALTER TABLE foo MOVE;<br />
EXEC dbms_stats.gather_table_stats(user, 'FOO');<br />
</code></p>
<p>What I could not understand is why is the stats collection needed after the ALTER TABLE..MOVE? Without stats collection, the number of buffers reported (by DBMS_XPLAN.DISPLAY_CURSOR) were 8 and never went back to 4. My understanding is the outcome of DBMS_XPLAN.DISPLAY_CURSOR reports facts and not the guesses (based on statistics). In that case, how did the stats collection affect the actual work done?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Narendra</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-223</link>
		<dc:creator><![CDATA[Narendra]]></dc:creator>
		<pubDate>Tue, 10 Nov 2009 09:50:46 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-223</guid>
		<description><![CDATA[Harald,

Yes. I am using ASSM tablespace. Now as for your quote
&lt;i&gt;I didn’t insert and rolled back the new rows in another session though. I simply did it in the same session.&lt;/i&gt;, then the obvious
way to do it from single session is doing the INSERTs (followed by ROLLBACK) from an autonomous transaction (in same session). Am I correct?]]></description>
		<content:encoded><![CDATA[<p>Harald,</p>
<p>Yes. I am using ASSM tablespace. Now as for your quote<br />
<i>I didn’t insert and rolled back the new rows in another session though. I simply did it in the same session.</i>, then the obvious<br />
way to do it from single session is doing the INSERTs (followed by ROLLBACK) from an autonomous transaction (in same session). Am I correct?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald van Breederode</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-221</link>
		<dc:creator><![CDATA[Harald van Breederode]]></dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:47:29 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-221</guid>
		<description><![CDATA[Hi Narendra,

You are correct that the increased number of consistent gets  is caused by a bumped high-water mark. I didn&#039;t insert and rolled back the new rows in another session though. I simply did it in the same session. The exact number of rows that are needed to get the extra 20 consistent gets depends on the physical table structure: block size, pctfree and column data type (and a few other attributes). In my case I increased the number of rows from 64 to 10000.
-Harald]]></description>
		<content:encoded><![CDATA[<p>Hi Narendra,</p>
<p>You are correct that the increased number of consistent gets  is caused by a bumped high-water mark. I didn&#8217;t insert and rolled back the new rows in another session though. I simply did it in the same session. The exact number of rows that are needed to get the extra 20 consistent gets depends on the physical table structure: block size, pctfree and column data type (and a few other attributes). In my case I increased the number of rows from 64 to 10000.<br />
-Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald van Breederode</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-220</link>
		<dc:creator><![CDATA[Harald van Breederode]]></dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:34:25 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-220</guid>
		<description><![CDATA[Hi Narendra,

Thanx for catching the typo (5 instead of 4). I&#039;ve updated the original post which now read correct.

The reason why you get 4 blocks instead of 1 could be caused by the tablespace space management type. My table resides in a freelist managed tablespace and yours is probably stored in an ASSM tablespace. I did this on purpose to get consistent behaviour. Things become somewhat complex when rows get stored in an.ASSM managed table and I didn&#039;t want it to get in the way for this discussion. Is your table indeed in an ASSM tablespace?
Just as Mark you are close to what I did to the table, but I didn&#039;t use a second session to make it happen.
-Harald]]></description>
		<content:encoded><![CDATA[<p>Hi Narendra,</p>
<p>Thanx for catching the typo (5 instead of 4). I&#8217;ve updated the original post which now read correct.</p>
<p>The reason why you get 4 blocks instead of 1 could be caused by the tablespace space management type. My table resides in a freelist managed tablespace and yours is probably stored in an ASSM tablespace. I did this on purpose to get consistent behaviour. Things become somewhat complex when rows get stored in an.ASSM managed table and I didn&#8217;t want it to get in the way for this discussion. Is your table indeed in an ASSM tablespace?<br />
Just as Mark you are close to what I did to the table, but I didn&#8217;t use a second session to make it happen.<br />
-Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald van Breederode</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-219</link>
		<dc:creator><![CDATA[Harald van Breederode]]></dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:06:21 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-219</guid>
		<description><![CDATA[Mark,

No, I did not insert a bunch of rows in another session and rolled them back, but you are getting real close now! ;-)
-Harald]]></description>
		<content:encoded><![CDATA[<p>Mark,</p>
<p>No, I did not insert a bunch of rows in another session and rolled them back, but you are getting real close now! ;-)<br />
-Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-218</link>
		<dc:creator><![CDATA[Vincent]]></dc:creator>
		<pubDate>Mon, 09 Nov 2009 12:57:09 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-218</guid>
		<description><![CDATA[Thanks a lot for the answers, they are perfectly clear.

Vincent]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot for the answers, they are perfectly clear.</p>
<p>Vincent</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Narendra</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-217</link>
		<dc:creator><![CDATA[Narendra]]></dc:creator>
		<pubDate>Mon, 09 Nov 2009 12:04:25 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-217</guid>
		<description><![CDATA[Just to add some details to my earlier response.
Oracle atabase version: 10.2.0.4 64-bit on Solaris.
Also, I had added 2010 rows (from another session) in 3 batches of 1000, 1000 and 10.
When I tried to add all 2010 rows in a single batch, the consistent gets were not 24. So it appears to be some internal (??) mechanism used by Oracle that decides when to advance the High Water Mark.
BTW, the increase in consistent gets is due to Oracle advancing High Water Mark of the table as a result of adding new rows (INSERT from another session). I could not get a reproducible number of rows that would result in exact figure of 24. I guess it depends upon how you insert, row size etc.]]></description>
		<content:encoded><![CDATA[<p>Just to add some details to my earlier response.<br />
Oracle atabase version: 10.2.0.4 64-bit on Solaris.<br />
Also, I had added 2010 rows (from another session) in 3 batches of 1000, 1000 and 10.<br />
When I tried to add all 2010 rows in a single batch, the consistent gets were not 24. So it appears to be some internal (??) mechanism used by Oracle that decides when to advance the High Water Mark.<br />
BTW, the increase in consistent gets is due to Oracle advancing High Water Mark of the table as a result of adding new rows (INSERT from another session). I could not get a reproducible number of rows that would result in exact figure of 24. I guess it depends upon how you insert, row size etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Narendra</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-216</link>
		<dc:creator><![CDATA[Narendra]]></dc:creator>
		<pubDate>Mon, 09 Nov 2009 11:30:13 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-216</guid>
		<description><![CDATA[Harald,

Nice post.
When I tried running your scripts, the DBA_TABLES always reported BLOCKS as 4 whereas COUNT(DISTINCT dbms_rowid.rowid_block_number(rowid)) reported 1. Not sure what is the reason for difference. However, the DBMS_XPLAN.DISPLAY_CURSOR reported buffers as 4, with arraysize 70.
Now, bit confused with your question, &lt;i&gt;why there are 24 consistent gets instead of just 5&lt;/i&gt;. shouldn&#039;t it be &lt;i&gt;why there are 24 consistent gets instead of just &lt;b&gt;4&lt;/b&gt;&lt;/i&gt; since you have set the arraysize to 70.
Now, I was able to get the figure of 24 when I added 2010 rows into foo table from another session but did not commit. After this when I executed the &lt;code&gt;SELECT * from foo&lt;/code&gt; in the first session, the subsequent DBMS_XPLAN.DISPLAY_CURSOR reported 24 buffers, instead of 4. Could that be the case?
p.s. As you mentioned in a reply, I did not &quot;touch&quot; existing 64 rows at all. :)]]></description>
		<content:encoded><![CDATA[<p>Harald,</p>
<p>Nice post.<br />
When I tried running your scripts, the DBA_TABLES always reported BLOCKS as 4 whereas COUNT(DISTINCT dbms_rowid.rowid_block_number(rowid)) reported 1. Not sure what is the reason for difference. However, the DBMS_XPLAN.DISPLAY_CURSOR reported buffers as 4, with arraysize 70.<br />
Now, bit confused with your question, <i>why there are 24 consistent gets instead of just 5</i>. shouldn&#8217;t it be <i>why there are 24 consistent gets instead of just <b>4</b></i> since you have set the arraysize to 70.<br />
Now, I was able to get the figure of 24 when I added 2010 rows into foo table from another session but did not commit. After this when I executed the <code>SELECT * from foo</code> in the first session, the subsequent DBMS_XPLAN.DISPLAY_CURSOR reported 24 buffers, instead of 4. Could that be the case?<br />
p.s. As you mentioned in a reply, I did not &#8220;touch&#8221; existing 64 rows at all. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Gorbachev</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-215</link>
		<dc:creator><![CDATA[Alex Gorbachev]]></dc:creator>
		<pubDate>Mon, 09 Nov 2009 00:35:44 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-215</guid>
		<description><![CDATA[Mark, I think it should qualify as full blown guess. ;-)]]></description>
		<content:encoded><![CDATA[<p>Mark, I think it should qualify as full blown guess. ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark W. Farnham</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-214</link>
		<dc:creator><![CDATA[Mark W. Farnham]]></dc:creator>
		<pubDate>Sun, 08 Nov 2009 21:48:47 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-214</guid>
		<description><![CDATA[Okay, I&#039;ll hope the czar of the society against guessing isn&#039;t watching and I&#039;ll try one more:

Did you insert some more rows in a different session and it had to read the blocks to determine your session wasn&#039;t supposed to see the contents?

I&#039;m also not sure without testing what happens if you insert rows in your own session and then roll them back. Sigh. Isn&#039;t it a real achievement that Oracle CONSISTENTLY gets the right answer?]]></description>
		<content:encoded><![CDATA[<p>Okay, I&#8217;ll hope the czar of the society against guessing isn&#8217;t watching and I&#8217;ll try one more:</p>
<p>Did you insert some more rows in a different session and it had to read the blocks to determine your session wasn&#8217;t supposed to see the contents?</p>
<p>I&#8217;m also not sure without testing what happens if you insert rows in your own session and then roll them back. Sigh. Isn&#8217;t it a real achievement that Oracle CONSISTENTLY gets the right answer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald van Breederode</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-213</link>
		<dc:creator><![CDATA[Harald van Breederode]]></dc:creator>
		<pubDate>Sun, 08 Nov 2009 19:51:38 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-213</guid>
		<description><![CDATA[Hi Mark,

Both are possible techniques to force the number of consistent gets to go up, but both are not what I did. I didn&#039;t touch the existing 64 rows at all.
-Harald]]></description>
		<content:encoded><![CDATA[<p>Hi Mark,</p>
<p>Both are possible techniques to force the number of consistent gets to go up, but both are not what I did. I didn&#8217;t touch the existing 64 rows at all.<br />
-Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald van Breederode</title>
		<link>http://prutser.wordpress.com/2009/11/06/explaining-the-number-of-consistent-gets/#comment-212</link>
		<dc:creator><![CDATA[Harald van Breederode]]></dc:creator>
		<pubDate>Sun, 08 Nov 2009 19:39:24 +0000</pubDate>
		<guid isPermaLink="false">http://prutser.wordpress.com/?p=435#comment-212</guid>
		<description><![CDATA[Hi Vincent,

Thanx for your feedback. I&#039;ll try to answer your questions:

The 69th consistent get is to undo the changes made to the data block header. In this header data structures resides which are known as ITL&#039;s and their function is to link the changed rows to the undo segment holding the previous values. All rows inside one data block that are changed by the same transaction share one ITL. Because all 64 rows are stored in one data block there is one ITL in use causing one extra consistent get. If the updated rows were stored in two data blocks there would be two ITL&#039;s involved causing two extra consistent gets. Or if the 64 rows were updated by two transactions there would also be two ITL&#039;s involved also resulting in two extra consistent gets.

The missing 4th consistent get in the aggregate trap is caused by the way SQL*Plus fetches data. Strangely enough SQL*Plus always seems to start with a fetch for one row followed by fetches of arraysize number of rows until there is nothing more to fetch. So in the case where SQL*Plus fetches 64 rows using an arraysize of 70 it results in two consistent gets. In the case where the sum function fetches the rows from the full table scan, SQL*Plus start by fetching one row from the sum function and it gets notified that there is nothing more to fetch resulting in one consistent get less.

A consistent get is basicly accessing a data block that is first made read consistent. Consistent gets have a n-to-n relationship with a fetch operation.
-Harald]]></description>
		<content:encoded><![CDATA[<p>Hi Vincent,</p>
<p>Thanx for your feedback. I&#8217;ll try to answer your questions:</p>
<p>The 69th consistent get is to undo the changes made to the data block header. In this header data structures resides which are known as ITL&#8217;s and their function is to link the changed rows to the undo segment holding the previous values. All rows inside one data block that are changed by the same transaction share one ITL. Because all 64 rows are stored in one data block there is one ITL in use causing one extra consistent get. If the updated rows were stored in two data blocks there would be two ITL&#8217;s involved causing two extra consistent gets. Or if the 64 rows were updated by two transactions there would also be two ITL&#8217;s involved also resulting in two extra consistent gets.</p>
<p>The missing 4th consistent get in the aggregate trap is caused by the way SQL*Plus fetches data. Strangely enough SQL*Plus always seems to start with a fetch for one row followed by fetches of arraysize number of rows until there is nothing more to fetch. So in the case where SQL*Plus fetches 64 rows using an arraysize of 70 it results in two consistent gets. In the case where the sum function fetches the rows from the full table scan, SQL*Plus start by fetching one row from the sum function and it gets notified that there is nothing more to fetch resulting in one consistent get less.</p>
<p>A consistent get is basicly accessing a data block that is first made read consistent. Consistent gets have a n-to-n relationship with a fetch operation.<br />
-Harald</p>
]]></content:encoded>
	</item>
</channel>
</rss>
