<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Undocumented Hints</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Thu, 23 May 2013 12:47:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-40490</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 07 May 2011 08:05:40 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-40490</guid>
		<description><![CDATA[Igor,

This is not the forum for getting SQL fixed. You might try the OTN Database or SQL forum.

Before you do so, though, read up on using dbms_xplan to generate a complete plan, and especially the option for collecting and reporting rowsource execution statistics to see where the work was done.  At present If you select dbms_xplan from the Categeries drop-down list at the top right of this block you will find 12 articles on the topic.]]></description>
		<content:encoded><![CDATA[<p>Igor,</p>
<p>This is not the forum for getting SQL fixed. You might try the OTN Database or SQL forum.</p>
<p>Before you do so, though, read up on using dbms_xplan to generate a complete plan, and especially the option for collecting and reporting rowsource execution statistics to see where the work was done.  At present If you select dbms_xplan from the Categeries drop-down list at the top right of this block you will find 12 articles on the topic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-40483</link>
		<dc:creator><![CDATA[Igor]]></dc:creator>
		<pubDate>Thu, 05 May 2011 16:56:20 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-40483</guid>
		<description><![CDATA[can somebody help me to tunup the query utilizing hints?

&lt;em&gt;[SQL statement removed by JPL]&lt;/em&gt;

Thanks in advance
Igor]]></description>
		<content:encoded><![CDATA[<p>can somebody help me to tunup the query utilizing hints?</p>
<p><em>[SQL statement removed by JPL]</em></p>
<p>Thanks in advance<br />
Igor</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-36448</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Tue, 08 Jun 2010 21:55:04 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-36448</guid>
		<description><![CDATA[Greg,
Thanks for the follow-up.]]></description>
		<content:encoded><![CDATA[<p>Greg,<br />
Thanks for the follow-up.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Rahn</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-36437</link>
		<dc:creator><![CDATA[Greg Rahn]]></dc:creator>
		<pubDate>Mon, 07 Jun 2010 04:55:42 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-36437</guid>
		<description><![CDATA[@Val

This is bug 9148171.  It&#039;s since been fixed so it works with CTAS.

&lt;pre&gt;
explain plan for
create table foo
as
SELECT deptno, mgr, 
       sum(sal) sum_sal, count(sal) cnt_sal, 
       max(hiredate) max_hd, 
       count(distinct hiredate) dist_hd_cnt 
FROM emp 
GROUP BY deptno, mgr;

select * from table(dbms_xplan.display(format=&gt;&#039;outline basic&#039;)); 

Plan hash value: 192513176

--------------------------------------------------
&#124; Id  &#124; Operation                     &#124; Name     &#124;
--------------------------------------------------
&#124;   0 &#124; CREATE TABLE STATEMENT        &#124;          &#124;
&#124;   1 &#124;  LOAD AS SELECT               &#124; FOO      &#124;
&#124;   2 &#124;   HASH GROUP BY               &#124;          &#124;
&#124;   3 &#124;    VIEW                       &#124; VW_DAG_0 &#124;
&#124;   4 &#124;     HASH GROUP BY             &#124;          &#124;
&#124;   5 &#124;      TABLE ACCESS STORAGE FULL&#124; EMP      &#124;
--------------------------------------------------

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      USE_HASH_AGGREGATION(@&quot;SEL$5771D262&quot;)
      FULL(@&quot;SEL$5771D262&quot; &quot;EMP&quot;@&quot;SEL$1&quot;)
      USE_HASH_AGGREGATION(@&quot;SEL$C33C846D&quot;)
      NO_ACCESS(@&quot;SEL$C33C846D&quot; &quot;VW_DAG_0&quot;@&quot;SEL$C33C846D&quot;)
      TRANSFORM_DISTINCT_AGG(@&quot;SEL$1&quot;)
      OUTLINE(@&quot;SEL$5771D262&quot;)
      OUTLINE(@&quot;SEL$1&quot;)
      OUTLINE_LEAF(@&quot;SEL$C33C846D&quot;)
      TRANSFORM_DISTINCT_AGG(@&quot;SEL$1&quot;)
      OUTLINE_LEAF(@&quot;SEL$5771D262&quot;)
      NO_PARALLEL
      ALL_ROWS
      DB_VERSION(&#039;11.2.0.1&#039;)
      OPTIMIZER_FEATURES_ENABLE(&#039;11.2.0.1&#039;)
      IGNORE_OPTIM_EMBEDDED_HINTS
      END_OUTLINE_DATA
  */
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>@Val</p>
<p>This is bug 9148171.  It&#8217;s since been fixed so it works with CTAS.</p>
<pre>
explain plan for
create table foo
as
SELECT deptno, mgr, 
       sum(sal) sum_sal, count(sal) cnt_sal, 
       max(hiredate) max_hd, 
       count(distinct hiredate) dist_hd_cnt 
FROM emp 
GROUP BY deptno, mgr;

select * from table(dbms_xplan.display(format=&gt;'outline basic')); 

Plan hash value: 192513176

--------------------------------------------------
| Id  | Operation                     | Name     |
--------------------------------------------------
|   0 | CREATE TABLE STATEMENT        |          |
|   1 |  LOAD AS SELECT               | FOO      |
|   2 |   HASH GROUP BY               |          |
|   3 |    VIEW                       | VW_DAG_0 |
|   4 |     HASH GROUP BY             |          |
|   5 |      TABLE ACCESS STORAGE FULL| EMP      |
--------------------------------------------------

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      USE_HASH_AGGREGATION(@"SEL$5771D262")
      FULL(@"SEL$5771D262" "EMP"@"SEL$1")
      USE_HASH_AGGREGATION(@"SEL$C33C846D")
      NO_ACCESS(@"SEL$C33C846D" "VW_DAG_0"@"SEL$C33C846D")
      TRANSFORM_DISTINCT_AGG(@"SEL$1")
      OUTLINE(@"SEL$5771D262")
      OUTLINE(@"SEL$1")
      OUTLINE_LEAF(@"SEL$C33C846D")
      TRANSFORM_DISTINCT_AGG(@"SEL$1")
      OUTLINE_LEAF(@"SEL$5771D262")
      NO_PARALLEL
      ALL_ROWS
      DB_VERSION('11.2.0.1')
      OPTIMIZER_FEATURES_ENABLE('11.2.0.1')
      IGNORE_OPTIM_EMBEDDED_HINTS
      END_OUTLINE_DATA
  */
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Val</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-35718</link>
		<dc:creator><![CDATA[Val]]></dc:creator>
		<pubDate>Mon, 08 Mar 2010 19:06:24 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-35718</guid>
		<description><![CDATA[10053 gives a hint as to what can be done:

select  x, count(y) cnt from  
(
  select x, y from t1 group by x, y
) 
group by x

The above is what Oracle does with the original &#039;select x, count(unique y) from t1 group by x&#039;.

Adding an &#039;insert&#039; in front the re-written statement does not break the plan any more.  Why Oracle abandons a more performant &#039;hash group by&#039; plan when you add an insert to the original statement is unclear.]]></description>
		<content:encoded><![CDATA[<p>10053 gives a hint as to what can be done:</p>
<p>select  x, count(y) cnt from<br />
(<br />
  select x, y from t1 group by x, y<br />
)<br />
group by x</p>
<p>The above is what Oracle does with the original &#8216;select x, count(unique y) from t1 group by x&#8217;.</p>
<p>Adding an &#8216;insert&#8217; in front the re-written statement does not break the plan any more.  Why Oracle abandons a more performant &#8216;hash group by&#8217; plan when you add an insert to the original statement is unclear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Val</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-35710</link>
		<dc:creator><![CDATA[Val]]></dc:creator>
		<pubDate>Sun, 07 Mar 2010 23:56:26 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-35710</guid>
		<description><![CDATA[Re: USE_HASH_AGGREGATION

Apparently,  the hint has no effect when DML is involved:
[sourcecode]
sqlplus xyz/xyz

SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 7 18:41:59 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL&gt; set line 10000
SQL&gt; set autot on explain
SQL&gt; create table t1(x int, y int);

Table created.

SQL&gt; select x, count(unique y) from t1 group by x;

no rows selected


Execution Plan
----------------------------------------------------------
Plan hash value: 3640378487

----------------------------------------------------------------------------------
&#124; Id  &#124; Operation            &#124; Name      &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
----------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT     &#124;           &#124;     1 &#124;    26 &#124;     3  (34)&#124; 00:00:01 &#124;
&#124;   1 &#124;  HASH GROUP BY       &#124;           &#124;     1 &#124;    26 &#124;     3  (34)&#124; 00:00:01 &#124;
&#124;   2 &#124;   VIEW               &#124; VM_NWVW_1 &#124;     1 &#124;    26 &#124;     3  (34)&#124; 00:00:01 &#124;
&#124;   3 &#124;    HASH GROUP BY     &#124;           &#124;     1 &#124;    26 &#124;     3  (34)&#124; 00:00:01 &#124;
&#124;   4 &#124;     TABLE ACCESS FULL&#124; T1        &#124;     1 &#124;    26 &#124;     2   (0)&#124; 00:00:01 &#124;
----------------------------------------------------------------------------------

Note
-----
   - dynamic sampling used for this statement (level=2)

SQL&gt; create table t2 as select * from t1;

Table created.

SQL&gt; insert into t2 select/*+USE_HASH_AGGREGATION*/ x, count(unique y) from t1 group by x;

0 rows created.


Execution Plan
----------------------------------------------------------
Plan hash value: 3946799371

---------------------------------------------------------------------------------
&#124; Id  &#124; Operation                &#124; Name &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
---------------------------------------------------------------------------------
&#124;   0 &#124; INSERT STATEMENT         &#124;      &#124;     1 &#124;    26 &#124;     3  (34)&#124; 00:00:01 &#124;
&#124;   1 &#124;  LOAD TABLE CONVENTIONAL &#124; T2   &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   2 &#124;   SORT GROUP BY          &#124;      &#124;     1 &#124;    26 &#124;     3  (34)&#124; 00:00:01 &#124;
&#124;   3 &#124;    TABLE ACCESS FULL     &#124; T1   &#124;     1 &#124;    26 &#124;     2   (0)&#124; 00:00:01 &#124;
---------------------------------------------------------------------------------

Note
-----
   - dynamic sampling used for this statement (level=2)

SQL&gt;

[/sourcecode]
This is a pity because in our specific scenario, doing unique count through hashing is 2.4 times faster than by sorting (sort group by).  Another database whose name shall remain unspoken does hash group by in the insert/select statement just fine.  Is there some hidden hint per chance that would force Oracle to do the proper thing ?

Thanks.]]></description>
		<content:encoded><![CDATA[<p>Re: USE_HASH_AGGREGATION</p>
<p>Apparently,  the hint has no effect when DML is involved:</p>
<pre class="brush: plain; title: ; notranslate">
sqlplus xyz/xyz

SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 7 18:41:59 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL&amp;gt; set line 10000
SQL&amp;gt; set autot on explain
SQL&amp;gt; create table t1(x int, y int);

Table created.

SQL&amp;gt; select x, count(unique y) from t1 group by x;

no rows selected


Execution Plan
----------------------------------------------------------
Plan hash value: 3640378487

----------------------------------------------------------------------------------
| Id  | Operation            | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |           |     1 |    26 |     3  (34)| 00:00:01 |
|   1 |  HASH GROUP BY       |           |     1 |    26 |     3  (34)| 00:00:01 |
|   2 |   VIEW               | VM_NWVW_1 |     1 |    26 |     3  (34)| 00:00:01 |
|   3 |    HASH GROUP BY     |           |     1 |    26 |     3  (34)| 00:00:01 |
|   4 |     TABLE ACCESS FULL| T1        |     1 |    26 |     2   (0)| 00:00:01 |
----------------------------------------------------------------------------------

Note
-----
   - dynamic sampling used for this statement (level=2)

SQL&amp;gt; create table t2 as select * from t1;

Table created.

SQL&amp;gt; insert into t2 select/*+USE_HASH_AGGREGATION*/ x, count(unique y) from t1 group by x;

0 rows created.


Execution Plan
----------------------------------------------------------
Plan hash value: 3946799371

---------------------------------------------------------------------------------
| Id  | Operation                | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------
|   0 | INSERT STATEMENT         |      |     1 |    26 |     3  (34)| 00:00:01 |
|   1 |  LOAD TABLE CONVENTIONAL | T2   |       |       |            |          |
|   2 |   SORT GROUP BY          |      |     1 |    26 |     3  (34)| 00:00:01 |
|   3 |    TABLE ACCESS FULL     | T1   |     1 |    26 |     2   (0)| 00:00:01 |
---------------------------------------------------------------------------------

Note
-----
   - dynamic sampling used for this statement (level=2)

SQL&amp;gt;

</pre>
<p>This is a pity because in our specific scenario, doing unique count through hashing is 2.4 times faster than by sorting (sort group by).  Another database whose name shall remain unspoken does hash group by in the insert/select statement just fine.  Is there some hidden hint per chance that would force Oracle to do the proper thing ?</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-33620</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Wed, 24 Jun 2009 07:37:10 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-33620</guid>
		<description><![CDATA[Hemant,

The &lt;em&gt;&lt;strong&gt;dynamic_sampling()&lt;/strong&gt;&lt;/em&gt; hint allows you to specify a table and a level and samples blocks from that table unconditionally. Level 1 is (by default 32 blocks, and each level doubles the sample up to level 9, then level 10 is the whole table).

A directive to peek sounds nice.  The adaptive cursor sharing in 11g is roughly in that area - except it has to do it wrong before it tries again. And if you&#039;re using &lt;em&gt;&lt;strong&gt;cursor_sharing&lt;/strong&gt;&lt;/em&gt;=force there is a &lt;em&gt;&lt;strong&gt;cursor_sharing_exact&lt;/strong&gt;&lt;/em&gt; hint (from 9i) which, again, is working in the same area.]]></description>
		<content:encoded><![CDATA[<p>Hemant,</p>
<p>The <em><strong>dynamic_sampling()</strong></em> hint allows you to specify a table and a level and samples blocks from that table unconditionally. Level 1 is (by default 32 blocks, and each level doubles the sample up to level 9, then level 10 is the whole table).</p>
<p>A directive to peek sounds nice.  The adaptive cursor sharing in 11g is roughly in that area &#8211; except it has to do it wrong before it tries again. And if you&#8217;re using <em><strong>cursor_sharing</strong></em>=force there is a <em><strong>cursor_sharing_exact</strong></em> hint (from 9i) which, again, is working in the same area.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hemant K Chitale</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-33576</link>
		<dc:creator><![CDATA[Hemant K Chitale]]></dc:creator>
		<pubDate>Mon, 22 Jun 2009 03:15:30 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-33576</guid>
		<description><![CDATA[Adding to Timur&#039;s wishlist here are two I would like to see (do tell me if they are already possible) :

DYNAMIC_SAMPLING (table_name, blocks)
-- dynamic sampling for the table, ignoring existing table statistics


IGNORE_BIND_PEEKED (table_name)
-- ignore previously peeked binds for this table and re-peek in this execution.


Hemant]]></description>
		<content:encoded><![CDATA[<p>Adding to Timur&#8217;s wishlist here are two I would like to see (do tell me if they are already possible) :</p>
<p>DYNAMIC_SAMPLING (table_name, blocks)<br />
&#8211; dynamic sampling for the table, ignoring existing table statistics</p>
<p>IGNORE_BIND_PEEKED (table_name)<br />
&#8211; ignore previously peeked binds for this table and re-peek in this execution.</p>
<p>Hemant</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Billington</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-33571</link>
		<dc:creator><![CDATA[Adrian Billington]]></dc:creator>
		<pubDate>Sun, 21 Jun 2009 19:28:37 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-33571</guid>
		<description><![CDATA[Jonathan,

Thanks for re-formatting the example - I used the code tags suggested on your How To Comment page and saw how I&#039;d failed to take care of the whitespace after I had submitted it!

For those who are interested, &lt;a href=&quot;http://www.oracle-developer.net/display.php?id=427&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;my article on table/pipelined function cardinality&lt;/strong&gt;&lt;/a&gt; is now available.

Regards,
Adrian]]></description>
		<content:encoded><![CDATA[<p>Jonathan,</p>
<p>Thanks for re-formatting the example &#8211; I used the code tags suggested on your How To Comment page and saw how I&#8217;d failed to take care of the whitespace after I had submitted it!</p>
<p>For those who are interested, <a href="http://www.oracle-developer.net/display.php?id=427" rel="nofollow"><strong>my article on table/pipelined function cardinality</strong></a> is now available.</p>
<p>Regards,<br />
Adrian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2009/06/14/undocumented-hints/#comment-33561</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 20 Jun 2009 17:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=1527#comment-33561</guid>
		<description><![CDATA[Adrian,

Thanks for the example.
I&#039;ve done a quick edit to make it more readable - and I&#039;ve re-activated the link to your blog to make it easier for people to get back to your website in a few days, but feel free to put a new comment here when you publish the article]]></description>
		<content:encoded><![CDATA[<p>Adrian,</p>
<p>Thanks for the example.<br />
I&#8217;ve done a quick edit to make it more readable &#8211; and I&#8217;ve re-activated the link to your blog to make it easier for people to get back to your website in a few days, but feel free to put a new comment here when you publish the article</p>
]]></content:encoded>
	</item>
</channel>
</rss>
