<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tanel Poder's blog: Core IT for Geeks and Pros &#187; Tools</title>
	<atom:link href="http://blog.tanelpoder.com/category/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tanelpoder.com</link>
	<description>Oracle troubleshooting, internals and performance tuning</description>
	<lastBuildDate>Sat, 31 Jul 2010 05:44:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The full power of Oracle&#8217;s diagnostic events, part 2: ORADEBUG DOC and 11g improvements</title>
		<link>http://blog.tanelpoder.com/2010/06/23/the-full-power-of-oracles-diagnostic-events-part-2-oradebug-doc-and-11g-improvements/</link>
		<comments>http://blog.tanelpoder.com/2010/06/23/the-full-power-of-oracles-diagnostic-events-part-2-oradebug-doc-and-11g-improvements/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 11:46:31 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Cool stuff]]></category>
		<category><![CDATA[Internals]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle 11g]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=697</guid>
		<description><![CDATA[I haven&#8217;t written any blog entries for a while, so here&#8217;s a very sweet treat for low-level Oracle troubleshooters and internals geeks out there :) Over a year ago I wrote that Oracle 11g has a completely new low-level kernel diagnostics &#38; tracing infrastructure built in to it. I wanted to write a longer article [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t written any blog entries for a while, so here&#8217;s a very sweet treat for low-level Oracle troubleshooters and internals geeks out there :)</p>
<p>Over a year ago <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOS8wMy8wMy90aGUtZnVsbC1wb3dlci1vZi1vcmFjbGVzLWRpYWdub3N0aWMtZXZlbnRzLXBhcnQtMS1zeW50YXgtZm9yLWtzZC1kZWJ1Zy1ldmVudC1oYW5kbGluZy8=" target=\"_blank\">I wrote</a> that Oracle 11g has a completely new low-level kernel diagnostics &amp; tracing infrastructure built in to it. I wanted to write a longer article about it with comprehensive examples and use cases, but by now I realize I won&#8217;t ever have time for this, so I&#8217;ll just point you to the right direction :)</p>
<p>Basically, since 11g, you can use SQL_Trace, kernel undocumented traces, various dumps and other actions at much better granularity than before.</p>
<p>For example, you can enable SQL_Trace for a specific SQL_ID only:</p>
<pre>SQL&gt; alter session set events 'sql_trace[<strong>SQL: 32cqz71gd8wy3</strong>] 
<span style="font-size: 11.6667px;">{<strong>pgadep: exactdepth 0</strong>} {<strong>callstack: fname opiexe</strong>}
plan_stat=all_executions,wait=true,bind=true';</span>
<span style="font-size: 11.6667px;">
</span>
<span style="font-size: 11.6667px;">Session altered.</span></pre>
<p><span style="font-size: 13.3333px;">Actually I have done more in above example, I have also said that trace only when the PGA depth (the dep= in tracefile) is zero. This means that trace only top-level calls, issued directly by the client application and not recursively by some PL/SQL or by dictionary cache layer. Additionally I have added a check whether we are currently servicing opiexe function (whether the current call stack contains opiexe as a (grand)parent function) &#8211; this allows to trace &amp; dump only in specific cases of interest!</span></p>
<p>The syntax is actually more powerful than that, in this example I&#8217;m running kernel tracing for a kernel component plus instructing Oracle to dump various other things at level 1 (callstack,process state and query block debug info) whenever a tracepoint (event) in the SQL Transformation component family is hit:</p>
<pre>SQL&gt; alter session set events 'trace[<strong>RDBMS.SQL_Transform</strong>] <span style="font-size: 11.6667px;">[<strong>SQL: 32cqz71gd8wy3</strong>]
disk=high <strong>RDBMS.query_block_dump(1) processstate(1) callstack(1)</strong>';</span>
<span style="font-size: 11.6667px;">
</span>
<span style="font-size: 11.6667px;">Session altered.</span></pre>
<p>And by now you are probably asking that where is this syntax formally documented? Google and MOS searches don&#8217;t return anything useful. Well, as with many other things, a good reference is stored within Oracle kernel itself!</p>
<p>Just log on as sysdba and type ORADEBUG DOC:</p>
<p><strong>ORADEBUG DOC</strong></p>
<pre>SQL&gt; oradebug doc</pre>
<pre>Internal Documentation
<span style="font-size: 11.6667px;">**********************
</span><span style="font-size: 11.6667px;">EVENT                           Help on events (syntax, event list, ...)
</span><span style="font-size: 11.6667px;">COMPONENT       [&lt;comp_name&gt;]   List all components or describe &lt;comp_name&gt;</span></pre>
<p>This gives you the index page, now you can navigate on by running ORADEBUG DOC EVENT and take it from there. There&#8217;s lots of documentation there!</p>
<p><span style="font-size: 13.3333px;">I have put the output with some comments and examples into my website too:</span></p>
<p><span style="font-size: 13.3333px;"><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlL3Ryb3VibGVzaG9vdGluZy9vcmFkZWJ1Zy1kb2M=" target=\"_blank\">http://tech.e2sn.com/oracle/troubleshooting/oradebug-doc</a></span></p>
<p>Note that this feature is quite fresh, almost not used at all in the real (production) world, so I consider this quite experimental. I have managed to crash my session with some tests, so take the usual advice about any undocumented stuff (and oradebug) &#8211; don&#8217;t use it in production without thinking first and if you do use it, then use it at your own risk!</p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F06%2F23%2Fthe-full-power-of-oracles-diagnostic-events-part-2-oradebug-doc-and-11g-improvements%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=697" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/06/23/the-full-power-of-oracles-diagnostic-events-part-2-oradebug-doc-and-11g-improvements/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Flexible Sqlplus command line history with RLWRAP</title>
		<link>http://blog.tanelpoder.com/2010/05/07/flexible-sqlplus-command-line-history-with-rlwrap/</link>
		<comments>http://blog.tanelpoder.com/2010/05/07/flexible-sqlplus-command-line-history-with-rlwrap/#comments</comments>
		<pubDate>Fri, 07 May 2010 22:49:26 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Cool stuff]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=690</guid>
		<description><![CDATA[At Hotsos Symposium Training Day I used rlwrap with sqlplus &#8211; which gives nice command line editing and history capabilities for tools like sqlplus. Additionally I pre-generated commonly used Oracle keywords, data dictionary view and package names into rlwrap wordfile, so I got nice tab-completion too. Sqlplus sucks much less with rlwrap ;-) It&#8217;s relatively [...]]]></description>
			<content:encoded><![CDATA[<p>At Hotsos Symposium Training Day I used rlwrap with sqlplus &#8211; which gives nice command line editing and history capabilities for tools like sqlplus. Additionally I pre-generated commonly used Oracle keywords, data dictionary view and package names into rlwrap wordfile, so I got nice tab-completion too. Sqlplus sucks much less with rlwrap ;-)</p>
<p>It&#8217;s relatively easy to install rlwrap on Unix (there are rlwrap RPMs out there, Solaris freeware packages and I installed it on Mac via macports.org). Just google around&#8230;</p>
<p>You can have rlwrap on Windows too &#8211; As rlwrap has been coded for Unix flavors, then on Windows you need to run it on a Unix library environment emulator &#8211; like Cygwin.</p>
<p>Dave Herring and Michael Paddock have both written an article about how to get rlwrap &amp; sqlplus running on Windows, check out the articles here. It&#8217;s worth reading both as they have different additions&#8230;</p>
<p>So, if you want command line history, search and tab completion for sqlplus on Unix flavors or Windows, check these articles out!</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RhdmVoZXJyaW5nc2RiYWJsb2cuYmxvZ3Nwb3QuY29tLzIwMTAvMDMvc3FscGx1cy1jb21tYW5kLWhpc3Rvcnktd2l0aC1jeWd3aW4uaHRtbA==">http://daveherringsdbablog.blogspot.com/2010/03/sqlplus-command-history-with-cygwin.html</a></p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuZW5raXRlYy5jb20vMjAxMC8wNC8yOS91c2luZy1zcWxwbHVzLXdpdGgtcmx3cmFwLW9uLW1zLXdpbmRvd3Mv">http://blog.enkitec.com/2010/04/29/using-sqlplus-with-rlwrap-on-ms-windows/</a></p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F05%2F07%2Fflexible-sqlplus-command-line-history-with-rlwrap%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=690" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/05/07/flexible-sqlplus-command-line-history-with-rlwrap/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Oracle Latch Contention Troubleshooting</title>
		<link>http://blog.tanelpoder.com/2010/03/27/oracle-latch-contention-troubleshooting/</link>
		<comments>http://blog.tanelpoder.com/2010/03/27/oracle-latch-contention-troubleshooting/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 04:46:08 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Cool stuff]]></category>
		<category><![CDATA[Internals]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Tuning]]></category>
		<category><![CDATA[contention]]></category>
		<category><![CDATA[latch]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[systematic]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=658</guid>
		<description><![CDATA[I wrote a latch contention troubleshooting article for IOUG Select journal last year (it was published earlier this year). I have uploaded this to tech.E2SN too, I recommend you to read it if you want to become systematic about latch contention troubleshooting: http://tech.e2sn.com/oracle/troubleshooting I&#8217;m working on getting the commenting &#038; feedback work at tech.E2SN site [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a latch contention troubleshooting article for IOUG Select journal last year (it was published earlier this year). I have uploaded this to tech.E2SN too, I recommend you to read it if you want to become systematic about latch contention troubleshooting:</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlL3Ryb3VibGVzaG9vdGluZw==">http://tech.e2sn.com/oracle/troubleshooting</a></p>
<p>I&#8217;m working on getting the commenting &#038; feedback work at tech.E2SN site too, but for now you can comment here at this blog entry&#8230;</p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F03%2F27%2Foracle-latch-contention-troubleshooting%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=658" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/03/27/oracle-latch-contention-troubleshooting/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Session Snapper v3.11 &#8211; bugfix update &#8211; now ASH report works properly on Oracle 10.1 too</title>
		<link>http://blog.tanelpoder.com/2010/03/27/session-snapper-v3-11-bugfix-update-now-ash-report-works-properly-on-oracle-10-1-too/</link>
		<comments>http://blog.tanelpoder.com/2010/03/27/session-snapper-v3-11-bugfix-update-now-ash-report-works-properly-on-oracle-10-1-too/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 15:40:34 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Tuning]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[snapper]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=655</guid>
		<description><![CDATA[This is an updated version of Snapper, which works ok on Oracle 10.1 now as well (9i support is coming some time in the future :) Thanks to Jamey Johnston for sending me the fix info (and saving me some time that way :) So if you have some problems with Snapper on Oracle 10.1, [...]]]></description>
			<content:encoded><![CDATA[<p>This is an updated version of Snapper, which works ok on Oracle 10.1 now as well (9i support is coming some time in the future :)</p>
<p>Thanks to Jamey Johnston for sending me the fix info (and saving me some time that way :)</p>
<p>So if you have some problems with Snapper on Oracle 10.1, please make sure you have the latest version v3.11, which you can get from here:</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXNjcmlwdHMtYW5kLXRvb2xzL3Nlc3Npb24tc25hcHBlcg==">http://tech.e2sn.com/oracle-scripts-and-tools/session-snapper</a></p>
<p>The output below is from Snapper 3.11 on Oracle 10.1.0.5, the ASH columns in the bottom part of the output are displayed correctly now:</p>
<pre>SQL&gt; @snapper ash,ash1,ash2,ash3,stats,gather=t 15 1 all
Sampling with interval 15 seconds, 1 times...

-- Session Snapper v3.11 by Tanel Poder @ E2SN ( http://tech.e2sn.com )

----------------------------------------------------------------------------------------------------------------------
    SID, USERNAME  , TYPE, STATISTIC                               ,         DELTA, HDELTA/SEC,    %TIME, GRAPH
----------------------------------------------------------------------------------------------------------------------
     52, SYSTEM    , TIME, PL/SQL execution elapsed time           ,         53968,      3.6ms,      .4%, |          |
     52, SYSTEM    , TIME, DB CPU                                  ,         10000,   666.67us,      .1%, |          |
     52, SYSTEM    , TIME, sql execute elapsed time                ,        118225,     7.88ms,      .8%, |@         |
     52, SYSTEM    , TIME, DB time                                 ,        118632,     7.91ms,      .8%, |@         |
     54, SYSTEM    , TIME, hard parse elapsed time                 ,        289905,    19.33ms,     1.9%, |@         |
     54, SYSTEM    , TIME, parse time elapsed                      ,        528034,     35.2ms,     3.5%, |@         |
     54, SYSTEM    , TIME, PL/SQL execution elapsed time           ,       5010579,   334.04ms,    33.4%, |@@@@      |
     54, SYSTEM    , TIME, DB CPU                                  ,      10660000,   710.67ms,    71.1%, |@@@@@@@@  |
     54, SYSTEM    , TIME, sql execute elapsed time                ,      12920952,    861.4ms,    86.1%, |@@@@@@@@@ |
     54, SYSTEM    , TIME, DB time                                 ,      12937606,   862.51ms,    86.3%, |@@@@@@@@@ |
     54, SYSTEM    , TIME, sequence load elapsed time              ,          1079,    71.93us,      .0%, |          |
     56, (MMNL)    , TIME, background cpu time                     ,           940,    62.67us,      .0%, |          |
     56, (MMNL)    , TIME, background elapsed time                 ,           940,    62.67us,      .0%, |          |
     58, (MMON)    , TIME, background cpu time                     ,           158,    10.53us,      .0%, |          |
     58, (MMON)    , TIME, background elapsed time                 ,           158,    10.53us,      .0%, |          |
     64, (RBAL)    , TIME, background cpu time                     ,            86,     5.73us,      .0%, |          |
     64, (RBAL)    , TIME, background elapsed time                 ,            86,     5.73us,      .0%, |          |
     68, (CJQ0)    , TIME, background cpu time                     ,           820,    54.67us,      .0%, |          |
     68, (CJQ0)    , TIME, background elapsed time                 ,           820,    54.67us,      .0%, |          |
     70, (SMON)    , TIME, background cpu time                     ,           141,      9.4us,      .0%, |          |
     70, (SMON)    , TIME, background elapsed time                 ,           141,      9.4us,      .0%, |          |
     71, (CKPT)    , TIME, background cpu time                     ,         14515,   967.67us,      .1%, |          |
     71, (CKPT)    , TIME, background elapsed time                 ,         14515,   967.67us,      .1%, |          |
     72, (LGWR)    , TIME, background cpu time                     ,       1530000,      102ms,    10.2%, |@         |
     72, (LGWR)    , TIME, background elapsed time                 ,       1954778,   130.32ms,    13.0%, |@@        |
     73, (DBW0)    , TIME, background cpu time                     ,         10000,   666.67us,      .1%, |          |
     73, (DBW0)    , TIME, background elapsed time                 ,        268787,    17.92ms,     1.8%, |@         |
     74, (MMAN)    , TIME, background cpu time                     ,           141,      9.4us,      .0%, |          |
     74, (MMAN)    , TIME, background elapsed time                 ,           141,      9.4us,      .0%, |          |
     75, (PMON)    , TIME, background cpu time                     ,          1636,   109.07us,      .0%, |          |
     75, (PMON)    , TIME, background elapsed time                 ,          1636,   109.07us,      .0%, |          |
--  End of Stats snap 1, end=2010-03-27 16:37:13, seconds=15

-----------------------------------------------------------------------
Active% | SQL_ID          | EVENT                     | WAIT_CLASS
-----------------------------------------------------------------------
    61% | 6d0z2j01c8ytc   | ON CPU                    | ON CPU
    22% |                 | log file parallel write   | System I/O
     7% | 6d0z2j01c8ytc   | db file sequential read   | User I/O
     3% | 0zkt25f36kbzd   | ON CPU                    | ON CPU
     3% |                 | db file parallel write    | System I/O
     2% | g1xapjmt4vm5c   | ON CPU                    | ON CPU
     2% |                 | ON CPU                    | ON CPU
     2% | gaxwgwd72b3pn   | ON CPU                    | ON CPU
     1% | 4ftbahd08ab2a   | ON CPU                    | ON CPU
     1% | c69wrxcndxuzw   | ON CPU                    | ON CPU

-----------------------------------------------------
Active% | EVENT                     | WAIT_CLASS
-----------------------------------------------------
    76% | ON CPU                    | ON CPU
    22% | log file parallel write   | System I/O
     9% | db file sequential read   | User I/O
     3% | db file parallel write    | System I/O
     3% | db file scattered read    | User I/O
     1% | direct path write temp    | User I/O

----------------------------------
Active% |    SID | SQL_ID
----------------------------------
    69% |     54 | 6d0z2j01c8ytc
    23% |     72 |
     3% |     54 | 0zkt25f36kbzd
     3% |     73 |
     3% |     54 | 8qs4shjvhk2w4
     2% |     54 | g1xapjmt4vm5c
     2% |     54 | gaxwgwd72b3pn
     1% |     54 | 3w6304ztrww4h
     1% |     54 | b86h705svfmjz
     1% |     54 | drppqann6dwfa

---------------------------------------------------
Active% | PLSQL_OBJE | PLSQL_SUBP | SQL_ID
---------------------------------------------------
    69% | N/A        | N/A        | 6d0z2j01c8ytc
    27% | N/A        | N/A        |
     3% | N/A        | N/A        | 0zkt25f36kbzd
     3% | N/A        | N/A        | 8qs4shjvhk2w4
     2% | N/A        | N/A        | g1xapjmt4vm5c
     2% | N/A        | N/A        | gaxwgwd72b3pn
     1% | N/A        | N/A        | 3w6304ztrww4h
     1% | N/A        | N/A        | b86h705svfmjz
     1% | N/A        | N/A        | drppqann6dwfa
     1% | N/A        | N/A        | c69wrxcndxuzw

--  End of ASH snap 1, end=2010-03-27 16:37:13, seconds=15, samples_taken=96

PL/SQL procedure successfully completed.

SQL&gt;</pre>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F03%2F27%2Fsession-snapper-v3-11-bugfix-update-now-ash-report-works-properly-on-oracle-10-1-too%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=655" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/03/27/session-snapper-v3-11-bugfix-update-now-ash-report-works-properly-on-oracle-10-1-too/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Oracle Session Snapper v3.10</title>
		<link>http://blog.tanelpoder.com/2010/03/22/oracle-session-snapper-v3-10/</link>
		<comments>http://blog.tanelpoder.com/2010/03/22/oracle-session-snapper-v3-10/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 16:35:50 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=639</guid>
		<description><![CDATA[Hi all, long time no see!  =8-) Now as I&#8217;m done with the awesome Hotsos Symposium (and the training day which I delivered) and have got some rest, I&#8217;ll start publishing some of the cool things I&#8217;ve been working on over the past half a year or so. The first is Oracle Session Snapper version [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all, long time no see!  =8-)</p>
<p>Now as I&#8217;m done with the awesome Hotsos Symposium (and the training day which I delivered) and have got some rest, I&#8217;ll start publishing some of the cool things I&#8217;ve been working on over the past half a year or so.</p>
<p>The first is Oracle Session Snapper version 3!</p>
<p>There are some major improvements in Snapper 3, like ASH style session activity sampling!</p>
<p>When you troubleshoot a session&#8217;s performance (or instance performance) then the main things you want to know first are very very simple:</p>
<ol>
<li>Which SQL statements are being executed</li>
<li>What are they doing, are they working on CPU or waiting.</li>
<li>If waiting, then for what</li>
</ol>
<p>Often this is enough for troubleshooting what&#8217;s wrong. For example, if a session is waiting for a lock, then wait interface will show you that. If a single SQL statement is taking 99% of total response time, the V$SESSION (ASH style) samples will point out the problem SQL and so on. Simple stuff.</p>
<p>However there are cases where you need to go beyond wait interface and use V$SESSTAT (and other) counters and even take a &#8220;screwdriver&#8221; and open Oracle up from outside by stack tracing :-)</p>
<p>When I wrote the first version of Snapper for my own use some 4-5 years ago I wrote it mainly having the &#8220;beyond wait interface&#8221; part in mind. So I focused on V$SESSTAT and various other counters and left the basic troubleshooting to other tools. I used to manually sample V$SESSION/V$SESSION_WAIT a few times in a row to get a rough overview of what a session was doing or some other special-purpose scripts.</p>
<p>However after Snapper got more popular and I started getting some feedback about it I saw the need for covering more with Snapper, not just the &#8220;beyond wait interface&#8221; part, but also the &#8220;wait interface&#8221; and &#8220;which SQL&#8221; part too.</p>
<p>So, now I&#8217;m presenting Snapper v3 which does all the 3 points above using ASH style V$SESSION sampling and it still has the first step to &#8220;beyond wait interface&#8221; part in it, which is very useful for advanced performance troubleshooting and diagnosis &#8211; I&#8217;m talking about the V$SESSTAT counters above.</p>
<p>I&#8217;ve made some syntax changes in Snapper too and right now the v3 doesn&#8217;t work on Oracle 9.2 (it will work some day :)</p>
<p>To give you an idea of the new ASH style sampling capabilities, heres some example output:</p>
<pre>SQL&gt; @snapper ash=sid+event+wait_class,ash1=plsql_object_id+plsql_subprogram_id+sql_id,ash2=program+module+action 5 1 all
<div id="_mcePaste">Sampling...</div>
<div id="_mcePaste">-- Session Snapper v3.10 by Tanel Poder @ E2SN ( http://tech.e2sn.com )

--------------------------------------------------------------</div>
<div id="_mcePaste">Active% |    SID | EVENT                     | WAIT_CLASS</div>
<div id="_mcePaste">--------------------------------------------------------------
   100% |    133 | db file scattered read    | User I/O
     5% |    165 | control file parallel wri | System I/O
     2% |    162 | ON CPU                    | ON CPU
     2% |    167 | db file parallel write    | System I/O
     2% |    166 | log file parallel write   | System I/O</div>
<div id="_mcePaste">
---------------------------------------------------
Active% | PLSQL_OBJE | PLSQL_SUBP | SQL_ID
---------------------------------------------------
    77% |            |            | a5xyjp9gt796s
    23% |            |            | 4g4u44bk830ms
    12% |            |            |</div>
<div id="_mcePaste">-------------------------------------------------------------------------------------------
Active% | PROGRAM                   | MODULE                    | ACTION
-------------------------------------------------------------------------------------------
100% | sqlplus@mac01 (TNS V1-V3) | sqlplus@mac01 (TNS V1-V3) |
  5% | oracle@solaris02 (CKPT)   |                           |
  2% | oracle@solaris02 (DBW0)   |                           |
  2% | oracle@solaris02 (CJQ0)   |                           |
  2% | oracle@solaris02 (LGWR)   |                           |

--  End of ASH snap 1, end=2010-03-22 17:35:06, seconds=5, samples_taken=43</div>

<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: medium;"><span style="line-height: 22px; white-space: normal;"><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace;"><span style="line-height: 25px; white-space: pre;">
</span></span></span></span></pre>
<p>You can read some usage examples and download it here:</p>
<ul>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXNjcmlwdHMtYW5kLXRvb2xzL3Nlc3Npb24tc25hcHBlcg==" target=\"_blank\">http://tech.e2sn.com/oracle-scripts-and-tools/session-snapper</a></li>
</ul>
<p>P.S. People who attended Hotsos Symposium Training Day where I demoed the initial version of Snapper v3 &#8211; download the new version from above link (v3.10), it&#8217;s much more flexible than the one I demoed couple of weeks ago!</p>
<p><span style="color: #ff0000;"><strong><span style="font-family: monospace; color: #000000;"><span style="font-weight: normal;"><br />
</span></span></strong></span></p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F03%2F22%2Foracle-session-snapper-v3-10%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=639" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/03/22/oracle-session-snapper-v3-10/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>My new website tech.e2sn.com and a new application</title>
		<link>http://blog.tanelpoder.com/2010/01/18/my-new-website-tech-e2sn-com-and-a-new-application/</link>
		<comments>http://blog.tanelpoder.com/2010/01/18/my-new-website-tech-e2sn-com-and-a-new-application/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 18:45:40 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Cool stuff]]></category>
		<category><![CDATA[Internals]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=574</guid>
		<description><![CDATA[In early January I wrote that I&#8217;m gonna start organizing the more serious and practical Oracle content into my new website and I&#8217;ll leave my blog for Oracle hacks, my (IT) observations and philosophy, general thoughts and just fun. It&#8217;s time to publish the newsite now with an application demo rototype which gives some clue [...]]]></description>
			<content:encoded><![CDATA[<p>In early January I wrote that I&#8217;m gonna start organizing the more serious and practical Oracle content into my new website and I&#8217;ll leave my blog for Oracle hacks, my (IT) observations and philosophy, general thoughts and just fun.</p>
<p>It&#8217;s time to publish the newsite now with an application <em>demo rototype</em> which gives some clue of what kind of features will there be in the secret project I&#8217;ve been working on for several months with my friend and business partner.</p>
<p>The website is located here:</p>
<h3><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20=" target=\"_blank\">http://tech.e2sn.com</a></h3>
<p>E2SN <em>does</em> have a meaning, but I&#8217;ll leave it a secret for now ( you are free to guess ;-)</p>
<p>So, there&#8217;s not much technical content at the site yet, but there&#8217;s a cool online app which you should check if you deal with SQL tuning and execution plan analysis much.</p>
<p>It&#8217;s called PlanViz, Oracle Execution Plan Visualization app, you can check it out here:</p>
<h3></h3>
<h3><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vYXBwcy9wbGFudml6Lw==" target=\"_blank\">http://tech.e2sn.com/apps/planviz</a></h3>
<p>Oh, I&#8217;ve also created something called a &#8220;Living Book&#8221; into my website, where I will write about Oracle, performance, troubleshooting, etc. There is also a place where people can request what I should write about there!</p>
<p>And that&#8217;s all for today!</p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F01%2F18%2Fmy-new-website-tech-e2sn-com-and-a-new-application%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=574" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/01/18/my-new-website-tech-e2sn-com-and-a-new-application/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Sometimes things are easy (Part 1): How to fix wrapped execution plan text?</title>
		<link>http://blog.tanelpoder.com/2010/01/18/sometimes-things-are-easy-part-1-how-to-fix-wrapped-execution-plan-text/</link>
		<comments>http://blog.tanelpoder.com/2010/01/18/sometimes-things-are-easy-part-1-how-to-fix-wrapped-execution-plan-text/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 16:26:33 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Unix/Linux]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=568</guid>
		<description><![CDATA[What you see below is a common problem. Someone sends you (or posts to a forum) a wide execution plan, which is unreadable because of wrapped lines. For example, this one below: -------------------------------------------------------------------------------- ------------------- &#124; Id  &#124; Operation                   &#124; Name                    &#124; E-Rows &#124;  OMem &#124; 1Mem &#124; Used-Mem &#124; -------------------------------------------------------------------------------- ------------------- &#124;   0 &#124; SELECT [...]]]></description>
			<content:encoded><![CDATA[<p>What you see below is a common problem. Someone sends you (or posts to a forum) a wide execution plan, which is unreadable because of wrapped lines. For example, this one below:</p>
<pre>--------------------------------------------------------------------------------
-------------------

| Id  | Operation                   | Name                    | E-Rows |  OMem |
 1Mem | Used-Mem |

--------------------------------------------------------------------------------
-------------------

|   0 | SELECT STATEMENT            |                         |        |       |
 |          |

|   1 |  SORT AGGREGATE             |                         |      1 |       |
 |          |

|*  2 |   HASH JOIN                 |                         |     13 |  1102K|
 1102K|  355K (0)|

|*  3 |    HASH JOIN                |                         |     13 |   988K|
 988K|  367K (0)|

|*  4 |     HASH JOIN               |                         |     13 |   921K|
 921K|  621K (0)|

|*  5 |      HASH JOIN OUTER        |                         |     13 |   836K|
 836K| 1224K (0)|

|*  6 |       HASH JOIN             |                         |     13 |   821K|
 821K|  501K (0)|

|*  7 |        HASH JOIN            |                         |     13 |  1102K|
 1102K|  501K (0)|

|   8 |         MERGE JOIN CARTESIAN|                         |      1 |       |
 |          |

|*  9 |          TABLE ACCESS FULL  | PROFILE$                |      1 |       |
 |          |

|  10 |          BUFFER SORT        |                         |      1 | 73728 |
 73728 |          |

|* 11 |           TABLE ACCESS FULL | PROFILE$                |      1 |       |
 |          |

|* 12 |         TABLE ACCESS FULL   | USER$                   |     36 |       |
 |          |

|  13 |        TABLE ACCESS FULL    | PROFNAME$               |      1 |       |
 |          |

|* 14 |       TABLE ACCESS FULL     | RESOURCE_GROUP_MAPPING$ |      1 |       |
 |          |

|  15 |      TABLE ACCESS FULL      | TS$                     |      7 |       |
 |          |

|  16 |     TABLE ACCESS FULL       | TS$                     |      7 |       |
 |          |

|  17 |    TABLE ACCESS FULL        | USER_ASTATUS_MAP        |      9 |       |
 |          |

--------------------------------------------------------------------------------
-------------------
</pre>
<p>So now you either try to manually edit and fix the execution plan text so you could read it or ask the developer to send the execution plan again. Both approaches take time.</p>
<p>Well, sometimes things are easy &#8211; in this particular case I saved the above into a file called /tmp/x and ran the following command:</p>
<pre>$ cat /tmp/x | <strong>awk '{ printf "%s", $0 ; if (NR % 3 == 0) print } END { print }'</strong>
---------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name                    | E-Rows |  OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |                         |        |       | |          |
|   1 |  SORT AGGREGATE             |                         |      1 |       | |          |
|*  2 |   HASH JOIN                 |                         |     13 |  1102K| 1102K|  355K (0)|
|*  3 |    HASH JOIN                |                         |     13 |   988K| 988K|  367K (0)|
|*  4 |     HASH JOIN               |                         |     13 |   921K| 921K|  621K (0)|
|*  5 |      HASH JOIN OUTER        |                         |     13 |   836K| 836K| 1224K (0)|
|*  6 |       HASH JOIN             |                         |     13 |   821K| 821K|  501K (0)|
|*  7 |        HASH JOIN            |                         |     13 |  1102K| 1102K|  501K (0)|
|   8 |         MERGE JOIN CARTESIAN|                         |      1 |       | |          |
|*  9 |          TABLE ACCESS FULL  | PROFILE$                |      1 |       | |          |
|  10 |          BUFFER SORT        |                         |      1 | 73728 | 73728 |          |
|* 11 |           TABLE ACCESS FULL | PROFILE$                |      1 |       | |          |
|* 12 |         TABLE ACCESS FULL   | USER$                   |     36 |       | |          |
|  13 |        TABLE ACCESS FULL    | PROFNAME$               |      1 |       | |          |
|* 14 |       TABLE ACCESS FULL     | RESOURCE_GROUP_MAPPING$ |      1 |       | |          |
|  15 |      TABLE ACCESS FULL      | TS$                     |      7 |       | |          |
|  16 |     TABLE ACCESS FULL       | TS$                     |      7 |       | |          |
|  17 |    TABLE ACCESS FULL        | USER_ASTATUS_MAP        |      9 |       | |          |
---------------------------------------------------------------------------------------------------</pre>
<p>All I did here was that I stripped out line feeds from all lines except every 3rd line (which is the real end of the original line).</p>
<p>Note that if your linesize is very wide (and trimspool/trimout settings are ON) then this script would need some adjustment&#8230;</p>
<p>I&#8217;m sure this trivial approach doesn&#8217;t work in all situations, but with this article I wanted to illustrate that sometimes things which seem hard can be made much easier with a little scripting knowledge. If you are thinking which technology you should learn next &#8211; then better check out a Perl, Python or some shell+AWK book :)</p>
<p>By the way, if you want real flexibility displaying your execution plans (from library cache), then check this out:</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOS8wNS8yNi9zY3JpcHRzLWZvci1zaG93aW5nLWV4ZWN1dGlvbi1wbGFucy12aWEtcGxhaW4tc3FsLWFuZC1hbHNvLWluLW9yYWNsZS05aS8=">http://blog.tanelpoder.com/2009/05/26/scripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i/</a></p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F01%2F18%2Fsometimes-things-are-easy-part-1-how-to-fix-wrapped-execution-plan-text%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=568" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/01/18/sometimes-things-are-easy-part-1-how-to-fix-wrapped-execution-plan-text/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>latch: cache buffers chains latch contention &#8211; a better way for finding the hot block</title>
		<link>http://blog.tanelpoder.com/2009/08/27/latch-cache-buffers-chains-latch-contention-a-better-way-for-finding-the-hot-block/</link>
		<comments>http://blog.tanelpoder.com/2009/08/27/latch-cache-buffers-chains-latch-contention-a-better-way-for-finding-the-hot-block/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 09:37:08 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Cool stuff]]></category>
		<category><![CDATA[Internals]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=417</guid>
		<description><![CDATA[Here&#8217;s a treat for Oracle performance professionals and geeks who are looking for more systematic ways for cache buffers chains (CBC) latch contention troubleshooting. Cache buffers chains latches are taken when a process wants to walk through a cache buffer hash chain, looking if the block with required DBA (data block address) is in buffer [...]]]></description>
			<content:encoded><![CDATA[<p><!--[if !mso]> <mce:style><!  v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} p\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} v\:textbox {display:none;} --> <!--[endif]--></p>
<div>
<p>Here&#8217;s a treat for Oracle performance professionals and geeks who are looking for more systematic ways for cache buffers chains (CBC) latch contention troubleshooting. Cache buffers chains latches are taken when a process wants to walk through a cache buffer hash chain, looking if the block with required DBA (data block address) is in buffer cache. If the block happens to be in cache, then in most cases it has to be pinned first before use and unpinned after use, to make sure no-one else can perform an incompatible operation on that block at the same time. The modification of pin structures (pinning/unpinning) is also protected by CBC latches.</p></div>
<div>
<p>CBC latch contention can happen for multiple reasons, but one reason is that there is some <em>really</em> hot block in a SMP system with high number of CPUs (or CMT system with high number of threads like Sun T-series servers). Sometimes there happen to be multiple moderately hot blocks &#8220;under&#8221; the same CBC latch, which can result in latch contention again.</div>
<div>
<p>Traditionally DBAs used to look up the <strong>child latch address</strong> from V$SESSION_WAIT, sql_trace output or ASH and then look up all buffers protected by that latch from X$BH, using HLADDR column (HLADDR stands for Hash Latch Address). I also have a script for that, <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL2JobGEuc3Fs" target=\"_blank\">bhla.sql</a> (Buffer Headers by Latch Address), which reports me all blocks currently in buffer cache, &#8220;under&#8221; that particular latch and the corresponding data block addresses and object names:</div>
<div><span id="more-417"></span></div>
<pre>SQL&gt; <strong>@bhla </strong>27E5A780  <em>&lt;-- latch address reported by wait interface (Parameter1 in latch: cache buffers chains wait event)</em>

FLG_LRUFLG                 OBJ OBJECT_TYPE         object                                          TCH DBA     
------------------- ---------- ------------------- ---------------------------------------- ---------- ---------
80000:8                      2 TABLE               SYS.SUBCOLTYPE$                                   0 1 7873  
80000:8                      2 TABLE               SYS.ATTRCOL$                                      0 1 7873  
0:0                      50472 INDEX               SYSMAN.MGMT_JOB_EXEC_IDX04                        1 3 27699 
0:0                      50472 INDEX               SYSMAN.MGMT_JOB_EXEC_IDX04                        1 3 27699 
0:4                      50472 INDEX               SYSMAN.MGMT_JOB_EXEC_IDX04                        1 3 27699 
2202000:8                 3710 TABLE               SYS.WRI$_ADV_REC_ACTIONS                          1 3 972   
0:0                      50472 INDEX               SYSMAN.MGMT_JOB_EXEC_IDX04                        1 3 27699 
0:0                      50472 INDEX               SYSMAN.MGMT_JOB_EXEC_IDX04                        1 3 27699 
2202000:8                94227 TABLE PARTITION     SYS.WRH$_ROWCACHE_SUMMARY                         2 3 36142 
80000:8                  54880 INDEX               PERFSTAT.STATS$UNDOSTAT_PK                       <strong>14 </strong>4 118331
0:8                         37 INDEX               SYS.I_OBJ2                                       <strong>24 </strong>1 55591 
2000:8                    3680 TABLE               SYS.WRI$_ADV_TASKS                               <strong>26 </strong>3 739   
0:8                         75 TABLE               SYS.IDL_UB2$                                     <strong>35 </strong>1 11745 
0:8                         73 TABLE               SYS.IDL_UB1$                                     <strong>38 </strong>1 12211</pre>
<p>From above we see that this child latch is protecting many blocks in buffer cache. So which one is the troublemaker? This is where the touchcount (TCH column) has been traditionally used, the higher the TCH the hotter the buffer, right?</p>
<p>Actually this may not always be true. For example if there is a somewhat hot block which has been steadily in buffer cache for weeks, it may have very high touch count. Now if there is an extremely hot block used by every morning&#8217;s batch job (and causing the trouble) but not used later on in the day, this block will get aged out later in the day. Once a block is aged out, its metadata, including TCH is gone! So when the block is loaded back in next morning (causing trouble again), its touch count starts from zero again.</p>
<p>So, by just looking into touchcount numbers you can&#8217;t always reliably detect who&#8217;s the <em>current</em> troublemaker. One option here would be to query the touchcounts, then wait for a minute, query the touchcounts again and see who&#8217;s touchcount increased the most during the minute. This would give a bit better picture about who is causing trouble <em>now.</em></p>
<p>But still, it would not be always reliable for another reason &#8211; touchcounts are incremented only after 3 seconds have passed since last increment! This factor has been coded in to avoid situation such a short but crazy nested loop join hammering a single buffer hundreds of thousands of times in few seconds and then finishing. The buffer wouldn&#8217;t be hot anymore but the touchcount would be hundreds of thousands due a single SQL execution. So, unless 3 seconds (of SGA internal time) has passed since last TCH update, the touchcounts would not be increased during buffer access.</p>
<blockquote><p>This time is controlled by SGA variable <strong>kcbatt_</strong> by the way:</p>
<pre>SQL&gt; oradebug dumpvar sga kcbatt_
ub4 kcbatt_ [3C440F4, 3C440F8) = 0000000<strong>3

</strong></pre>
</blockquote>
<p>This 3-second delay leaves us in the following situation, let say there are 2 blocks protected by a CBC child latch:</p>
<p>One block has been accessed <strong>once every 3 seconds</strong> for 24 hours in a row. A block accessed once per 3 seconds is definitely not a hot block, but its touchcount would be around 28800 (86400 seconds per 24 hours / 3 = 28800).</p>
<p>And there is another block which is accessed crazily for 2 seconds in a row and this happens every 10 seconds. 2 seconds of consecutive access would increase the touchcount by 1. If such access pattern has been going on every 10 seconds over last 24 hours, then the touch count for that buffer would be 86400 / 10 = 8640.</p>
<p>In the first case we can have a very cold block with TCH = 28800 and in second case a very hot block with TCH = 8640 only and this can mislead DBAs to fixing the wrong problem.</p>
<p>Luckily this problem can be solved with LatchProfX :-)</p>
<p>If you don&#8217;t know what LatchProfX is, you may want to read these articles first &#8211; LatchProf gives you a better way for latch contention troubleshooting compared to old approaches:</p>
<ul>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOC8wNy8wOS9hZHZhbmNlZC1vcmFjbGUtdHJvdWJsZXNob290aW5nLWd1aWRlLXBhcnQtNy1zYW1wbGluZy1sYXRjaC1ob2xkZXItc3RhdGlzdGljcy11c2luZy1sYXRjaHByb2Yv" target=\"_blank\">http://blog.tanelpoder.com/2008/07/09/advanced-oracle-troubleshooting-guide-part-7-sampling-latch-holder-statistics-using-latchprof/</a></li>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOC8wNy8yMy9hZHZhbmNlZC1vcmFjbGUtdHJvdWJsZXNob290aW5nLWd1aWRlLXBhcnQtOC1ldmVuLW1vcmUtZGV0YWlsZWQtbGF0Y2gtdHJvdWJsZXNob290aW5nLXVzaW5nLWxhdGNocHJvZngv">http://blog.tanelpoder.com/2008/07/23/advanced-oracle-troubleshooting-guide-part-8-even-more-detailed-latch-troubleshooting-using-latchprofx/</a></li>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOS8wMy8yMC9hbm90aGVyLWxhdGNocHJvZngtdXNlLWNhc2Uv">http://blog.tanelpoder.com/2009/03/20/another-latchprofx-use-case/</a></li>
</ul>
<p>And now I introduce a new feature in LatchProfX.</p>
<p>In addition to being able to report the SID of the latch holder and the kernel function why this latch was taken by the session, the newest LatchProfX can also report the <strong>object</strong> what was protected by the latch under investigation. For cache buffers chains the object is <em>data block address</em> of the block being accessed.</p>
<p>Here&#8217;s an example, let say I have CBC latch contention problems and from monitoring tools or sql_trace I have identified the hot latch, I use my <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL3N3LnNxbA==" target=\"_blank\">sw.sql</a> script here, to report what a session is waiting for:</p>
<pre>SQL&gt; <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL3N3LnNxbA==" target=\"_blank\"><strong>@sw</strong></a> 138
 SID STATE   EVENT                        SEC_IN_WAIT                 P1
------- ------- ---------------------------- ----------- ------------------
    138 WAITING latch: cache buffers chains            0 address=0x<strong>27E5A780</strong></pre>
<p>Sw reports that this session is waiting on cache buffer chains child latch with address 0x27E5a780.</p>
<p>Now we can run latchprofx and report sid, name, hold mode and protected object for that child latch only (instead of latch name we specified its address):</p>
<pre>SQL&gt; <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL2xhdGNocHJvZnguc3Fs">@latchprofx</a> sid,name,hmode,<strong>object</strong> % <strong>27E5A780</strong> 100000

 SID NAME                   HMODE         OBJECT   Held  Gets  Held %  Held ms
---- ---------------------- ------------ ------- ------ ----- ------- --------
 138 cache buffers chains   exclusive     <strong>40EB02</strong>   3928  3797    3.93   41.637
 151 cache buffers chains   exclusive     <strong>40EB02</strong>   3711  3660    3.71   39.337
 138 cache buffers chains   shared        <strong>40EB02</strong>    623   623     .62    6.604
 151 cache buffers chains   shared        <strong>40EB02</strong>    544   544     .54    5.766</pre>
<p>As you see, LatchProfX has reported a data block address in the object column. This is the datablock we are trying to access in buffer cache under protection of the given child latch.</p>
<p>Lets see what this DBA translates to:</p>
<pre>
<pre>SQL&gt; <strong><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL2RiYS5zcWw=" target=\"_blank\">@dba</a> 40EB02</strong>

 RFILE#     BLOCK#
---------- ----------
         1      60162

Press enter to find the segment using V$BH (this may take CPU time), CTRL+C to cancel:

STATE      BLOCK_CLASS        OBJECT_TYPE         object                                          TCH  MODE_HELD
---------- ------------------ ------------------- ---------------------------------------- ---------- ----------
xcur       data block         INDEX               SYS.SYS_IOT_TOP_<strong>94276</strong>                           331          1

Press enter to query what segment resides there using DBA_EXTENTS (this can be IO intensive), CTRL+C to cancel:

OWNER                          SEGMENT_NAME         PARTITION_NAME  TABLESPACE_NAME
------------------------------ -------------------- --------------- -----------------
SYS                            SYS_IOT_TOP_94276                    SYSTEM</pre>
<p>So, the troublemaker is an IOT index segment block belonging to table with object_id <strong>94276</strong>. I can find the table name from dba_objects by object_id, or by using my script:</pre>
<pre>SQL&gt;<strong> <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL29pZC5zcWw=" target=\"_blank\">@oid</a></strong> 94276

owner                     object_name                    object_type        CREATED
------------------------- ------------------------------ ------------------ -----------------
SYS                       <strong>KILL_CPU</strong>                       TABLE              20090825 23:19:49</pre>
<p>Also, as we know the segment name and relative file number (RFILE#) and block number (BLOCK#)  from above output we can dump the datablock with an ALTER SYSTEM DUMP DATAFILE command.</p>
<p>As that command requires absolute file id (not relative) we have to do a little conversion first (in cases where there are multiple files with same relative file number in database):</p>
<pre>SQL&gt; select file_id from dba_extents where <strong>relative_fno</strong> = 1 and <strong>segment_name</strong> = 'SYS_IOT_TOP_94276';

 FILE_ID
----------
 1</pre>
<p>Of course in my little test case all relative file numbers match with absolute numbers (but if you have lots of datafiles, have directly migrated from Oracle 7 or use transportable tablespaces, you may hit this issue).</p>
<p>Finally I can run ALTER SYSTEM DUMP DATAFILE 1 BLOCK 60162 to find out more about the contents of that block. Another option would be to construct a rowid from the data_object_id, rfile and block and query the table using that but as that&#8217;s complicated for IOTs, I&#8217;ll leave this to a future post.</p>
<p>You can download latest version of LatchProfX here:</p>
<ul>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL2xhdGNocHJvZnguc3Fs" target=\"_blank\">http://www.tanelpoder.com/files/scripts/latchprofx.sql</a></li>
</ul>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2009%2F08%2F27%2Flatch-cache-buffers-chains-latch-contention-a-better-way-for-finding-the-hot-block%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=417" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/08/27/latch-cache-buffers-chains-latch-contention-a-better-way-for-finding-the-hot-block/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Links section</title>
		<link>http://blog.tanelpoder.com/2009/06/14/links-section/</link>
		<comments>http://blog.tanelpoder.com/2009/06/14/links-section/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 21:50:32 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/2009/06/14/links-section/</guid>
		<description><![CDATA[I have added a links section into my blog where I put links to useful external documents and tools what I often refer to during my seminars and consulting. I will make additions to that page over time&#8230; To see the list, you can click on the &#8220;Seminar Links&#8221; in top right section of the [...]]]></description>
			<content:encoded><![CDATA[<p>I have added a links section into my blog where I put links to useful external documents and tools what I often refer to during my seminars and consulting.</p>
<p>I will make additions to that page over time&#8230;</p>
<p>To see the list, you can click on the &#8220;Seminar Links&#8221; in top right section of the blog page or just click here:</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vc2VtaW5hci9zZW1pbmFyLWxpbmtzLw==">http://blog.tanelpoder.com/seminar/seminar-links/</a></p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2009%2F06%2F14%2Flinks-section%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=350" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/06/14/links-section/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scripts for showing execution plans via plain SQL and also in Oracle 9i</title>
		<link>http://blog.tanelpoder.com/2009/05/26/scripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i/</link>
		<comments>http://blog.tanelpoder.com/2009/05/26/scripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i/#comments</comments>
		<pubDate>Tue, 26 May 2009 20:42:05 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/2009/05/26/scripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i/</guid>
		<description><![CDATA[Hi all, Here are few scripts which allow you to query SQL execution plans and their execution statistics out from V$SQL_PLAN and V$SQL_PLAN_STATISTICS yourself. Why would you want to do this as there&#8217;s the DBMS_XPLAN.DISPLAY_CURSOR() function in Oracle 10g? Well, my scripts work also on Oracle 9.2. Also they give you better detail (and flexibility) [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>Here are few scripts which allow you to query SQL execution plans and their execution statistics out from V$SQL_PLAN and V$SQL_PLAN_STATISTICS yourself.</p>
<p>Why would you want to do this as there&#8217;s the DBMS_XPLAN.DISPLAY_CURSOR() function in Oracle 10g?</p>
<p>Well, my scripts work also on Oracle 9.2. Also they give you better detail (and flexibility) compared to DBMS_XPLAN.DISPLAY_CURSOR.</p>
<p>Of course in 9i there&#8217;s the DBMS_XPLAN.DISPLAY function which you can use in conjuction with EXPLAIN PLAN FOR command, but that approach has problems. EXPLAIN PLAN treats all bind variables as varchar2 datatype, possibly causing the reported execution plan to be different from reality. Also, if you have a long running report from last night and you run explain plan today morning, then if optimizer statistics have changed meanwhile, the explain plan command might come up with a different execution plan again, which is different from reality.</p>
<p>So that&#8217;s why in 10g we have the DBMS_XPLAN.DISPLAY_CURSOR which goes directly to required library cache child cursor and extracts (unparses) the execution plan from there. The function uses V$SQL_PLAN% views as its data source. And guess what &#8211; these views are there in version 9.2 already! And thats&#8217; where my scripts come in:</p>
<p>Here&#8217;s an example. Let&#8217;s set statistics_level=all so we get rowsource level execution stats for the cursor (note that this parameter makes your query consume much more CPU so it should only be used at session level for troubleshooting a specific performance issue):</p>
<pre><code>SQL&gt; alter session set statistics_level = all;

Session altered.

SQL&gt; select count(*) from all_users;

  COUNT(*)
----------
        36
</code></pre>
<p>I know the hash value of this query, so lets report its execution plan, directly from library cache. This is the REAL execution plan inside that child cursor, not some estimate like EXPLAIN PLAN command gives:</p>
<p><span id="more-298"></span></p>
<pre><code>SQL&gt; <strong>@xm 3416239794 %</strong>

Ch Pr   Op                                                         Objcect                        Optimizer Optim rows Optim bytes Optimizer
ld ed   ID Operation                                               Name                                Cost  from step   from step Mode
-- -- ---- ------------------------------------------------------- ------------------------------ --------- ---------- ----------- ----------
 0       0 SELECT STATEMENT                                                                              14                        ALL_ROWS
         1  SORT AGGREGATE                                                                                           1          15
   A     2   HASH JOIN                                                                                   14         36         540
   A     3    HASH JOIN                                                                                   9         36         432
         4     TABLE ACCESS FULL                                   TS$                                    5         13          39
    F    5     TABLE ACCESS FULL                                   USER$                                  3         36         324
         6    TABLE ACCESS FULL                                    TS$                                    5         13          39

7 rows selected.

Ch Op
ld ID     Predicate Information (identified by operation id):
-- ------ ----------------------------------------------------------------------------------------------------
 0     2  - access("U"."TEMPTS#"="TTS"."TS#")
       3  - access("U"."DATATS#"="DTS"."TS#")
       5  - filter("U"."TYPE#"=1)

</code></pre>
<p>XM means eXplain from Memory :)</p>
<p>As we had enabled rowsource level execution stats collection, we can use another script to report the response time and resource consumption at execution plan line level (if you&#8217;re interested how Oracle achieves this, check the last part of <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOC8wNi8xNS9hZHZhbmNlZC1vcmFjbGUtdHJvdWJsZXNob290aW5nLWd1aWRlLXBhcnQtNi11bmRlcnN0YW5kaW5nLW9yYWNsZS1leGVjdXRpb24tcGxhbnMtd2l0aC1vc19leHBsYWluLw==">this blog post</a>)</p>
<pre><code>SQL&gt; <strong>@xmsh 3416239794 %</strong>

SQL hash value:          3416239794    Cursor address:                  00000003A41E5290    |   Statement first parsed at: 2009-05-26/23:02:16  |  200 seconds ago

 Ch Pr   Op                                                         Object                           ms spent in     Estimated Real #rows  Rowsource Consistent    Current   Physical   Physical    Optimizer
 ld ed   ID Operation                                               Name                               operation   output rows   returned     starts       gets       gets      reads     writes         Cost
--- -- ---- ------------------------------------------------------- ------------------------------ ------------- ------------- ---------- ---------- ---------- ---------- ---------- ---------- ------------
  0       0 SELECT STATEMENT                                                                                                                                                                               14
          1  SORT AGGREGATE                                                                                 2.49             1          1          1         42          0          0          0
    A     2   HASH JOIN                                                                                     2.43            36         36          1         42          0          0          0           14
    A     3    HASH JOIN                                                                                    1.87            36         36          1         24          0          0          0            9
          4     TABLE ACCESS FULL                                   TS$                                      .12            13         13          1         18          0          0          0            5
     F    5     TABLE ACCESS FULL                                   USER$                                    .06            36         36          1          6          0          0          0            3
          6    TABLE ACCESS FULL                                    TS$                                      .05            13         13          1         18          0          0          0            5

 Ch Op
 ld ID     Predicate Information (identified by operation id):
--- ------ ----------------------------------------------------------------------------------------------------
  0     2  - access("U"."TEMPTS#"="TTS"."TS#")
        3  - access("U"."DATATS#"="DTS"."TS#")
        5  - filter("U"."TYPE#"=1)

</code></pre>
<p>XMSH means eXplain from Memory with Statistics by Hash value (well it did make sense to me when I wrote the script, you can rename it to something else if you like :)</p>
<p>You may need to make your browser window pretty wide to see the full output to see all the columns reported. I normally run sqlplus in Windows cmd.exe and make the screen buffer wide, so the output doesn&#8217;t wrap.</p>
<p>If you want to read what these output columns mean, read my presentation about <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vc2VtaW5hci9zZW1pbmFyLWZpbGVzLw==">how SQL plan execution works</a>.</p>
<p>As I mentioned, the above scripts run also on Oracle 9.2 (that&#8217;s why I wrote them years ago).</p>
<p>Also there&#8217;s one more script, xms.sql which doesn&#8217;t take any parameters and shows you the execution plan of the latest SQL executed in current session. It uses v$session.prev_hash_value for determining this. However on Oracle 9.2 the prev_hash_value seems to be incorrectly reset and my script would display you wrong SQL statements execution plan. In 10g onwards Oracle has fixed this problem though. In 9i you need to identify the hash value of the statement and use xmsh.sql instead.</p>
<p>In 10g the xms works ok:</p>
<pre><code>SQL&gt; select count(*) from all_tables;

  COUNT(*)
----------
      1739

1 row selected.

SQL&gt; @xms

SQL hash value:          3565202713    Cursor address:                  00000003A4311930    |   Statement first parsed at: 2009-05-26/23:05:59  |  2 seconds ago

 Ch Pr   Op                                          Object                             ms spent   Estimated Real #rows  Rowsource Consistent    Current   Physical   Physical  Optimizer
 ld ed   ID Operation                                Name                                 in op. output rows   returned     starts       gets       gets      reads     writes       Cost
--- -- ---- ---------------------------------------- ------------------------------ ------------ ----------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
  0       0 SELECT STATEMENT                                                                                                                                                          558
          1  SORT AGGREGATE                                                               418.63           1          1          1       4559          0          1          0
     F    2   FILTER                                                                      416.78                   1739          1       4559          0          1          0
    A     3    HASH JOIN RIGHT OUTER                                                      387.23        1750       1739          1       2568          0          0          0        558
          4     TABLE ACCESS FULL                    USER$                                   .12          74         74          1          6          0          0          0          3
    A     5     HASH JOIN OUTER                                                           377.55        1750       1739          1       2562          0          0          0        555
          6      NESTED LOOPS OUTER                                                       225.00        1750       1739          1       1913          0          0          0        410
    A     7       HASH JOIN                                                               218.02        1750       1739          1       1819          0          0          0        410
          8        TABLE ACCESS FULL                 USER$                                   .11          74         74          1          6          0          0          0          3
    A     9        HASH JOIN                                                              206.61        1750       1739          1       1813          0          0          0        406
    A    10         HASH JOIN RIGHT OUTER                                                  41.63        1750       1750          1       1164          0          0          0        260
         11          TABLE ACCESS FULL               SEG$                                   5.28        5249       5249          1        156          0          0          0         35
    A    12          HASH JOIN                                                             17.97        1750       1750          1       1008          0          0          0        224
         13           MERGE JOIN CARTESIAN                                                  6.62          13         13          1         18          0          0          0          6
    A    14            HASH JOIN                                                            6.40           1          1          1          0          0          0          0          1
     F   15             FIXED TABLE FULL             X$KSPPI                                 .95           1          1          1          0          0          0          0          0
         16             FIXED TABLE FULL             X$KSPPCV                               1.45        1440       1440          1          0          0          0          0          0
         17            BUFFER SORT                                                           .20          13         13          1         18          0          0          0          6
         18             TABLE ACCESS FULL            TS$                                     .09          13         13          1         18          0          0          0          5
     F   19           TABLE ACCESS FULL              TAB$                                   3.55        1750       1750          1        990          0          0          0        218
     F   20         TABLE ACCESS FULL                OBJ$                                  55.26       53718      53716          1        649          0          0          0        146
    A    21       INDEX UNIQUE SCAN                  I_OBJ1                                 3.36           1         92       1739         94          0          0          0          0
         22      TABLE ACCESS FULL                   OBJ$                                   1.26       53728      53727          1        649          0          0          0        144
         23    NESTED LOOPS                                                                25.93           1         69        995       1991          0          1          0          2
    A    24     INDEX RANGE SCAN                     I_OBJAUTH1                            22.25           1        149        995       1991          0          1          0          2
     F   25     FIXED TABLE FULL                     X$KZSRO                                 .91           1         69        149          0          0          0          0          0
     F   26      FIXED TABLE FULL                    X$KZSPR                                 .05          14          1          1          0          0          0          0          0

 Ch Op
 ld ID     Predicate Information (identified by operation id):
--- ------ ----------------------------------------------------------------------------------------------------
  0     2  - filter(("O"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR  IS NOT NULL))
        3  - access("CX"."OWNER#"="CU"."USER#")
        5  - access("T"."DATAOBJ#"="CX"."OBJ#")
        7  - access("O"."OWNER#"="U"."USER#")
        9  - access("O"."OBJ#"="T"."OBJ#")
       10  - access("T"."FILE#"="S"."FILE#" AND "T"."BLOCK#"="S"."BLOCK#" AND "T"."TS#"="S"."TS#")
       12  - access("T"."TS#"="TS"."TS#")
       14  - access("KSPPI"."INDX"="KSPPCV"."INDX")
       15  - filter("KSPPI"."KSPPINM"='_dml_monitoring_enabled')
       19  - filter(BITAND("T"."PROPERTY",1)=0)
       20  - filter(BITAND("O"."FLAGS",128)=0)
       21  - access("T"."BOBJ#"="CO"."OBJ#")
       24  - access("OA"."OBJ#"=:B1)
       25  - filter("GRANTEE#"="KZSROROL")
       26  - filter((((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49)
           OR (-"KZSPRPRV")=(-50)) AND "INST_ID"=USERENV('INSTANCE')))

</code></pre>
<p>I haven&#8217;t had a need to adjust the scripts to fix the problem what Jonathan Lewis has <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2pvbmF0aGFubGV3aXMud29yZHByZXNzLmNvbS8yMDA4LzAxLzEwL2ZpbHRlci1wbGFuLWVycm9yLw==">described earlier</a>, but it should be easily doable (just need to make sure that the connect by recursive loop is done against a materialized resultset of v$sql_plan, not the view itself to avoid excessive latching).</p>
<p>The scripts are downloadable from here:</p>
<ul>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL3htLnNxbA==">xm.sql</a> &#8211; explain from Memory</li>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL3htc2guc3Fs">xmsh.sql</a> &#8211; eXplain from Memory lookup by Hash value</li>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL3htcy5zcWw=">xms.sql</a> &#8211; eXplain from Memory (latest SQL in current session)</li>
</ul>
<p><em>Update:</em></p>
<p>If you are on 10g and want to know how to convert SQL_ID&#8217;s to hash values for use with my XM scripts, read this:</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOS8wMi8yMi9zcWxfaWQtaXMtanVzdC1hLWZhbmN5LXJlcHJlc2VudGF0aW9uLW9mLWhhc2gtdmFsdWUv">http://blog.tanelpoder.com/2009/02/22/sql_id-is-just-a-fancy-representation-of-hash-value/</a></p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2009%2F05%2F26%2Fscripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=298" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/05/26/scripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
