<?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: Buffer Pinning</title>
	<atom:link href="http://dioncho.wordpress.com/2009/04/08/buffer-pinning/feed/" rel="self" type="application/rss+xml" />
	<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/</link>
	<description>We are natural born scientists</description>
	<lastBuildDate>Fri, 17 Dec 2010 18:43:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Roberto</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-214</link>
		<dc:creator><![CDATA[Roberto]]></dc:creator>
		<pubDate>Thu, 07 May 2009 09:11:52 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-214</guid>
		<description><![CDATA[Thanks Dion, I missed that &quot;buffer is pinned count&quot; is incremented only after the SECOND visit, and then, in worst clustering case, for each key in the index block, I (ideally) pin the table blocks only one time and thus &quot;buffer is pinned count&quot; is not incremented. Nigel tried to explain me, but I was deaf. The crude numbers opened my eyes! (and my ears)]]></description>
		<content:encoded><![CDATA[<p>Thanks Dion, I missed that &#8220;buffer is pinned count&#8221; is incremented only after the SECOND visit, and then, in worst clustering case, for each key in the index block, I (ideally) pin the table blocks only one time and thus &#8220;buffer is pinned count&#8221; is not incremented. Nigel tried to explain me, but I was deaf. The crude numbers opened my eyes! (and my ears)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dion Cho</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-208</link>
		<dc:creator><![CDATA[Dion Cho]]></dc:creator>
		<pubDate>Tue, 05 May 2009 13:12:20 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-208</guid>
		<description><![CDATA[@Tanel

I was about to add comment on my comments about latch acquisition. As test case cleary shows, the latch acquisition count is almost 2 times of logical reads. This means that Oracle does not release and reacquire the CBCL, but upgrades it. Your explanation clearly proves my assumption. 

Really thanks for the awesome explanation!]]></description>
		<content:encoded><![CDATA[<p>@Tanel</p>
<p>I was about to add comment on my comments about latch acquisition. As test case cleary shows, the latch acquisition count is almost 2 times of logical reads. This means that Oracle does not release and reacquire the CBCL, but upgrades it. Your explanation clearly proves my assumption. </p>
<p>Really thanks for the awesome explanation!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanel Poder</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-207</link>
		<dc:creator><![CDATA[Tanel Poder]]></dc:creator>
		<pubDate>Tue, 05 May 2009 13:01:23 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-207</guid>
		<description><![CDATA[...shows how many times we tried to access a buffer but discovered that such buffer already had an open handle cached pointing to it (thus the buffer was also pinned)]]></description>
		<content:encoded><![CDATA[<p>&#8230;shows how many times we tried to access a buffer but discovered that such buffer already had an open handle cached pointing to it (thus the buffer was also pinned)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanel Poder</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-206</link>
		<dc:creator><![CDATA[Tanel Poder]]></dc:creator>
		<pubDate>Tue, 05 May 2009 13:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-206</guid>
		<description><![CDATA[Hi,

A little correction. In step 3 above (in your reply to LSCheng) the CBC latch is not released and retaken in exclusive mode, but upgraded to exclusive mode from shared. This is what the &quot;shared hash latch upgrades&quot; statistics show in v$sesstat.

Also, pinning a buffer additionally means estabilishing pointers between session&#039;s db buffer handles and pinned buffer headers. Oracle caches the db buffer handles in SGA (separate handles for each process) and doesn&#039;t close these (nor unpins buffers) immediately after block visit. So, Oracle caches db handles for a call and closes them when a call finishes or the number of already cached handles exceeds a threshold (controlled by _db_handles_cached parameter, 5 by default)

So, the &quot;buffer is already pinned count&quot; statistic]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>A little correction. In step 3 above (in your reply to LSCheng) the CBC latch is not released and retaken in exclusive mode, but upgraded to exclusive mode from shared. This is what the &#8220;shared hash latch upgrades&#8221; statistics show in v$sesstat.</p>
<p>Also, pinning a buffer additionally means estabilishing pointers between session&#8217;s db buffer handles and pinned buffer headers. Oracle caches the db buffer handles in SGA (separate handles for each process) and doesn&#8217;t close these (nor unpins buffers) immediately after block visit. So, Oracle caches db handles for a call and closes them when a call finishes or the number of already cached handles exceeds a threshold (controlled by _db_handles_cached parameter, 5 by default)</p>
<p>So, the &#8220;buffer is already pinned count&#8221; statistic</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dion Cho</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-202</link>
		<dc:creator><![CDATA[Dion Cho]]></dc:creator>
		<pubDate>Mon, 04 May 2009 13:04:02 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-202</guid>
		<description><![CDATA[@Roberto.

It&#039;s all about simple mathematics. In the above example, the size of both indexes is as following.

&lt;pre&gt;
TABLE_NAME                    : T1                    
INDEX_NAME                    : T1_N1                 
BLEVEL                        : 1                     
LEAF_BLOCKS                   : 21                    
DISTINCT_KEYS                 : 10000                 
CLUSTERING_FACTOR             : 164                   
SAMPLE_SIZE                   : 10000                 
GLOBAL_STATS                  : YES                   
LAST_ANAL                     : 2009/05/04 20:52:22   
-----------------                                     
TABLE_NAME                    : T1                    
INDEX_NAME                    : T1_N2                 
BLEVEL                        : 1                     
LEAF_BLOCKS                   : 26                    
DISTINCT_KEYS                 : 10000                 
CLUSTERING_FACTOR             : 9934                  
SAMPLE_SIZE                   : 10000                 
GLOBAL_STATS                  : YES                   
LAST_ANAL                     : 2009/05/04 20:52:22   
-----------------                                     
&lt;/pre&gt;

I&#039;ll do very simple mathematics using these values(with some computational errors)

&lt;b&gt;1. For index T1_N1 of good clustering factor&lt;/b&gt;
&lt;pre&gt;
1) Leaf block# = 21
2) So, keys per leaf block = 10000/21 = 476
3) Table block# = 164
4) So, keys per table block = 10000/164 = 61
5) Buffer is pinned by the 2nd visit on the same block.
Next read on the same block is incremented as buffer is pinned count
6) So, buffer is pinned count = (478-1)*21 + (61-1)*164 = 19815

-- index T1_N1(good clustering factor)
NAME                                             DIFF
---------------------------------------- ------------
buffer is pinned count                         19,835

&lt;/pre&gt;

&lt;b&gt;2. For index T1_N2 of bad clustering factor&lt;/b&gt;
&lt;pre&gt;
1) Leaf block# = 26
2) So, keys per leaf block = 10000/26 = 384.6
3) Table block# = 164
4) So, keys per table block = 10000/164 = 61
5) Buffer is pinned by the 2nd visit on the same block.
Next read on the same block is incremented as buffer is pinned count
6) So, buffer is pinned count = (384.6-1)*26 +  = 
9973 + small_value_for_table


-- index T1_N2(bad clustering factor)
NAME                                             DIFF
---------------------------------------- ------------
buffer is pinned count                         10,066
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>@Roberto.</p>
<p>It&#8217;s all about simple mathematics. In the above example, the size of both indexes is as following.</p>
<pre>
TABLE_NAME                    : T1                    
INDEX_NAME                    : T1_N1                 
BLEVEL                        : 1                     
LEAF_BLOCKS                   : 21                    
DISTINCT_KEYS                 : 10000                 
CLUSTERING_FACTOR             : 164                   
SAMPLE_SIZE                   : 10000                 
GLOBAL_STATS                  : YES                   
LAST_ANAL                     : 2009/05/04 20:52:22   
-----------------                                     
TABLE_NAME                    : T1                    
INDEX_NAME                    : T1_N2                 
BLEVEL                        : 1                     
LEAF_BLOCKS                   : 26                    
DISTINCT_KEYS                 : 10000                 
CLUSTERING_FACTOR             : 9934                  
SAMPLE_SIZE                   : 10000                 
GLOBAL_STATS                  : YES                   
LAST_ANAL                     : 2009/05/04 20:52:22   
-----------------                                     
</pre>
<p>I&#8217;ll do very simple mathematics using these values(with some computational errors)</p>
<p><b>1. For index T1_N1 of good clustering factor</b></p>
<pre>
1) Leaf block# = 21
2) So, keys per leaf block = 10000/21 = 476
3) Table block# = 164
4) So, keys per table block = 10000/164 = 61
5) Buffer is pinned by the 2nd visit on the same block.
Next read on the same block is incremented as buffer is pinned count
6) So, buffer is pinned count = (478-1)*21 + (61-1)*164 = 19815

-- index T1_N1(good clustering factor)
NAME                                             DIFF
---------------------------------------- ------------
buffer is pinned count                         19,835

</pre>
<p><b>2. For index T1_N2 of bad clustering factor</b></p>
<pre>
1) Leaf block# = 26
2) So, keys per leaf block = 10000/26 = 384.6
3) Table block# = 164
4) So, keys per table block = 10000/164 = 61
5) Buffer is pinned by the 2nd visit on the same block.
Next read on the same block is incremented as buffer is pinned count
6) So, buffer is pinned count = (384.6-1)*26 +  = 
9973 + small_value_for_table


-- index T1_N2(bad clustering factor)
NAME                                             DIFF
---------------------------------------- ------------
buffer is pinned count                         10,066
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roberto</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-200</link>
		<dc:creator><![CDATA[Roberto]]></dc:creator>
		<pubDate>Mon, 04 May 2009 08:38:14 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-200</guid>
		<description><![CDATA[Please Dion, Nigel didn&#039;t respond me. Could you answer to my doubts?
Thanks,
Roberto]]></description>
		<content:encoded><![CDATA[<p>Please Dion, Nigel didn&#8217;t respond me. Could you answer to my doubts?<br />
Thanks,<br />
Roberto</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lscheng</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-197</link>
		<dc:creator><![CDATA[lscheng]]></dc:creator>
		<pubDate>Sun, 03 May 2009 08:50:34 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-197</guid>
		<description><![CDATA[Aha, it&#039;s very clear now

Thank you for the time and patience :-)]]></description>
		<content:encoded><![CDATA[<p>Aha, it&#8217;s very clear now</p>
<p>Thank you for the time and patience :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dion Cho</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-195</link>
		<dc:creator><![CDATA[Dion Cho]]></dc:creator>
		<pubDate>Sat, 02 May 2009 23:24:15 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-195</guid>
		<description><![CDATA[@Lscheng

The step got modified as following.
&lt;pre&gt;
1. Acquire CBCL in the shared mode.
2. Walk through the chain and find the buffer to read.
3. Release CBCL.
4. Acquire CBCL in the exclusive mode.
5. Acquire buffer pin for the buffer - shared mode for SELECT, exclusive mode for DML.
6. Release CBCL.
7. Read the buffer.
8. Acquire CBCL in the exclusive mode.
9. Release buffer pin.
10. Release CBCL.
11. Logical Reads done!
&lt;/pre&gt;

The point here is that &lt;b&gt;buffer pin itself is a shared memory object which should be protected by latch&lt;/b&gt;. CBCL is used to protect buffer pin. 

So to acquire buffer pin, 1) acquire CBCL in exclusive mode 2) acquire buffer pin 3) release CBCL.

And to release buffer pin, 1) acquire CBCL in exclusive mode 2) release buffer pin 3) release CBCL.

And this is why concurrent reads are still blocked by CBCL contention. At &lt;b&gt;the short period during buffer read&lt;/b&gt;, we still need to acquire CBCL in exclusive mode.]]></description>
		<content:encoded><![CDATA[<p>@Lscheng</p>
<p>The step got modified as following.</p>
<pre>
1. Acquire CBCL in the shared mode.
2. Walk through the chain and find the buffer to read.
3. Release CBCL.
4. Acquire CBCL in the exclusive mode.
5. Acquire buffer pin for the buffer - shared mode for SELECT, exclusive mode for DML.
6. Release CBCL.
7. Read the buffer.
8. Acquire CBCL in the exclusive mode.
9. Release buffer pin.
10. Release CBCL.
11. Logical Reads done!
</pre>
<p>The point here is that <b>buffer pin itself is a shared memory object which should be protected by latch</b>. CBCL is used to protect buffer pin. </p>
<p>So to acquire buffer pin, 1) acquire CBCL in exclusive mode 2) acquire buffer pin 3) release CBCL.</p>
<p>And to release buffer pin, 1) acquire CBCL in exclusive mode 2) release buffer pin 3) release CBCL.</p>
<p>And this is why concurrent reads are still blocked by CBCL contention. At <b>the short period during buffer read</b>, we still need to acquire CBCL in exclusive mode.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lscheng</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-194</link>
		<dc:creator><![CDATA[lscheng]]></dc:creator>
		<pubDate>Sat, 02 May 2009 22:53:20 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-194</guid>
		<description><![CDATA[Sprry I mean step order should be

1, 2, 3, 4, 7, 8, 10,11, 12]]></description>
		<content:encoded><![CDATA[<p>Sprry I mean step order should be</p>
<p>1, 2, 3, 4, 7, 8, 10,11, 12</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lscheng</title>
		<link>http://dioncho.wordpress.com/2009/04/08/buffer-pinning/#comment-193</link>
		<dc:creator><![CDATA[lscheng]]></dc:creator>
		<pubDate>Sat, 02 May 2009 22:49:58 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=497#comment-193</guid>
		<description><![CDATA[Hi Dion

Dont understand very well step 5 and 7, arent they the same? Shouldnt the step be 1, 2, 3, 4, 7, 8, 9, 10,11, 12?

So at the end of the day concurrent reads could block each other due to exclusive CBCL (as I thought) no?

Thanks for your time]]></description>
		<content:encoded><![CDATA[<p>Hi Dion</p>
<p>Dont understand very well step 5 and 7, arent they the same? Shouldnt the step be 1, 2, 3, 4, 7, 8, 9, 10,11, 12?</p>
<p>So at the end of the day concurrent reads could block each other due to exclusive CBCL (as I thought) no?</p>
<p>Thanks for your time</p>
]]></content:encoded>
	</item>
</channel>
</rss>
