<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: dbms_xplan and v$sql_plan</title>
	<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html</link>
	<description>Oracle Certified Master</description>
	<pubDate>Mon, 06 Oct 2008 21:50:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>

	<item>
		<title>by: mdinh</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2807</link>
		<pubDate>Wed, 30 May 2007 20:48:40 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2807</guid>
					<description>Excellent site and read.  I did a little research and this call all be done in one swoop. (reference: http://www.psoug.org/reference/dbms_xplan.html)

SYS@TIGGER&#62; select systimestamp from dual;

SYSTIMESTAMP
---------------------------------------------------------------------------
30-MAY-07 08.46.13.784288 PM +00:00

SYS@TIGGER&#62; connect mdinh
Enter password:
Connected.
MDINH@TIGGER&#62; SELECT t.*
FROM v$sql s,
TABLE(dbms_xplan.display_cursor(s.sql_id, s.child_number)) t
WHERE sql_text LIKE 'select systimestamp from dual%';  2    3    4

PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------------------------------
SQL_ID  a6vvt01r5w66v, child number 0
-------------------------------------
select systimestamp from dual

Plan hash value: 1388734953

-----------------------------------------------------------------
&#124; Id  &#124; Operation        &#124; Name &#124; Rows  &#124; Cost (%CPU)&#124; Time     &#124;
-----------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT &#124;      &#124;       &#124;     2 (100)&#124;          &#124;
&#124;   1 &#124;  FAST DUAL       &#124;      &#124;     1 &#124;     2   (0)&#124; 00:00:01 &#124;
-----------------------------------------------------------------


13 rows selected.

MDINH@TIGGER&#62;</description>
		<content:encoded><![CDATA[<p>Excellent site and read.  I did a little research and this call all be done in one swoop. (reference: <a href="http://www.psoug.org/reference/dbms_xplan.html" rel="nofollow">http://www.psoug.org/reference/dbms_xplan.html</a>)</p>
<p><a href="mailto:SYS@TIGGER&gt;">SYS@TIGGER&gt;</a> select systimestamp from dual;</p>
<p>SYSTIMESTAMP<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
30-MAY-07 08.46.13.784288 PM +00:00</p>
<p><a href="mailto:SYS@TIGGER&gt;">SYS@TIGGER&gt;</a> connect mdinh<br />
Enter password:<br />
Connected.<br />
<a href="mailto:MDINH@TIGGER&gt;">MDINH@TIGGER&gt;</a> SELECT t.*<br />
FROM v$sql s,<br />
TABLE(dbms_xplan.display_cursor(s.sql_id, s.child_number)) t<br />
WHERE sql_text LIKE &#8217;select systimestamp from dual%&#8217;;  2    3    4</p>
<p>PLAN_TABLE_OUTPUT<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
SQL_ID  a6vvt01r5w66v, child number 0<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
select systimestamp from dual</p>
<p>Plan hash value: 1388734953</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
| Id  | Operation        | Name | Rows  | Cost (%CPU)| Time     |<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
|   0 | SELECT STATEMENT |      |       |     2 (100)|          |<br />
|   1 |  FAST DUAL       |      |     1 |     2   (0)| 00:00:01 |<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>13 rows selected.</p>
<p><a href="mailto:MDINH@TIGGER&gt;">MDINH@TIGGER&gt;</a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Pythian Group Blog &#187; Log Buffer #46: a Carnival of the Vanities for DBAs</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2707</link>
		<pubDate>Fri, 25 May 2007 18:44:51 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2707</guid>
					<description>[...] Laurent Scheider produced an all-code post on dbms_xplan and v$sql_plan, with some snazzy Oracle-fu in the comments from Yas of the Oracle Today blog, who has a post of his own on modifying sprepins.sql for custom statspack reports. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Laurent Scheider produced an all-code post on dbms_xplan and v$sql_plan, with some snazzy Oracle-fu in the comments from Yas of the Oracle Today blog, who has a post of his own on modifying sprepins.sql for custom statspack reports. [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Laurent Schneider</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2682</link>
		<pubDate>Thu, 24 May 2007 14:15:47 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2682</guid>
					<description>Thanks Gregory for the hint, you were right, display_cursor is a very usable function in 10.2 :-D</description>
		<content:encoded><![CDATA[<p>Thanks Gregory for the hint, you were right, display_cursor is a very usable function in 10.2 <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gregory</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2681</link>
		<pubDate>Thu, 24 May 2007 13:37:12 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2681</guid>
					<description>Laurent,

SQL_ID! :-) That's what I meant by dbms_xplan.display_cursor. I'm just too stupid to be precise. This function query V$SQL_PLAN which is often far better than PLAN_TABLE (bind peeking, no_invalidate=&#62;true, etc)

Gregory</description>
		<content:encoded><![CDATA[<p>Laurent,</p>
<p>SQL_ID! <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  That&#8217;s what I meant by dbms_xplan.display_cursor. I&#8217;m just too stupid to be precise. This function query V$SQL_PLAN which is often far better than PLAN_TABLE (bind peeking, no_invalidate=&gt;true, etc)</p>
<p>Gregory
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Laurent Schneider</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2679</link>
		<pubDate>Thu, 24 May 2007 08:19:19 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2679</guid>
					<description>yas, you rule 8-)</description>
		<content:encoded><![CDATA[<p>yas, you rule <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_cool.gif' alt='8-)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: yas</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2678</link>
		<pubDate>Thu, 24 May 2007 06:27:04 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2678</guid>
					<description>Laurent, I use something like this in 9.2.

In 10GR2 you can display the plan from v$sql_plan without this. Try this function in dbms_xplan.

function display_cursor(sql_id           varchar2 default  null,
                          cursor_child_no  integer  default  0,
                          format           varchar2 default  'TYPICAL')
  return dbms_xplan_type_table

SQL&#62; r
  1  select sql_text,sql_id,child_number from v$sql
  2  where upper(sql_text) like 'SELECT * FROM DUAL%'
  3*

SQL_TEXT             SQL_ID        CHILD_NUMBER
-------------------- ------------- ------------
select * from dual   01fwpqgt0jx4p            0

SQL&#62; select * from table(dbms_xplan.display_cursor('01fwpqgt0jx4p'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
SQL_ID  01fwpqgt0jx4p, child number 0
-------------------------------------
select * from dual

Plan hash value: 3543395131

--------------------------------------------------------------------------
&#124; Id  &#124; Operation         &#124; Name &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
--------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT  &#124;      &#124;       &#124;       &#124;     2 (100)&#124;          &#124;
&#124;   1 &#124;  TABLE ACCESS FULL&#124; DUAL &#124;     1 &#124;     2 &#124;     2   (0)&#124; 00:00:01 &#124;

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------------------------------------------------------------


13 rows selected.</description>
		<content:encoded><![CDATA[<p>Laurent, I use something like this in 9.2.</p>
<p>In 10GR2 you can display the plan from v$sql_plan without this. Try this function in dbms_xplan.</p>
<p>function display_cursor(sql_id           varchar2 default  null,<br />
                          cursor_child_no  integer  default  0,<br />
                          format           varchar2 default  &#8216;TYPICAL&#8217;)<br />
  return dbms_xplan_type_table</p>
<p>SQL&gt; r<br />
  1  select sql_text,sql_id,child_number from v$sql<br />
  2  where upper(sql_text) like &#8216;SELECT * FROM DUAL%&#8217;<br />
  3*</p>
<p>SQL_TEXT             SQL_ID        CHILD_NUMBER<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;<br />
select * from dual   01fwpqgt0jx4p            0</p>
<p>SQL&gt; select * from table(dbms_xplan.display_cursor(&#8217;01fwpqgt0jx4p&#8217;));</p>
<p>PLAN_TABLE_OUTPUT<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
SQL_ID  01fwpqgt0jx4p, child number 0<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
select * from dual</p>
<p>Plan hash value: 3543395131</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
|   0 | SELECT STATEMENT  |      |       |       |     2 (100)|          |<br />
|   1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |</p>
<p>PLAN_TABLE_OUTPUT<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>13 rows selected.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Ted</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2677</link>
		<pubDate>Thu, 24 May 2007 01:55:11 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2677</guid>
					<description>Or dump every plan for every query that meets a criteria.

begin
for x in (select hash_value from v$sql where sql_text like '%MD%')
loop
explain_plan(x.hash_value);
end loop;
end;
/


I like this... :)</description>
		<content:encoded><![CDATA[<p>Or dump every plan for every query that meets a criteria.</p>
<p>begin<br />
for x in (select hash_value from v$sql where sql_text like &#8216;%MD%&#8217;)<br />
loop<br />
explain_plan(x.hash_value);<br />
end loop;<br />
end;<br />
/</p>
<p>I like this&#8230; <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Laurent Schneider</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2669</link>
		<pubDate>Wed, 23 May 2007 17:19:36 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2669</guid>
					<description>Sure Gregory,
But I am mainly interested in plan I am not executing myself, rather those generated by an application 8-)

Jens,
The plan table did change over time. Your link point to a 9.2 plan table. But the query works similary. 

I use this ugly max(id)+1 because asking the same plan twice should not produce duplicates</description>
		<content:encoded><![CDATA[<p>Sure Gregory,<br />
But I am mainly interested in plan I am not executing myself, rather those generated by an application <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_cool.gif' alt='8-)' class='wp-smiley' /> </p>
<p>Jens,<br />
The plan table did change over time. Your link point to a 9.2 plan table. But the query works similary. </p>
<p>I use this ugly max(id)+1 because asking the same plan twice should not produce duplicates
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gregory</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2667</link>
		<pubDate>Wed, 23 May 2007 17:10:33 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2667</guid>
					<description>Laurent,

(With 10.2 and SQL*Plus Only), You'll get the content of V$SQL_PLAN with the display_cursor table function :

select * from emp where id=7788;

select * from table(dbms_xplan.display_cursor(null, null));

Gregory</description>
		<content:encoded><![CDATA[<p>Laurent,</p>
<p>(With 10.2 and SQL*Plus Only), You&#8217;ll get the content of V$SQL_PLAN with the display_cursor table function :</p>
<p>select * from emp where id=7788;</p>
<p>select * from table(dbms_xplan.display_cursor(null, null));</p>
<p>Gregory
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Jens</title>
		<link>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2666</link>
		<pubDate>Wed, 23 May 2007 16:21:43 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/05/dbms_xplan-and-vsql_plan.html#comment-2666</guid>
					<description>In case you would like to have a more detailed explanation of what Laurent demonstrated above, I recommend to read Garry Robinsons
Generate execution plans direct from the library cache
http://www.oracleadvice.com/Tips/plantip.htm</description>
		<content:encoded><![CDATA[<p>In case you would like to have a more detailed explanation of what Laurent demonstrated above, I recommend to read Garry Robinsons<br />
Generate execution plans direct from the library cache<br />
<a href="http://www.oracleadvice.com/Tips/plantip.htm" rel="nofollow">http://www.oracleadvice.com/Tips/plantip.htm</a>
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
