<?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: OC 7 Parsing and Optimising</title>
	<atom:link href="http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Sun, 26 May 2013 02:13:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Martin Maletinsky</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-55154</link>
		<dc:creator><![CDATA[Martin Maletinsky]]></dc:creator>
		<pubDate>Wed, 01 May 2013 17:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-55154</guid>
		<description><![CDATA[Hello Jonathan,

Just after I finished reading chapter 7 I faced an ORA-04020 on a client&#039;s production system. The theory I learnt in chapter 7 helped me a lot to understand the context of the problem. However, when I look at the tracefile that was produced, I still have a question (although the problem at the client&#039;s site has been resolved). I include an excerpt of the tracefile below:

[...]
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning option
[...]
System name:	AIX
Node name:	[...]
Release:	1
Version:	7
[...]
Redo thread mounted by this instance: 1
Oracle process number: 70
Unix process pid: 11927750, image: oracle@[...] (J003)


*** 2013-04-25 19:39:54.145
*** SESSION ID:(471.65) 2013-04-25 19:39:54.145
*** CLIENT ID:() 2013-04-25 19:39:54.145
*** SERVICE NAME:(SYS$USERS) 2013-04-25 19:39:54.145
*** MODULE NAME:(DBMS_SCHEDULER) 2013-04-25 19:39:54.145
*** ACTION NAME:(AVQ$ISLRM0_42100) 2013-04-25 19:39:54.145
 
A deadlock among DDL and parse locks is detected.
This deadlock is usually due to user errors in
the design of an application or from issuing a set
of concurrent statements which can cause a deadlock.
[...]
ORA-04020: deadlock detected while trying to lock object K.DEF_SEC_ENV
--------------------------------------------------------
  object   waiting  waiting       blocking blocking
  handle   session     lock mode   session     lock mode
--------  -------- -------- ----  -------- -------- ----
700000297c255b0  7000002a889eb68 700000285b96050    X  7000002a889eb68 700000285c0a3f0    S
700000298c42b90  7000002aaa29498 7000002826d79d0    X  7000002a889eb68 700000285c0b700    S
--------------------------------------------------------
[...]

From how I read the deadlock graph, the session identified by 7000002a889eb68 was locking itself as it was holding a shared lock on library cache object 700000297c255b0 and wanted to get an exclusive lock on that object. Moreover this session was holding a shared lock on library cache object 700000298c42b90, which was requested to be locked in exclusive mode by a session identified by 7000002aaa29498.

The two library cache objects were PL/SQL packages. The scenario was that the client was installing a software upgrade, and forgot to stop all application processes connecting to the database (as would be required), so the solution was to repeat the installation after properly terminating all processes connected to the database.

The surviving session (7000002a889eb68) was the application process the client forgot to stop, while the session that terminated with an ORA-04020 was one of the processes doing the actual installation.

The point I don&#039;t understand, is why the above scenario is considered a deadlock. Couldn&#039;t session 7000002a889eb68 just convert it&#039;s shared lock to an exclusive lock (if there were other sessions holding a shared lock on the object it obviously couldn&#039;t, but then I&#039;d expect to see those sessions in the deadlock graph and to be listed as the session blocking session 7000002a889eb68). Also, terminating session 7000002aaa29498 as Oracle did doesn&#039;t resolve the locking graph - and in fact ORA-04020 occurred two more times throughout the faulty installation, each time with session 7000002a889eb68 in the same place in the corresponding deadlock graph, locked on the same object (700000297c255b0) and with two other installation processes being blocked by this session and terminating with an ORA-04020.

I just add the remainder of the tracefile below in case it contains any information that is relevant to understand the problem.

Thank you
kind regards
Martin


[...]
---------- DUMP OF WAITING AND BLOCKING LOCKS ----------
--------------------------------------------------------
------------- WAITING LOCK -------------
----------------------------------------
SO: 0x700000285b96050, type: 78, owner: 0x7000002a3ea7fb0, flag: INIT/-/-/0x00 if: 0x3 c: 0x3
 proc=0x7000002aa7250e8, name=LIBRARY OBJECT LOCK, file=kgl.h LINE:8548 ID:, pg=0

LibraryObjectLock:  Address=700000285b96050 Handle=700000297c255b0 RequestMode=X CanBeBrokenCount=1 Incarnation=2 ExecutionCount=0   
  
  User=7000002a889eb68 Session=7000002ac94e810 ReferenceCount=0 Flags=[0000] SavepointNum=152b0 
  LibraryHandle:  Address=700000297c255b0 Hash=14f3dcb0 LockMode=S PinMode=S LoadLockMode=0 Status=INVL 
  ObjectName:  Name=K.BASE_PAR#   
    FullHashValue=a198494a548895777a38651614f3dcb0 Namespace=TABLE/PROCEDURE(01) Type=PACKAGE(09) Identifier=274315 OwnerIdn=29 
  Statistics:  InvalidationCount=1 ExecutionCount=4 LoadCount=6 ActiveLocks=1 TotalLockCount=128 TotalPinCount=145 
  Counters:  BrokenCount=1 RevocablePointer=2 KeepDependency=0 BucketInUse=306 HandleInUse=306 HandleReferenceCount=0 
  Concurrency:  DependencyMutex=700000297c25660(0, 600, 0, 0) Mutex=700000297c256e0(0, 1961, 0, 0) 
  Flags=PIN/TIM/[00002801] 
  WaitersLists:  
    Lock=700000297c25640[700000285b960c0,700000285b960c0] 
    Pin=700000297c25620[700000297c25620,700000297c25620] 
    LoadLock=700000297c25698[700000297c25698,700000297c25698] 
  Timestamp:  Current=10-13-2012 01:55:44 
  HandleReference:  Address=700000297c25758 Handle=700000299dc22a8 Flags=OWN[200] 
  LibraryObject:  Address=70000028f5c0ca8 HeapMask=0000-0015-0015-0000 Flags=EXS/LOC[0004] Flags2=[0000] PublicFlags=/SWR[0008] 
    DataBlocks:  
      Block:  #=&#039;0&#039; name=KGLH0^14f3dcb0 pins=0 Change=NONE   
        Heap=70000028f5c1c60 Pointer=70000028f5c0d48 Extent=70000028f5c0c28 Flags=I/-/P/A/-/- 
        FreedLocation=0 Alloc=1.773438 Size=3.976562 LoadTime=59819567764 
      Block:  #=&#039;2&#039; name=PLDIA^14f3dcb0 pins=1 Change=NONE   
        Heap=70000028f5c1110 Pointer=70000028f5bfca8 Extent=70000028f5bfc28 Flags=I/-/P/A/-/- 
        FreedLocation=0 Alloc=54.085938 Size=56.000000 LoadTime=59819567764 
      Block:  #=&#039;4&#039; name=PLMCD^14f3dcb0 pins=0 Change=NONE   
        Heap=70000028f5c11e8 Pointer=70000028f583278 Extent=70000028f5831f8 Flags=I/-/-/A/-/- 
        FreedLocation=0 Alloc=6.960938 Size=8.031250 LoadTime=59819568229 ------------- BLOCKING LOCK ------------
----------------------------------------
SO: 0x700000285c0a3f0, type: 78, owner: 0x7000002a3f836e0, flag: INIT/-/-/0x00 if: 0x3 c: 0x3
 proc=0x7000002aa7250e8, name=LIBRARY OBJECT LOCK, file=kgl.h LINE:8548 ID:, pg=0

LibraryObjectLock:  Address=700000285c0a3f0 Handle=700000297c255b0 Mode=S CanBeBrokenCount=1 Incarnation=1 ExecutionCount=0   
  
  User=7000002a889eb68 Session=7000002ac94e810 ReferenceCount=1 Flags=CNB/[0001] SavepointNum=3254 
  LibraryHandle:  Address=700000297c255b0 Hash=14f3dcb0 LockMode=S PinMode=S LoadLockMode=0 Status=INVL 
  ObjectName:  Name=K.BASE_PAR#   
    FullHashValue=a198494a548895777a38651614f3dcb0 Namespace=TABLE/PROCEDURE(01) Type=PACKAGE(09) Identifier=274315 OwnerIdn=29 
  Statistics:  InvalidationCount=1 ExecutionCount=4 LoadCount=6 ActiveLocks=1 TotalLockCount=128 TotalPinCount=145 
  Counters:  BrokenCount=1 RevocablePointer=2 KeepDependency=0 BucketInUse=306 HandleInUse=306 HandleReferenceCount=0 
  Concurrency:  DependencyMutex=700000297c25660(0, 600, 0, 0) Mutex=700000297c256e0(0, 1961, 0, 0) 
  Flags=PIN/TIM/[00002801] 
  WaitersLists:  
    Lock=700000297c25640[700000285b960c0,700000285b960c0] 
    Pin=700000297c25620[700000297c25620,700000297c25620] 
    LoadLock=700000297c25698[700000297c25698,700000297c25698] 
  Timestamp:  Current=10-13-2012 01:55:44 
  HandleReference:  Address=700000297c25758 Handle=700000299dc22a8 Flags=OWN[200] 
  LibraryObject:  Address=70000028f5c0ca8 HeapMask=0000-0015-0015-0000 Flags=EXS/LOC[0004] Flags2=[0000] PublicFlags=/SWR[0008] 
    DataBlocks:  
      Block:  #=&#039;0&#039; name=KGLH0^14f3dcb0 pins=0 Change=NONE   
        Heap=70000028f5c1c60 Pointer=70000028f5c0d48 Extent=70000028f5c0c28 Flags=I/-/P/A/-/- 
        FreedLocation=0 Alloc=1.773438 Size=3.976562 LoadTime=59819567764 
      Block:  #=&#039;2&#039; name=PLDIA^14f3dcb0 pins=1 Change=NONE   
        Heap=70000028f5c1110 Pointer=70000028f5bfca8 Extent=70000028f5bfc28 Flags=I/-/P/A/-/- 
        FreedLocation=0 Alloc=54.085938 Size=56.000000 LoadTime=59819567764 
      Block:  #=&#039;4&#039; name=PLMCD^14f3dcb0 pins=0 Change=NONE   
        Heap=70000028f5c11e8 Pointer=70000028f583278 Extent=70000028f5831f8 Flags=I/-/-/A/-/- 
        FreedLocation=0 Alloc=6.960938 Size=8.031250 LoadTime=59819568229 ------------- WAITING LOCK -------------
----------------------------------------
SO: 0x7000002826d79d0, type: 78, owner: 0x7000002a3f13810, flag: INIT/-/-/0x00 if: 0x3 c: 0x3
 proc=0x7000002aa71bb48, name=LIBRARY OBJECT LOCK, file=kgl.h LINE:8548 ID:, pg=0

LibraryObjectLock:  Address=7000002826d79d0 Handle=700000298c42b90 RequestMode=X CanBeBrokenCount=1 Incarnation=1 ExecutionCount=0   
  
  User=7000002aaa29498 Session=7000002aaa29498 ReferenceCount=0 Flags=[0100] SavepointNum=126f08 
  LibraryHandle:  Address=700000298c42b90 Hash=be6d0403 LockMode=S PinMode=S LoadLockMode=0 Status=VALD 
  ObjectName:  Name=K.DEF_SEC_ENV   
    FullHashValue=71ccc043dbfdfb6ee394b13dbe6d0403 Namespace=TABLE/PROCEDURE(01) Type=PACKAGE(09) Identifier=58571 OwnerIdn=29 
  Statistics:  InvalidationCount=0 ExecutionCount=0 LoadCount=1 ActiveLocks=1 TotalLockCount=1 TotalPinCount=1 
  Counters:  BrokenCount=1 RevocablePointer=1 KeepDependency=0 BucketInUse=4 HandleInUse=4 HandleReferenceCount=0 
  Concurrency:  DependencyMutex=700000298c42c40(0, 3, 0, 0) Mutex=700000298c42cc0(0, 175, 0, 0) 
  Flags=PIN/TIM/[00002801] 
  WaitersLists:  
    Lock=700000298c42c20[7000002826d7a40,7000002826d7a40] 
    Pin=700000298c42c00[700000298c42c00,700000298c42c00] 
    LoadLock=700000298c42c78[700000298c42c78,700000298c42c78] 
  Timestamp:  Current=11-16-2012 19:10:57 
  HandleReference:  Address=700000298c42d38 Handle=700000299dc22a8 Flags=OWN[200] 
  LibraryObject:  Address=700000282c65820 HeapMask=0000-0005-0005-0000 Flags=EXS/LOC[0004] Flags2=[0000] PublicFlags=NST[0001] 
    DataBlocks:  
      Block:  #=&#039;0&#039; name=KGLH0^be6d0403 pins=0 Change=NONE   
        Heap=7000002984ce330 Pointer=700000282c65910 Extent=700000282c657a0 Flags=I/-/P/A/-/- 
        FreedLocation=0 Alloc=0.882812 Size=4.000000 LoadTime=59819579077 
      Block:  #=&#039;2&#039; name=PLDIA^be6d0403 pins=1 Change=NONE   
        Heap=700000282c65a68 Pointer=700000282c64820 Extent=700000282c647a0 Flags=I/-/P/A/-/- 
        FreedLocation=0 Alloc=29.679688 Size=32.000000 LoadTime=59819579077 ------------- BLOCKING LOCK ------------
----------------------------------------
SO: 0x700000285c0b700, type: 78, owner: 0x7000002a3f836e0, flag: INIT/-/-/0x00 if: 0x3 c: 0x3
 proc=0x7000002aa7250e8, name=LIBRARY OBJECT LOCK, file=kgl.h LINE:8548 ID:, pg=0

LibraryObjectLock:  Address=700000285c0b700 Handle=700000298c42b90 Mode=S CanBeBrokenCount=1 Incarnation=1 ExecutionCount=0   
  
  User=7000002a889eb68 Session=7000002ac94e810 ReferenceCount=1 Flags=CNB/[0001] SavepointNum=375b 
  LibraryHandle:  Address=700000298c42b90 Hash=be6d0403 LockMode=S PinMode=S LoadLockMode=0 Status=VALD 
  ObjectName:  Name=K.DEF_SEC_ENV   
    FullHashValue=71ccc043dbfdfb6ee394b13dbe6d0403 Namespace=TABLE/PROCEDURE(01) Type=PACKAGE(09) Identifier=58571 OwnerIdn=29 
  Statistics:  InvalidationCount=0 ExecutionCount=0 LoadCount=1 ActiveLocks=1 TotalLockCount=1 TotalPinCount=1 
  Counters:  BrokenCount=1 RevocablePointer=1 KeepDependency=0 BucketInUse=4 HandleInUse=4 HandleReferenceCount=0 
  Concurrency:  DependencyMutex=700000298c42c40(0, 3, 0, 0) Mutex=700000298c42cc0(0, 175, 0, 0) 
  Flags=PIN/TIM/[00002801] 
  WaitersLists:  
    Lock=700000298c42c20[7000002826d7a40,7000002826d7a40] 
    Pin=700000298c42c00[700000298c42c00,700000298c42c00] 
    LoadLock=700000298c42c78[700000298c42c78,700000298c42c78] 
  Timestamp:  Current=11-16-2012 19:10:57 
  HandleReference:  Address=700000298c42d38 Handle=700000299dc22a8 Flags=OWN[200] 
  LibraryObject:  Address=700000282c65820 HeapMask=0000-0005-0005-0000 Flags=EXS/LOC[0004] Flags2=[0000] PublicFlags=NST[0001] 
    DataBlocks:  
      Block:  #=&#039;0&#039; name=KGLH0^be6d0403 pins=0 Change=NONE   
        Heap=7000002984ce330 Pointer=700000282c65910 Extent=700000282c657a0 Flags=I/-/P/A/-/- 
        FreedLocation=0 Alloc=0.882812 Size=4.000000 LoadTime=59819579077 
      Block:  #=&#039;2&#039; name=PLDIA^be6d0403 pins=1 Change=NONE   
        Heap=700000282c65a68 Pointer=700000282c64820 Extent=700000282c647a0 Flags=I/-/P/A/-/- 
        FreedLocation=0 Alloc=29.679688 Size=32.000000 LoadTime=59819579077 --------------------------------------------------------
This lock request was aborted.]]></description>
		<content:encoded><![CDATA[<p>Hello Jonathan,</p>
<p>Just after I finished reading chapter 7 I faced an ORA-04020 on a client&#8217;s production system. The theory I learnt in chapter 7 helped me a lot to understand the context of the problem. However, when I look at the tracefile that was produced, I still have a question (although the problem at the client&#8217;s site has been resolved). I include an excerpt of the tracefile below:</p>
<p>[...]<br />
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 &#8211; 64bit Production<br />
With the Partitioning option<br />
[...]<br />
System name:	AIX<br />
Node name:	[...]<br />
Release:	1<br />
Version:	7<br />
[...]<br />
Redo thread mounted by this instance: 1<br />
Oracle process number: 70<br />
Unix process pid: 11927750, image: oracle@[...] (J003)</p>
<p>*** 2013-04-25 19:39:54.145<br />
*** SESSION ID:(471.65) 2013-04-25 19:39:54.145<br />
*** CLIENT ID:() 2013-04-25 19:39:54.145<br />
*** SERVICE NAME:(SYS$USERS) 2013-04-25 19:39:54.145<br />
*** MODULE NAME:(DBMS_SCHEDULER) 2013-04-25 19:39:54.145<br />
*** ACTION NAME:(AVQ$ISLRM0_42100) 2013-04-25 19:39:54.145</p>
<p>A deadlock among DDL and parse locks is detected.<br />
This deadlock is usually due to user errors in<br />
the design of an application or from issuing a set<br />
of concurrent statements which can cause a deadlock.<br />
[...]<br />
ORA-04020: deadlock detected while trying to lock object K.DEF_SEC_ENV<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
  object   waiting  waiting       blocking blocking<br />
  handle   session     lock mode   session     lock mode<br />
&#8212;&#8212;&#8211;  &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-  &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-<br />
700000297c255b0  7000002a889eb68 700000285b96050    X  7000002a889eb68 700000285c0a3f0    S<br />
700000298c42b90  7000002aaa29498 7000002826d79d0    X  7000002a889eb68 700000285c0b700    S<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
[...]</p>
<p>From how I read the deadlock graph, the session identified by 7000002a889eb68 was locking itself as it was holding a shared lock on library cache object 700000297c255b0 and wanted to get an exclusive lock on that object. Moreover this session was holding a shared lock on library cache object 700000298c42b90, which was requested to be locked in exclusive mode by a session identified by 7000002aaa29498.</p>
<p>The two library cache objects were PL/SQL packages. The scenario was that the client was installing a software upgrade, and forgot to stop all application processes connecting to the database (as would be required), so the solution was to repeat the installation after properly terminating all processes connected to the database.</p>
<p>The surviving session (7000002a889eb68) was the application process the client forgot to stop, while the session that terminated with an ORA-04020 was one of the processes doing the actual installation.</p>
<p>The point I don&#8217;t understand, is why the above scenario is considered a deadlock. Couldn&#8217;t session 7000002a889eb68 just convert it&#8217;s shared lock to an exclusive lock (if there were other sessions holding a shared lock on the object it obviously couldn&#8217;t, but then I&#8217;d expect to see those sessions in the deadlock graph and to be listed as the session blocking session 7000002a889eb68). Also, terminating session 7000002aaa29498 as Oracle did doesn&#8217;t resolve the locking graph &#8211; and in fact ORA-04020 occurred two more times throughout the faulty installation, each time with session 7000002a889eb68 in the same place in the corresponding deadlock graph, locked on the same object (700000297c255b0) and with two other installation processes being blocked by this session and terminating with an ORA-04020.</p>
<p>I just add the remainder of the tracefile below in case it contains any information that is relevant to understand the problem.</p>
<p>Thank you<br />
kind regards<br />
Martin</p>
<p>[...]<br />
&#8212;&#8212;&#8212;- DUMP OF WAITING AND BLOCKING LOCKS &#8212;&#8212;&#8212;-<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8212;&#8212;&#8212;&#8212;- WAITING LOCK &#8212;&#8212;&#8212;&#8212;-<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
SO: 0x700000285b96050, type: 78, owner: 0x7000002a3ea7fb0, flag: INIT/-/-/0&#215;00 if: 0&#215;3 c: 0&#215;3<br />
 proc=0x7000002aa7250e8, name=LIBRARY OBJECT LOCK, file=kgl.h LINE:8548 ID:, pg=0</p>
<p>LibraryObjectLock:  Address=700000285b96050 Handle=700000297c255b0 RequestMode=X CanBeBrokenCount=1 Incarnation=2 ExecutionCount=0   </p>
<p>  User=7000002a889eb68 Session=7000002ac94e810 ReferenceCount=0 Flags=[0000] SavepointNum=152b0<br />
  LibraryHandle:  Address=700000297c255b0 Hash=14f3dcb0 LockMode=S PinMode=S LoadLockMode=0 Status=INVL<br />
  ObjectName:  Name=K.BASE_PAR#<br />
    FullHashValue=a198494a548895777a38651614f3dcb0 Namespace=TABLE/PROCEDURE(01) Type=PACKAGE(09) Identifier=274315 OwnerIdn=29<br />
  Statistics:  InvalidationCount=1 ExecutionCount=4 LoadCount=6 ActiveLocks=1 TotalLockCount=128 TotalPinCount=145<br />
  Counters:  BrokenCount=1 RevocablePointer=2 KeepDependency=0 BucketInUse=306 HandleInUse=306 HandleReferenceCount=0<br />
  Concurrency:  DependencyMutex=700000297c25660(0, 600, 0, 0) Mutex=700000297c256e0(0, 1961, 0, 0)<br />
  Flags=PIN/TIM/[00002801]<br />
  WaitersLists:<br />
    Lock=700000297c25640[700000285b960c0,700000285b960c0]<br />
    Pin=700000297c25620[700000297c25620,700000297c25620]<br />
    LoadLock=700000297c25698[700000297c25698,700000297c25698]<br />
  Timestamp:  Current=10-13-2012 01:55:44<br />
  HandleReference:  Address=700000297c25758 Handle=700000299dc22a8 Flags=OWN[200]<br />
  LibraryObject:  Address=70000028f5c0ca8 HeapMask=0000-0015-0015-0000 Flags=EXS/LOC[0004] Flags2=[0000] PublicFlags=/SWR[0008]<br />
    DataBlocks:<br />
      Block:  #=&#8217;0&#8242; name=KGLH0^14f3dcb0 pins=0 Change=NONE<br />
        Heap=70000028f5c1c60 Pointer=70000028f5c0d48 Extent=70000028f5c0c28 Flags=I/-/P/A/-/-<br />
        FreedLocation=0 Alloc=1.773438 Size=3.976562 LoadTime=59819567764<br />
      Block:  #=&#8217;2&#8242; name=PLDIA^14f3dcb0 pins=1 Change=NONE<br />
        Heap=70000028f5c1110 Pointer=70000028f5bfca8 Extent=70000028f5bfc28 Flags=I/-/P/A/-/-<br />
        FreedLocation=0 Alloc=54.085938 Size=56.000000 LoadTime=59819567764<br />
      Block:  #=&#8217;4&#8242; name=PLMCD^14f3dcb0 pins=0 Change=NONE<br />
        Heap=70000028f5c11e8 Pointer=70000028f583278 Extent=70000028f5831f8 Flags=I/-/-/A/-/-<br />
        FreedLocation=0 Alloc=6.960938 Size=8.031250 LoadTime=59819568229 &#8212;&#8212;&#8212;&#8212;- BLOCKING LOCK &#8212;&#8212;&#8212;&#8212;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
SO: 0x700000285c0a3f0, type: 78, owner: 0x7000002a3f836e0, flag: INIT/-/-/0&#215;00 if: 0&#215;3 c: 0&#215;3<br />
 proc=0x7000002aa7250e8, name=LIBRARY OBJECT LOCK, file=kgl.h LINE:8548 ID:, pg=0</p>
<p>LibraryObjectLock:  Address=700000285c0a3f0 Handle=700000297c255b0 Mode=S CanBeBrokenCount=1 Incarnation=1 ExecutionCount=0   </p>
<p>  User=7000002a889eb68 Session=7000002ac94e810 ReferenceCount=1 Flags=CNB/[0001] SavepointNum=3254<br />
  LibraryHandle:  Address=700000297c255b0 Hash=14f3dcb0 LockMode=S PinMode=S LoadLockMode=0 Status=INVL<br />
  ObjectName:  Name=K.BASE_PAR#<br />
    FullHashValue=a198494a548895777a38651614f3dcb0 Namespace=TABLE/PROCEDURE(01) Type=PACKAGE(09) Identifier=274315 OwnerIdn=29<br />
  Statistics:  InvalidationCount=1 ExecutionCount=4 LoadCount=6 ActiveLocks=1 TotalLockCount=128 TotalPinCount=145<br />
  Counters:  BrokenCount=1 RevocablePointer=2 KeepDependency=0 BucketInUse=306 HandleInUse=306 HandleReferenceCount=0<br />
  Concurrency:  DependencyMutex=700000297c25660(0, 600, 0, 0) Mutex=700000297c256e0(0, 1961, 0, 0)<br />
  Flags=PIN/TIM/[00002801]<br />
  WaitersLists:<br />
    Lock=700000297c25640[700000285b960c0,700000285b960c0]<br />
    Pin=700000297c25620[700000297c25620,700000297c25620]<br />
    LoadLock=700000297c25698[700000297c25698,700000297c25698]<br />
  Timestamp:  Current=10-13-2012 01:55:44<br />
  HandleReference:  Address=700000297c25758 Handle=700000299dc22a8 Flags=OWN[200]<br />
  LibraryObject:  Address=70000028f5c0ca8 HeapMask=0000-0015-0015-0000 Flags=EXS/LOC[0004] Flags2=[0000] PublicFlags=/SWR[0008]<br />
    DataBlocks:<br />
      Block:  #=&#8217;0&#8242; name=KGLH0^14f3dcb0 pins=0 Change=NONE<br />
        Heap=70000028f5c1c60 Pointer=70000028f5c0d48 Extent=70000028f5c0c28 Flags=I/-/P/A/-/-<br />
        FreedLocation=0 Alloc=1.773438 Size=3.976562 LoadTime=59819567764<br />
      Block:  #=&#8217;2&#8242; name=PLDIA^14f3dcb0 pins=1 Change=NONE<br />
        Heap=70000028f5c1110 Pointer=70000028f5bfca8 Extent=70000028f5bfc28 Flags=I/-/P/A/-/-<br />
        FreedLocation=0 Alloc=54.085938 Size=56.000000 LoadTime=59819567764<br />
      Block:  #=&#8217;4&#8242; name=PLMCD^14f3dcb0 pins=0 Change=NONE<br />
        Heap=70000028f5c11e8 Pointer=70000028f583278 Extent=70000028f5831f8 Flags=I/-/-/A/-/-<br />
        FreedLocation=0 Alloc=6.960938 Size=8.031250 LoadTime=59819568229 &#8212;&#8212;&#8212;&#8212;- WAITING LOCK &#8212;&#8212;&#8212;&#8212;-<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
SO: 0x7000002826d79d0, type: 78, owner: 0x7000002a3f13810, flag: INIT/-/-/0&#215;00 if: 0&#215;3 c: 0&#215;3<br />
 proc=0x7000002aa71bb48, name=LIBRARY OBJECT LOCK, file=kgl.h LINE:8548 ID:, pg=0</p>
<p>LibraryObjectLock:  Address=7000002826d79d0 Handle=700000298c42b90 RequestMode=X CanBeBrokenCount=1 Incarnation=1 ExecutionCount=0   </p>
<p>  User=7000002aaa29498 Session=7000002aaa29498 ReferenceCount=0 Flags=[0100] SavepointNum=126f08<br />
  LibraryHandle:  Address=700000298c42b90 Hash=be6d0403 LockMode=S PinMode=S LoadLockMode=0 Status=VALD<br />
  ObjectName:  Name=K.DEF_SEC_ENV<br />
    FullHashValue=71ccc043dbfdfb6ee394b13dbe6d0403 Namespace=TABLE/PROCEDURE(01) Type=PACKAGE(09) Identifier=58571 OwnerIdn=29<br />
  Statistics:  InvalidationCount=0 ExecutionCount=0 LoadCount=1 ActiveLocks=1 TotalLockCount=1 TotalPinCount=1<br />
  Counters:  BrokenCount=1 RevocablePointer=1 KeepDependency=0 BucketInUse=4 HandleInUse=4 HandleReferenceCount=0<br />
  Concurrency:  DependencyMutex=700000298c42c40(0, 3, 0, 0) Mutex=700000298c42cc0(0, 175, 0, 0)<br />
  Flags=PIN/TIM/[00002801]<br />
  WaitersLists:<br />
    Lock=700000298c42c20[7000002826d7a40,7000002826d7a40]<br />
    Pin=700000298c42c00[700000298c42c00,700000298c42c00]<br />
    LoadLock=700000298c42c78[700000298c42c78,700000298c42c78]<br />
  Timestamp:  Current=11-16-2012 19:10:57<br />
  HandleReference:  Address=700000298c42d38 Handle=700000299dc22a8 Flags=OWN[200]<br />
  LibraryObject:  Address=700000282c65820 HeapMask=0000-0005-0005-0000 Flags=EXS/LOC[0004] Flags2=[0000] PublicFlags=NST[0001]<br />
    DataBlocks:<br />
      Block:  #=&#8217;0&#8242; name=KGLH0^be6d0403 pins=0 Change=NONE<br />
        Heap=7000002984ce330 Pointer=700000282c65910 Extent=700000282c657a0 Flags=I/-/P/A/-/-<br />
        FreedLocation=0 Alloc=0.882812 Size=4.000000 LoadTime=59819579077<br />
      Block:  #=&#8217;2&#8242; name=PLDIA^be6d0403 pins=1 Change=NONE<br />
        Heap=700000282c65a68 Pointer=700000282c64820 Extent=700000282c647a0 Flags=I/-/P/A/-/-<br />
        FreedLocation=0 Alloc=29.679688 Size=32.000000 LoadTime=59819579077 &#8212;&#8212;&#8212;&#8212;- BLOCKING LOCK &#8212;&#8212;&#8212;&#8212;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
SO: 0x700000285c0b700, type: 78, owner: 0x7000002a3f836e0, flag: INIT/-/-/0&#215;00 if: 0&#215;3 c: 0&#215;3<br />
 proc=0x7000002aa7250e8, name=LIBRARY OBJECT LOCK, file=kgl.h LINE:8548 ID:, pg=0</p>
<p>LibraryObjectLock:  Address=700000285c0b700 Handle=700000298c42b90 Mode=S CanBeBrokenCount=1 Incarnation=1 ExecutionCount=0   </p>
<p>  User=7000002a889eb68 Session=7000002ac94e810 ReferenceCount=1 Flags=CNB/[0001] SavepointNum=375b<br />
  LibraryHandle:  Address=700000298c42b90 Hash=be6d0403 LockMode=S PinMode=S LoadLockMode=0 Status=VALD<br />
  ObjectName:  Name=K.DEF_SEC_ENV<br />
    FullHashValue=71ccc043dbfdfb6ee394b13dbe6d0403 Namespace=TABLE/PROCEDURE(01) Type=PACKAGE(09) Identifier=58571 OwnerIdn=29<br />
  Statistics:  InvalidationCount=0 ExecutionCount=0 LoadCount=1 ActiveLocks=1 TotalLockCount=1 TotalPinCount=1<br />
  Counters:  BrokenCount=1 RevocablePointer=1 KeepDependency=0 BucketInUse=4 HandleInUse=4 HandleReferenceCount=0<br />
  Concurrency:  DependencyMutex=700000298c42c40(0, 3, 0, 0) Mutex=700000298c42cc0(0, 175, 0, 0)<br />
  Flags=PIN/TIM/[00002801]<br />
  WaitersLists:<br />
    Lock=700000298c42c20[7000002826d7a40,7000002826d7a40]<br />
    Pin=700000298c42c00[700000298c42c00,700000298c42c00]<br />
    LoadLock=700000298c42c78[700000298c42c78,700000298c42c78]<br />
  Timestamp:  Current=11-16-2012 19:10:57<br />
  HandleReference:  Address=700000298c42d38 Handle=700000299dc22a8 Flags=OWN[200]<br />
  LibraryObject:  Address=700000282c65820 HeapMask=0000-0005-0005-0000 Flags=EXS/LOC[0004] Flags2=[0000] PublicFlags=NST[0001]<br />
    DataBlocks:<br />
      Block:  #=&#8217;0&#8242; name=KGLH0^be6d0403 pins=0 Change=NONE<br />
        Heap=7000002984ce330 Pointer=700000282c65910 Extent=700000282c657a0 Flags=I/-/P/A/-/-<br />
        FreedLocation=0 Alloc=0.882812 Size=4.000000 LoadTime=59819579077<br />
      Block:  #=&#8217;2&#8242; name=PLDIA^be6d0403 pins=1 Change=NONE<br />
        Heap=700000282c65a68 Pointer=700000282c64820 Extent=700000282c647a0 Flags=I/-/P/A/-/-<br />
        FreedLocation=0 Alloc=29.679688 Size=32.000000 LoadTime=59819579077 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
This lock request was aborted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Maletinsky</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-54928</link>
		<dc:creator><![CDATA[Martin Maletinsky]]></dc:creator>
		<pubDate>Tue, 23 Apr 2013 20:05:06 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-54928</guid>
		<description><![CDATA[Hello Jonathan,

Is my understanding correct that the strategy to hold cursors open which you describe starting on page 176 is the same that is done (automatically) by the PL/SQL interpreter when the PL/SQL cursor cache comes in action? Is that what you are saying by &quot;the Oracle pre-compiler allows you to generate code that holds cursors without having to do any special coding&quot;? 
Or phrased differently is my understanding correct that the code on page 177 would behave identically (performance-wise) if you moved the calls to dbms_sql.open_cursor, dbms_sql.parse and dbms_sql.close_cursor inside the loop, as the PL/SQL cursor cache would still keep the cursor open?
If so, what would be the benefit to implement this in PL/SQL code (as the optimization is done automatically by PL/SQL anyway) - or did you just write the code to demonstrate how the PL/SQL cursor cache works?

thank you
kind regards
Martin]]></description>
		<content:encoded><![CDATA[<p>Hello Jonathan,</p>
<p>Is my understanding correct that the strategy to hold cursors open which you describe starting on page 176 is the same that is done (automatically) by the PL/SQL interpreter when the PL/SQL cursor cache comes in action? Is that what you are saying by &#8220;the Oracle pre-compiler allows you to generate code that holds cursors without having to do any special coding&#8221;?<br />
Or phrased differently is my understanding correct that the code on page 177 would behave identically (performance-wise) if you moved the calls to dbms_sql.open_cursor, dbms_sql.parse and dbms_sql.close_cursor inside the loop, as the PL/SQL cursor cache would still keep the cursor open?<br />
If so, what would be the benefit to implement this in PL/SQL code (as the optimization is done automatically by PL/SQL anyway) &#8211; or did you just write the code to demonstrate how the PL/SQL cursor cache works?</p>
<p>thank you<br />
kind regards<br />
Martin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Maletinsky</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-54927</link>
		<dc:creator><![CDATA[Martin Maletinsky]]></dc:creator>
		<pubDate>Tue, 23 Apr 2013 19:54:25 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-54927</guid>
		<description><![CDATA[Hello Jonathan,

On page 183 you write that the sub-pool concept used to cause ORA-04031 in earlier releases. Is this no longer the case - and if so since which release and how did Oracle fix the problem (the most obvious approach would be to have a session try each of the sub-pools in turn in case it&#039;s allocation request to the first sub-pool fails). On page 191 (second paragraph) however you mention that the scenario of no sufficiently contiguous memory in one sub-pool can cause an ORA-04031, without referring to old versions.

Also on page 183 you mention that one of the reasons to introduce sub-pools was to combat ORA-04031. In what way do the sub-pools address the ORA-04031? Starting on that page 183 you list three damage limitation strategies, none of which seems to be directly related to the concept of sub-pools (the third is related to the sub-sub pools, i.e. durations, which could however be implemented independently of the sub-pools as well)

thank you
kind regards
Martin]]></description>
		<content:encoded><![CDATA[<p>Hello Jonathan,</p>
<p>On page 183 you write that the sub-pool concept used to cause ORA-04031 in earlier releases. Is this no longer the case &#8211; and if so since which release and how did Oracle fix the problem (the most obvious approach would be to have a session try each of the sub-pools in turn in case it&#8217;s allocation request to the first sub-pool fails). On page 191 (second paragraph) however you mention that the scenario of no sufficiently contiguous memory in one sub-pool can cause an ORA-04031, without referring to old versions.</p>
<p>Also on page 183 you mention that one of the reasons to introduce sub-pools was to combat ORA-04031. In what way do the sub-pools address the ORA-04031? Starting on that page 183 you list three damage limitation strategies, none of which seems to be directly related to the concept of sub-pools (the third is related to the sub-sub pools, i.e. durations, which could however be implemented independently of the sub-pools as well)</p>
<p>thank you<br />
kind regards<br />
Martin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Maletinsky</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-54896</link>
		<dc:creator><![CDATA[Martin Maletinsky]]></dc:creator>
		<pubDate>Mon, 22 Apr 2013 20:40:30 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-54896</guid>
		<description><![CDATA[Hello Jonathan,

I have a question regarding the free-lists which you describe starting on page 186. Is there one such list per sub-sub pool (which I don&#039;t think is written explicitly in the book, but I might also have skipped it when reading through the chapter). If so, are the different free lists just shown in order in the heapdump and is there any labelling telling what sub-sub pool the list belongs to? If this is not the case (i.e. one single free-list for the entire shared pool), how can Oracle determine to which sub-sub pool a chunk belongs that is found in the free-list and therefore decide if the chunk may be used to serve the corresponding memory request? 

thank you for clarification
kind regards
Martin]]></description>
		<content:encoded><![CDATA[<p>Hello Jonathan,</p>
<p>I have a question regarding the free-lists which you describe starting on page 186. Is there one such list per sub-sub pool (which I don&#8217;t think is written explicitly in the book, but I might also have skipped it when reading through the chapter). If so, are the different free lists just shown in order in the heapdump and is there any labelling telling what sub-sub pool the list belongs to? If this is not the case (i.e. one single free-list for the entire shared pool), how can Oracle determine to which sub-sub pool a chunk belongs that is found in the free-list and therefore decide if the chunk may be used to serve the corresponding memory request? </p>
<p>thank you for clarification<br />
kind regards<br />
Martin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Maletinsky</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-54895</link>
		<dc:creator><![CDATA[Martin Maletinsky]]></dc:creator>
		<pubDate>Mon, 22 Apr 2013 20:18:17 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-54895</guid>
		<description><![CDATA[Hello Jonathan,

On page 197 you mention &quot;vanish&quot; as one of the possibilities what a parse call can do. Does this refer to other possibilities than the PL/SQL cursor cache (where cursors are held open imlicitly). This might be inferred from the phrasing &quot;particlularly from pl/sql code&quot; (which seems to suggest that there are other possibilities in addition to the PL/SQL cursor cache). If so, could you please tell me what possibilities you were thinking of? Otherwise this first point would be the same as the fourth point where you mention the PL/SQL cache explicitly? 

thank you
kind regards
Martin]]></description>
		<content:encoded><![CDATA[<p>Hello Jonathan,</p>
<p>On page 197 you mention &#8220;vanish&#8221; as one of the possibilities what a parse call can do. Does this refer to other possibilities than the PL/SQL cursor cache (where cursors are held open imlicitly). This might be inferred from the phrasing &#8220;particlularly from pl/sql code&#8221; (which seems to suggest that there are other possibilities in addition to the PL/SQL cursor cache). If so, could you please tell me what possibilities you were thinking of? Otherwise this first point would be the same as the fourth point where you mention the PL/SQL cache explicitly? </p>
<p>thank you<br />
kind regards<br />
Martin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sasa Petkovic</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-49349</link>
		<dc:creator><![CDATA[Sasa Petkovic]]></dc:creator>
		<pubDate>Thu, 23 Aug 2012 08:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-49349</guid>
		<description><![CDATA[Hello,

I have managed to repeat this behaviour only in EE 9.2.0.8 while on EE 10.2.0.4 and 11.2.0.3 was working as expected ie to show one executions after flushing shared pool.

Regards,
Sasa]]></description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>I have managed to repeat this behaviour only in EE 9.2.0.8 while on EE 10.2.0.4 and 11.2.0.3 was working as expected ie to show one executions after flushing shared pool.</p>
<p>Regards,<br />
Sasa</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-45166</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sun, 26 Feb 2012 16:06:26 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-45166</guid>
		<description><![CDATA[Vishal,

I can&#039;t reproduce your results. You had &quot;alter session flush shared_pool&quot;, by the way, but I assume this was a typo, so I&#039;ve corrected it.

After the flush shared pool, I found that v$sql and v$sqlarea had been flushed, but v$sqlstats still showed the statement with 100 executions. After running the statement one more time, all three of them showed one execution.  (This was 11.2.0.3 on Windows XP Pro 32-bit.)]]></description>
		<content:encoded><![CDATA[<p>Vishal,</p>
<p>I can&#8217;t reproduce your results. You had &#8220;alter session flush shared_pool&#8221;, by the way, but I assume this was a typo, so I&#8217;ve corrected it.</p>
<p>After the flush shared pool, I found that v$sql and v$sqlarea had been flushed, but v$sqlstats still showed the statement with 100 executions. After running the statement one more time, all three of them showed one execution.  (This was 11.2.0.3 on Windows XP Pro 32-bit.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishal</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-45076</link>
		<dc:creator><![CDATA[Vishal]]></dc:creator>
		<pubDate>Fri, 17 Feb 2012 16:03:15 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-45076</guid>
		<description><![CDATA[Hi &quot;Sir&quot; Jonathan 

Looks like in 11.2.0.3 , session_cached_cursors behave differently than in the earlier patchsets/versions.
Here is a small test case.
[sourcecode]
###

Create table test (a number);
Insert into test values(1);
commit;

-- Session Cached Cursor is set to 100.

-- Run this SELECT 100 times.
SELECT * FROM TEST WHERE A=1 ;

SELECT EXECUTIONS FROM V$SQLAREA WHERE SQL_TEXT=&#039;SELECT * FROM TEST WHERE A=1&#039;;

Output
=======
100 

(This is expected)
[/sourcecode]
Hold on , don&#039;t exit this session. Now flush the shared pool
[sourcecode]
ALTER SYSTEM FLUSH SHARED_POOL;

SELECT EXECUTIONS FROM V$SQLAREA WHERE SQL_TEXT=&#039;SELECT * FROM TEST WHERE A=1&#039;;

Output
=======

No rows selected 
[/sourcecode]
(This is expected)

Now , run the same select statement just once.
[sourcecode]
SELECT * FROM TEST WHERE A=1 ;

SELECT EXECUTIONS FROM V$SQLAREA WHERE SQL_TEXT=&#039;SELECT * FROM TEST WHERE A=1&#039;;

Output
=======
101 
[/sourcecode]
V$SQLAREA now shows 101 executions. But the fact of the matter is that the previous 100 executions 
have been flushed out of the shared pool. So , this count should be 1 .
I notice this behavior only in 11.2.0.3 and not in the earlier patchsets/versions.

Further , if I set session_cached_cursor=0 ,
I don&#039;t get the same issue. I correctly see the execution count as 1 

Best Regards,
Vishal]]></description>
		<content:encoded><![CDATA[<p>Hi &#8220;Sir&#8221; Jonathan </p>
<p>Looks like in 11.2.0.3 , session_cached_cursors behave differently than in the earlier patchsets/versions.<br />
Here is a small test case.</p>
<pre class="brush: plain; title: ; notranslate">
###

Create table test (a number);
Insert into test values(1);
commit;

-- Session Cached Cursor is set to 100.

-- Run this SELECT 100 times.
SELECT * FROM TEST WHERE A=1 ;

SELECT EXECUTIONS FROM V$SQLAREA WHERE SQL_TEXT='SELECT * FROM TEST WHERE A=1';

Output
=======
100 

(This is expected)
</pre>
<p>Hold on , don&#8217;t exit this session. Now flush the shared pool</p>
<pre class="brush: plain; title: ; notranslate">
ALTER SYSTEM FLUSH SHARED_POOL;

SELECT EXECUTIONS FROM V$SQLAREA WHERE SQL_TEXT='SELECT * FROM TEST WHERE A=1';

Output
=======

No rows selected 
</pre>
<p>(This is expected)</p>
<p>Now , run the same select statement just once.</p>
<pre class="brush: plain; title: ; notranslate">
SELECT * FROM TEST WHERE A=1 ;

SELECT EXECUTIONS FROM V$SQLAREA WHERE SQL_TEXT='SELECT * FROM TEST WHERE A=1';

Output
=======
101 
</pre>
<p>V$SQLAREA now shows 101 executions. But the fact of the matter is that the previous 100 executions<br />
have been flushed out of the shared pool. So , this count should be 1 .<br />
I notice this behavior only in 11.2.0.3 and not in the earlier patchsets/versions.</p>
<p>Further , if I set session_cached_cursor=0 ,<br />
I don&#8217;t get the same issue. I correctly see the execution count as 1 </p>
<p>Best Regards,<br />
Vishal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-43746</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Thu, 29 Dec 2011 14:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-43746</guid>
		<description><![CDATA[Jonathan,

Thank you for providing the output summary for your core_dc_activity_01.sql script.  I examined the script while reading the book and noticed that there was a single result (likely one column selected, one predicate) for 10.2.0.3 and 11g included in the script file.  Prior to posting this potential errata item, I had not created your snap_latch_child and snap_rowcache packages in a test database, so I did not execute the test script to confirm that the number of dc_histogram_defs gets was dependent on the number of columns in the SELECT clause.  Logic reasoning suggested that there should be some form of increase in the dictionary cache gets to obtain the column definition and average row lengths of the selected columns, but it did not seem reasonable that dc_histogram_defs would show an increase in the number of gets.

After seeing your comment, I created the snap_latch_child and snap_rowcache packages in a test database and experimented a bit with the core_dc_activity_01.sql script.  I am able to reproduce the 2,000, 3,000, 3,000, and 4,000 results that you provided, so the statement in the book is correct.

I made several slight adjustments to your script.  Below is output (modified to show just the snap_rowcache.end_snap output) when selecting all four columns with either two columns listed in the WHERE clause or a single column in the WHERE clause.  In both cases there were 4,000 gets of dc_histogram_defs (only when hard parses were required):
[code]
SQL&gt; prompt	select four columns with two predicates
SQL&gt; declare
  2  	m_n	number;
  3  	m_v	varchar2(10);
  4          m_m2    varchar2(100);
  5          m_id    number;
  6  begin
  7  	for i in 1..1000 loop
  8  		execute immediate
  9  			&#039;select n1, v1, padding, id from t1 where padding = rpad(&#039;&#039;x&#039;&#039;,100) and id = &#039; &#124;&#124; i
 10  			into m_n, m_v, m_m2, m_id;
 11  	end loop;
 12  end;
 13  /
 
PL/SQL procedure successfully completed.
 
SQL&gt; execute snap_rowcache.end_snap
---------------------------------
Dictionary Cache - 28-Dec 22:39:52
Interval:-      0 seconds
---------------------------------
Parameter                 Usage Fixed    Gets  Misses   Scans  Misses    Comp    Mods Flushes
---------                 ----- -----    ----  ------   -----  --------------    ---- -------
dc_segments                   0     0   4,000       0       0       0       0       0       0
dc_users                      0     0   3,000       0       0       0       0       0       0
dc_objects                    0     0   4,013       0       0       0       0       0       0
dc_global_oids                0     0      12       0       0       0       0       0       0
dc_histogram_defs             0     0   4,000       0       0       0       0       0       0
dc_object_grants              0     0      20       0       0       0       0       0       0
 
PL/SQL procedure successfully completed.
[/code]
 
[code]
SQL&gt; prompt	select four columns with one predicate
SQL&gt; declare
  2  	m_n	number;
  3  	m_v	varchar2(10);
  4          m_m2    varchar2(100);
  5          m_id    number;
  6  begin
  7  	for i in 1..1000 loop
  8  		execute immediate
  9  			&#039;select n1, v1, padding, id from t1 where id = &#039; &#124;&#124; i
 10  			into m_n, m_v, m_m2, m_id;
 11  	end loop;
 12  end;
 13  /
 
PL/SQL procedure successfully completed.
 
SQL&gt; execute snap_rowcache.end_snap
---------------------------------
Dictionary Cache - 28-Dec 22:39:53
Interval:-      0 seconds
---------------------------------
Parameter                 Usage Fixed    Gets  Misses   Scans  Misses    Comp    Mods Flushes
---------                 ----- -----    ----  ------   -----  --------------    ---- -------
dc_segments                   0     0   4,000       0       0       0       0       0       0
dc_users                      0     0   3,000       0       0       0       0       0       0
dc_objects                    0     0   4,012       0       0       0       0       0       0
dc_global_oids                0     0      12       0       0       0       0       0       0
dc_histogram_defs             0     0   4,000       0       0       0       0       0       0
global database name          0     0       2       0       0       0       0       0       0
 
PL/SQL procedure successfully completed.
[/code]]]></description>
		<content:encoded><![CDATA[<p>Jonathan,</p>
<p>Thank you for providing the output summary for your core_dc_activity_01.sql script.  I examined the script while reading the book and noticed that there was a single result (likely one column selected, one predicate) for 10.2.0.3 and 11g included in the script file.  Prior to posting this potential errata item, I had not created your snap_latch_child and snap_rowcache packages in a test database, so I did not execute the test script to confirm that the number of dc_histogram_defs gets was dependent on the number of columns in the SELECT clause.  Logic reasoning suggested that there should be some form of increase in the dictionary cache gets to obtain the column definition and average row lengths of the selected columns, but it did not seem reasonable that dc_histogram_defs would show an increase in the number of gets.</p>
<p>After seeing your comment, I created the snap_latch_child and snap_rowcache packages in a test database and experimented a bit with the core_dc_activity_01.sql script.  I am able to reproduce the 2,000, 3,000, 3,000, and 4,000 results that you provided, so the statement in the book is correct.</p>
<p>I made several slight adjustments to your script.  Below is output (modified to show just the snap_rowcache.end_snap output) when selecting all four columns with either two columns listed in the WHERE clause or a single column in the WHERE clause.  In both cases there were 4,000 gets of dc_histogram_defs (only when hard parses were required):</p>
<pre class="brush: plain; title: ; notranslate">
SQL&gt; prompt	select four columns with two predicates
SQL&gt; declare
  2  	m_n	number;
  3  	m_v	varchar2(10);
  4          m_m2    varchar2(100);
  5          m_id    number;
  6  begin
  7  	for i in 1..1000 loop
  8  		execute immediate
  9  			'select n1, v1, padding, id from t1 where padding = rpad(''x'',100) and id = ' || i
 10  			into m_n, m_v, m_m2, m_id;
 11  	end loop;
 12  end;
 13  /
 
PL/SQL procedure successfully completed.
 
SQL&gt; execute snap_rowcache.end_snap
---------------------------------
Dictionary Cache - 28-Dec 22:39:52
Interval:-      0 seconds
---------------------------------
Parameter                 Usage Fixed    Gets  Misses   Scans  Misses    Comp    Mods Flushes
---------                 ----- -----    ----  ------   -----  --------------    ---- -------
dc_segments                   0     0   4,000       0       0       0       0       0       0
dc_users                      0     0   3,000       0       0       0       0       0       0
dc_objects                    0     0   4,013       0       0       0       0       0       0
dc_global_oids                0     0      12       0       0       0       0       0       0
dc_histogram_defs             0     0   4,000       0       0       0       0       0       0
dc_object_grants              0     0      20       0       0       0       0       0       0
 
PL/SQL procedure successfully completed.
</pre>
<pre class="brush: plain; title: ; notranslate">
SQL&gt; prompt	select four columns with one predicate
SQL&gt; declare
  2  	m_n	number;
  3  	m_v	varchar2(10);
  4          m_m2    varchar2(100);
  5          m_id    number;
  6  begin
  7  	for i in 1..1000 loop
  8  		execute immediate
  9  			'select n1, v1, padding, id from t1 where id = ' || i
 10  			into m_n, m_v, m_m2, m_id;
 11  	end loop;
 12  end;
 13  /
 
PL/SQL procedure successfully completed.
 
SQL&gt; execute snap_rowcache.end_snap
---------------------------------
Dictionary Cache - 28-Dec 22:39:53
Interval:-      0 seconds
---------------------------------
Parameter                 Usage Fixed    Gets  Misses   Scans  Misses    Comp    Mods Flushes
---------                 ----- -----    ----  ------   -----  --------------    ---- -------
dc_segments                   0     0   4,000       0       0       0       0       0       0
dc_users                      0     0   3,000       0       0       0       0       0       0
dc_objects                    0     0   4,012       0       0       0       0       0       0
dc_global_oids                0     0      12       0       0       0       0       0       0
dc_histogram_defs             0     0   4,000       0       0       0       0       0       0
global database name          0     0       2       0       0       0       0       0       0
 
PL/SQL procedure successfully completed.
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/oracle-core/oc-7-parsing-and-optimising/#comment-43712</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Wed, 28 Dec 2011 21:33:55 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?page_id=7145#comment-43712</guid>
		<description><![CDATA[Charles,

The script (core_dc_activity_01.sql) goes through four variations of query, ending with:
[sourcecode][/sourcecode]
select  n1, v1 
from    t1 
where   padding = rpad(&#039;x&#039;,100) 
and     id = {constant}
[sourcecode][/sourcecode]

Note that the columns in the select list are not the ones used in the where clause. 

The four variants tested by the script were:  
&lt;blockquote&gt;
one column selected, one predicate
one column selected, two predicates
two columns selected, one predicate,
two columns selected, two predicates
&lt;/blockquote&gt;

The number of gets on the dictionary cache entry &lt;b&gt;dc_histogram_defs&lt;/b&gt; (in 10.2.0.3) were
&lt;blockquote&gt;
2,000
3,000
3,000
4,000
&lt;/blockquote&gt;
suggesting that every column referenced in the query - whether in the select list or the where clause - requires dictionary access.

Perhaps if I had included multiple sets of the results my claim would have been clearer, but I was concerned that this would result in a fairly large section of repetitious text for a small increase in information content.]]></description>
		<content:encoded><![CDATA[<p>Charles,</p>
<p>The script (core_dc_activity_01.sql) goes through four variations of query, ending with:</p>
<p>select  n1, v1<br />
from    t1<br />
where   padding = rpad(&#8216;x&#8217;,100)<br />
and     id = {constant}</p>
<p>Note that the columns in the select list are not the ones used in the where clause. </p>
<p>The four variants tested by the script were:  </p>
<blockquote><p>
one column selected, one predicate<br />
one column selected, two predicates<br />
two columns selected, one predicate,<br />
two columns selected, two predicates
</p></blockquote>
<p>The number of gets on the dictionary cache entry <b>dc_histogram_defs</b> (in 10.2.0.3) were</p>
<blockquote><p>
2,000<br />
3,000<br />
3,000<br />
4,000
</p></blockquote>
<p>suggesting that every column referenced in the query &#8211; whether in the select list or the where clause &#8211; requires dictionary access.</p>
<p>Perhaps if I had included multiple sets of the results my claim would have been clearer, but I was concerned that this would result in a fairly large section of repetitious text for a small increase in information content.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
