<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Automatic Evolution of SQL Plan Baselines</title>
	<atom:link href="http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/feed/" rel="self" type="application/rss+xml" />
	<link>http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/</link>
	<description></description>
	<lastBuildDate>Wed, 10 Mar 2010 16:47:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Christian Antognini</title>
		<link>http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/comment-page-1/#comment-1065</link>
		<dc:creator>Christian Antognini</dc:creator>
		<pubDate>Thu, 19 Feb 2009 20:43:14 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=61#comment-1065</guid>
		<description>Hi Charlie

&gt; Aha, DD = data dictionary, you created a new word ^_^.

Not at all. It&#039;s a &quot;common&quot; acronym...
http://www.acronymfinder.com/DD.html

Chris</description>
		<content:encoded><![CDATA[<p>Hi Charlie</p>
<p>&gt; Aha, DD = data dictionary, you created a new word ^_^.</p>
<p>Not at all. It&#8217;s a &#8220;common&#8221; acronym&#8230;<br />
<a href="http://www.acronymfinder.com/DD.html" rel="nofollow">http://www.acronymfinder.com/DD.html</a></p>
<p>Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charlie Yi 木匠</title>
		<link>http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/comment-page-1/#comment-1062</link>
		<dc:creator>Charlie Yi 木匠</dc:creator>
		<pubDate>Thu, 19 Feb 2009 00:37:15 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=61#comment-1062</guid>
		<description>Aha, DD = data dictionary, you created a new word ^_^.

OK. When involve with binding variable. ACS (Adaptive cursor sharing) and SPM(SQL Plan Management), seems it dose not work, see last line, accepted = &#039;NO&#039;.

&lt;pre&gt;
set pagesize 0

drop table t purge;

CREATE TABLE t (
id NUMBER,
n  number,
pad VARCHAR2(4000),
CONSTRAINT t_pk PRIMARY KEY (id)
);

INSERT INTO t
SELECT rownum AS id, mod(rownum,1000) n, rpad(&#039;*&#039;,500,&#039;*&#039;) AS pad
FROM dual
CONNECT BY level &lt;= 10000;

commit;

exec dbms_stats.gather_table_stats(user,&#039;T&#039;);

REM remove all baselines created in the last 15 minutes
/*
DECLARE
  ret PLS_INTEGER;
BEGIN
  FOR c IN (SELECT DISTINCT sql_handle 
            FROM dba_sql_plan_baselines 
            WHERE creator = USER --&#039;SH&#039;
            --AND created &gt; systimestamp - to_dsinterval(&#039;0 00:15:00&#039;)
            )
  LOOP
    ret := dbms_spm.drop_sql_plan_baseline(c.sql_handle);
  END LOOP;
END;
/
*/

alter system flush shared_pool;

ALTER SESSION SET optimizer_capture_sql_plan_baselines = TRUE;

declare
 l_n pls_integer;
 li_cnt pls_integer;
begin
 l_n := 42;
 FOR i IN 1..2
 LOOP
  select count(*) into li_cnt from t where n = l_n;
 END LOOP;
end;
/

ALTER SESSION SET optimizer_capture_sql_plan_baselines = FALSE;

COLUMN sql_handle NEW_VALUE l_sql_handle

select sql_text, sql_handle, plan_name, enabled, accepted from dba_sql_plan_baselines
where sql_text like &#039;SELECT COUNT(*) FROM T WHERE N =%&#039;;

SELECT *
 FROM table(dbms_xplan.display_sql_plan_baseline(
              sql_handle =&gt; &#039;&amp;l_sql_handle&#039;,
              format     =&gt; &#039;basic&#039;
));

CREATE INDEX t_i1 ON t (n);

declare
 l_n pls_integer;
 li_cnt pls_integer;
begin
 l_n := 42;
 FOR i IN 1..2
 LOOP
  select count(*) into li_cnt from t where n = l_n;
 END LOOP;
end;
/

SELECT *
 FROM table(dbms_xplan.display_sql_plan_baseline(
              sql_handle =&gt; &#039;&amp;l_sql_handle&#039;,
              format     =&gt; &#039;basic&#039;
));

declare
 l_n pls_integer;
 li_cnt pls_integer;
begin
 l_n := 42;
 FOR i IN 1..100
 LOOP
  select count(*) into li_cnt from t where n = l_n;
 END LOOP;
 
 dbms_workload_repository.create_snapshot;
end;
/

DECLARE
  l_args dbms_advisor.argList;
BEGIN
  l_args := dbms_advisor.argList(&#039;ACCEPT_SQL_PROFILES&#039;, &#039;TRUE&#039;);
  dbms_sqltune.execute_tuning_task(
    task_name        =&gt; &#039;SYS_AUTO_SQL_TUNING_TASK&#039;,
    execution_params =&gt; l_args
  );
END;
/

select sql_text, sql_handle, plan_name, enabled, accepted from dba_sql_plan_baselines
where sql_text like &#039;SELECT COUNT(*) FROM T WHERE N =%&#039;;
-- -- ---
SELECT COUNT(*) FROM T WHERE N = :B1
SYS_SQL_4955f400c9c02a12       SYS_SQL_PLAN_c9c02a123fdbb376  YES YES

SELECT COUNT(*) FROM T WHERE N = :B1
SYS_SQL_4955f400c9c02a12       SYS_SQL_PLAN_c9c02a12c8938b16  YES NO
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Aha, DD = data dictionary, you created a new word ^_^.</p>
<p>OK. When involve with binding variable. ACS (Adaptive cursor sharing) and SPM(SQL Plan Management), seems it dose not work, see last line, accepted = &#8216;NO&#8217;.</p>
<p><pre>
set pagesize 0

drop table t purge;

CREATE TABLE t (
id NUMBER,
n  number,
pad VARCHAR2(4000),
CONSTRAINT t_pk PRIMARY KEY (id)
);

INSERT INTO t
SELECT rownum AS id, mod(rownum,1000) n, rpad(&#039;*&#039;,500,&#039;*&#039;) AS pad
FROM dual
CONNECT BY level &lt;= 10000;

commit;

exec dbms_stats.gather_table_stats(user,&#039;T&#039;);

REM remove all baselines created in the last 15 minutes
/*
DECLARE
  ret PLS_INTEGER;
BEGIN
  FOR c IN (SELECT DISTINCT sql_handle 
            FROM dba_sql_plan_baselines 
            WHERE creator = USER --&#039;SH&#039;
            --AND created &gt; systimestamp - to_dsinterval(&#039;0 00:15:00&#039;)
            )
  LOOP
    ret := dbms_spm.drop_sql_plan_baseline(c.sql_handle);
  END LOOP;
END;
/
*/

alter system flush shared_pool;

ALTER SESSION SET optimizer_capture_sql_plan_baselines = TRUE;

declare
 l_n pls_integer;
 li_cnt pls_integer;
begin
 l_n := 42;
 FOR i IN 1..2
 LOOP
  select count(*) into li_cnt from t where n = l_n;
 END LOOP;
end;
/

ALTER SESSION SET optimizer_capture_sql_plan_baselines = FALSE;

COLUMN sql_handle NEW_VALUE l_sql_handle

select sql_text, sql_handle, plan_name, enabled, accepted from dba_sql_plan_baselines
where sql_text like &#039;SELECT COUNT(*) FROM T WHERE N =%&#039;;

SELECT *
 FROM table(dbms_xplan.display_sql_plan_baseline(
              sql_handle =&gt; &#039;&amp;l_sql_handle&#039;,
              format     =&gt; &#039;basic&#039;
));

CREATE INDEX t_i1 ON t (n);

declare
 l_n pls_integer;
 li_cnt pls_integer;
begin
 l_n := 42;
 FOR i IN 1..2
 LOOP
  select count(*) into li_cnt from t where n = l_n;
 END LOOP;
end;
/

SELECT *
 FROM table(dbms_xplan.display_sql_plan_baseline(
              sql_handle =&gt; &#039;&amp;l_sql_handle&#039;,
              format     =&gt; &#039;basic&#039;
));

declare
 l_n pls_integer;
 li_cnt pls_integer;
begin
 l_n := 42;
 FOR i IN 1..100
 LOOP
  select count(*) into li_cnt from t where n = l_n;
 END LOOP;
 
 dbms_workload_repository.create_snapshot;
end;
/

DECLARE
  l_args dbms_advisor.argList;
BEGIN
  l_args := dbms_advisor.argList(&#039;ACCEPT_SQL_PROFILES&#039;, &#039;TRUE&#039;);
  dbms_sqltune.execute_tuning_task(
    task_name        =&gt; &#039;SYS_AUTO_SQL_TUNING_TASK&#039;,
    execution_params =&gt; l_args
  );
END;
/

select sql_text, sql_handle, plan_name, enabled, accepted from dba_sql_plan_baselines
where sql_text like &#039;SELECT COUNT(*) FROM T WHERE N =%&#039;;
-- -- ---
SELECT COUNT(*) FROM T WHERE N = :B1
SYS_SQL_4955f400c9c02a12       SYS_SQL_PLAN_c9c02a123fdbb376  YES YES

SELECT COUNT(*) FROM T WHERE N = :B1
SYS_SQL_4955f400c9c02a12       SYS_SQL_PLAN_c9c02a12c8938b16  YES NO
</pre></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Antognini</title>
		<link>http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/comment-page-1/#comment-912</link>
		<dc:creator>Christian Antognini</dc:creator>
		<pubDate>Mon, 16 Feb 2009 17:25:29 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=61#comment-912</guid>
		<description>Hi Charlie

&gt; Is DD mean in the SQL Profile?

I do not understand that question. Did the acronym (DD = data dictionary) confuse you?

Cheers,
Chris</description>
		<content:encoded><![CDATA[<p>Hi Charlie</p>
<p>> Is DD mean in the SQL Profile?</p>
<p>I do not understand that question. Did the acronym (DD = data dictionary) confuse you?</p>
<p>Cheers,<br />
Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charlie Yi 木匠</title>
		<link>http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/comment-page-1/#comment-723</link>
		<dc:creator>Charlie Yi 木匠</dc:creator>
		<pubDate>Fri, 13 Feb 2009 17:51:23 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=61#comment-723</guid>
		<description>&gt; In fact, in the DD, only hints are stored (not execution plans)
Is DD mean in the SQL Profile?

I&#039;ll try your Evolution of SQL Plan Baselines example again and paste the result soon,
on my 11.1.0.6 on Windows and pre-production 64bit 11.1.0.7 on Linux.

Thanks,
Charlie</description>
		<content:encoded><![CDATA[<p>&gt; In fact, in the DD, only hints are stored (not execution plans)<br />
Is DD mean in the SQL Profile?</p>
<p>I&#8217;ll try your Evolution of SQL Plan Baselines example again and paste the result soon,<br />
on my 11.1.0.6 on Windows and pre-production 64bit 11.1.0.7 on Linux.</p>
<p>Thanks,<br />
Charlie</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Antognini</title>
		<link>http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/comment-page-1/#comment-350</link>
		<dc:creator>Christian Antognini</dc:creator>
		<pubDate>Mon, 02 Feb 2009 16:47:39 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=61#comment-350</guid>
		<description>Hi Charlie

&gt; will step D generates an execution plan(do a hard parse)? 
&gt; or get plan from the SQL plan baseline directly and skip step D?

The hard parse is executed as usual. In fact, in the DD, only hints are stored (not execution plans).

&gt; I could not reproduce the result. dbms_sqltune.execute_tuning_task
&gt; dose not work for me; how to troubleshoot it?

Mhmm... do you get an error? In other words, please, describe what do you see.

Cheers,
Chris</description>
		<content:encoded><![CDATA[<p>Hi Charlie</p>
<p>> will step D generates an execution plan(do a hard parse)?<br />
> or get plan from the SQL plan baseline directly and skip step D?</p>
<p>The hard parse is executed as usual. In fact, in the DD, only hints are stored (not execution plans).</p>
<p>> I could not reproduce the result. dbms_sqltune.execute_tuning_task<br />
> dose not work for me; how to troubleshoot it?</p>
<p>Mhmm&#8230; do you get an error? In other words, please, describe what do you see.</p>
<p>Cheers,<br />
Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charlie Yi 木匠</title>
		<link>http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/comment-page-1/#comment-347</link>
		<dc:creator>Charlie Yi 木匠</dc:creator>
		<pubDate>Thu, 29 Jan 2009 00:23:14 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=61#comment-347</guid>
		<description>I could not reproduce the result. dbms_sqltune.execute_tuning_task dose not work for me; how to troubleshoot it? dbms_spm.evolve_sql_plan_baseline works for me.
Oracle 11.1.0.7 on RH ES 4 Linux.

SQL&gt; select sql_text, sql_handle, plan_name, enabled, accepted from dba_sql_plan_baselines;

SQL_TEXT
--------------------------------------------------------------------------------
SQL_HANDLE                     PLAN_NAME                      ENA ACC
------------------------------ ------------------------------ --- ---
SELECT count(pad) FROM t WHERE n = 42
SYS_SQL_492bdb47e8861a89       SYS_SQL_PLAN_e8861a893fdbb376  YES YES

SELECT count(pad) FROM t WHERE n = 42
SYS_SQL_492bdb47e8861a89       SYS_SQL_PLAN_e8861a8959340d78  YES NO

This works for me:

set long 32000

var report clob;
exec :report := dbms_spm.evolve_sql_plan_baseline(sql_handle=&gt;&#039;SYS_SQL_492bdb47e8861a89&#039;,verify =&gt; &#039;yes&#039;,commit =&gt; &#039;YES&#039;);

print report</description>
		<content:encoded><![CDATA[<p>I could not reproduce the result. dbms_sqltune.execute_tuning_task dose not work for me; how to troubleshoot it? dbms_spm.evolve_sql_plan_baseline works for me.<br />
Oracle 11.1.0.7 on RH ES 4 Linux.</p>
<p>SQL&gt; select sql_text, sql_handle, plan_name, enabled, accepted from dba_sql_plan_baselines;</p>
<p>SQL_TEXT<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_HANDLE                     PLAN_NAME                      ENA ACC<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212; &#8212;<br />
SELECT count(pad) FROM t WHERE n = 42<br />
SYS_SQL_492bdb47e8861a89       SYS_SQL_PLAN_e8861a893fdbb376  YES YES</p>
<p>SELECT count(pad) FROM t WHERE n = 42<br />
SYS_SQL_492bdb47e8861a89       SYS_SQL_PLAN_e8861a8959340d78  YES NO</p>
<p>This works for me:</p>
<p>set long 32000</p>
<p>var report clob;<br />
exec :report := dbms_spm.evolve_sql_plan_baseline(sql_handle=&gt;&#8217;SYS_SQL_492bdb47e8861a89&#8242;,verify =&gt; &#8216;yes&#8217;,commit =&gt; &#8216;YES&#8217;);</p>
<p>print report</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charlie Yi 木匠</title>
		<link>http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/comment-page-1/#comment-342</link>
		<dc:creator>Charlie Yi 木匠</dc:creator>
		<pubDate>Tue, 27 Jan 2009 18:41:09 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=61#comment-342</guid>
		<description>Hi Christian Antognini,

One question,
after we accepted the SQL profile and the linked SQL Plan baseline,
also reference your book &quot;TOP&quot; utilization of a SQL profile(page 267),
Step C and D: will step D generates an execution plan(do a hard parse)? or get plan from the SQL plan baseline directly and skip step D?

If so, it will not strictly follow the below process flow:

(page 292) Figure 7-9. Main steps carried out during the selection of a SQL plan baseline.
the query optimizer generates an execution plan without the support of SQL plan baselines.

You book TOP is really a good book, make CBO hardest part easy to understand.
I&#039;ll email some other SQL profile questions to you later.

Thanks for your good work,
Charlie (Yi)
Victoria, BC Canada</description>
		<content:encoded><![CDATA[<p>Hi Christian Antognini,</p>
<p>One question,<br />
after we accepted the SQL profile and the linked SQL Plan baseline,<br />
also reference your book &#8220;TOP&#8221; utilization of a SQL profile(page 267),<br />
Step C and D: will step D generates an execution plan(do a hard parse)? or get plan from the SQL plan baseline directly and skip step D?</p>
<p>If so, it will not strictly follow the below process flow:</p>
<p>(page 292) Figure 7-9. Main steps carried out during the selection of a SQL plan baseline.<br />
the query optimizer generates an execution plan without the support of SQL plan baselines.</p>
<p>You book TOP is really a good book, make CBO hardest part easy to understand.<br />
I&#8217;ll email some other SQL profile questions to you later.</p>
<p>Thanks for your good work,<br />
Charlie (Yi)<br />
Victoria, BC Canada</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sriram</title>
		<link>http://antognini.ch/2008/12/automatic-evolution-of-sql-plan-baselines/comment-page-1/#comment-275</link>
		<dc:creator>Sriram</dc:creator>
		<pubDate>Mon, 05 Jan 2009 20:55:33 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=61#comment-275</guid>
		<description>Thanks for this detailed clarifiaction and this one example of yours has cleared out the differece between stored outlines, sql profiles and SPM.

So to sum it up we can say that the automatic feature (SPM) is something like an evolving stored outline with the help of creaing sql profiles created and accepted automa
tically.

In case of manual stuff it is left to our discretion whether to accept the sql profile or not and instead the difference between 10g and 11g is instead of invoking DBMS_SQLTUNE
DBMS_SQLTUNE , You use the DBMS_SPM  for Manual load and evolution.

Thanks</description>
		<content:encoded><![CDATA[<p>Thanks for this detailed clarifiaction and this one example of yours has cleared out the differece between stored outlines, sql profiles and SPM.</p>
<p>So to sum it up we can say that the automatic feature (SPM) is something like an evolving stored outline with the help of creaing sql profiles created and accepted automa<br />
tically.</p>
<p>In case of manual stuff it is left to our discretion whether to accept the sql profile or not and instead the difference between 10g and 11g is instead of invoking DBMS_SQLTUNE<br />
DBMS_SQLTUNE , You use the DBMS_SPM  for Manual load and evolution.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
