<?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: Demonstration of Oracle &#8220;Ignoring&#8221; an Index Hint</title>
	<atom:link href="http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/feed/" rel="self" type="application/rss+xml" />
	<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/</link>
	<description>Miscellaneous Random Oracle Topics: Stop, Think, ... Understand</description>
	<lastBuildDate>Thu, 13 Jun 2013 22:46:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-2570</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Sun, 02 Jan 2011 13:20:40 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-2570</guid>
		<description><![CDATA[Mohamed,

Nice example using the unusual hint that is mentioned in this blog article:
http://richardfoote.wordpress.com/2010/12/20/oracle11g-ignore_row_on_dupkey_index-hint-micro-cuts/

I think that your example is a demonstration of the third bullet point: &quot;The hint is incompatible with another hint&quot;.  I enabled a 10053 trace for the INSERT statement that used the IGNORE_ROW_ON_DUPKEY_INDEX hint, and found this at the end of the trace file:
[code]
Dumping Hints
=============
  atom_hint=(@=000000044B3920D8 err=0 resol=0 &lt;strong&gt;used=0&lt;/strong&gt; token=814 org=1 lvl=1 txt=APPEND ())
  atom_hint=(@=00000000216C9020 err=0 resol=1 &lt;strong&gt;used=1&lt;/strong&gt; token=1735 org=1 lvl=3 txt=IGNORE_ROW_ON_DUPKEY_INDEX ())
[/code]
The above suggests that the APPEND hint was not used, and that was confirmed by the execution plan which was printed in the 10053 trace file:
[code]
============
Plan Table
============
--------------------------------------------------+-----------------------------------+
&#124; Id  &#124; Operation                       &#124; Name    &#124; Rows  &#124; Bytes &#124; Cost  &#124; Time      &#124;
--------------------------------------------------+-----------------------------------+
&#124; 0   &#124; INSERT STATEMENT                &#124;         &#124;       &#124;       &#124;     2 &#124;           &#124;
&#124; 1   &#124;  LOAD TABLE CONVENTIONAL        &#124;         &#124;       &#124;       &#124;       &#124;           &#124;
&#124; 2   &#124;   COUNT                         &#124;         &#124;       &#124;       &#124;       &#124;           &#124;
&#124; 3   &#124;    CONNECT BY WITHOUT FILTERING &#124;         &#124;       &#124;       &#124;       &#124;           &#124;
&#124; 4   &#124;     FAST DUAL                   &#124;         &#124;     1 &#124;       &#124;     2 &#124;  00:00:01 &#124;
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
 
Content of other_xml column
===========================
  db_version     : 11.2.0.1
  parse_schema   : TESTUSER
  plan_hash      : 1731520519
  plan_hash_2    : 2585177905
  Outline Data:
  /*+
    BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE(&#039;11.2.0.1&#039;)
      DB_VERSION(&#039;11.2.0.1&#039;)
      ALL_ROWS
      OUTLINE_LEAF(@&quot;SEL$1&quot;)
      OUTLINE_LEAF(@&quot;INS$1&quot;)
      FULL(@&quot;INS$1&quot; &quot;T&quot;@&quot;INS$1&quot;)
      NO_CONNECT_BY_FILTERING(@&quot;SEL$1&quot;)
      CONNECT_BY_COMBINE_SW(@&quot;SEL$1&quot;)
    END_OUTLINE_DATA
  */
[/code]

I experimented a little with your test case.
[code]
CREATE TABLE t (ID NUMBER, text VARCHAR2(10));
 
INSERT INTO t
 SELECT     ROWNUM, &#039;Test DML&#039;
   FROM DUAL
CONNECT BY LEVEL &lt;= 10;  
 
commit;
[/code]

So I now have a table without a primary key constraint.  Let&#039;s try the test SQL statement (the full test script followed by the output below the line /* The output */):
[code]
INSERT      /*+ append
		     ignore_row_on_dupkey_index(t)
               */
INTO t
  SELECT ROWNUM, &#039;unique ig&#039;
    FROM DUAL
  CONNECT BY LEVEL &lt;= 13
  LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;

ALTER SESSION SET EVENTS &#039;10053 TRACE NAME CONTEXT OFF&#039;;

/* The output */
                  *
ERROR at line 8:
ORA-38912: An index must be specified in the index hint
[/code]

OK, that did not work since I do not have an index on the ID column, and the optimizer did not just use the APPEND hint and ignore the IGNORE_ROW_ON_DUPKEY_INDEX hint.  Let&#039;s try again:
[code]
CREATE INDEX IND_T_ID ON T(ID);

ALTER SESSION SET TRACEFILE_IDENTIFIER=&#039;IGNORE_HINT2&#039;;
ALTER SESSION SET EVENTS &#039;10053 TRACE NAME CONTEXT FOREVER, LEVEL 1&#039;;

INSERT      /*+ append
		     ignore_row_on_dupkey_index(t IND_T_ID)
               */
INTO t
  SELECT ROWNUM, &#039;unique ig&#039;
    FROM DUAL
  CONNECT BY LEVEL &lt;= 13
  LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;

ALTER SESSION SET EVENTS &#039;10053 TRACE NAME CONTEXT OFF&#039;;

/* The output */
                  *
ERROR at line 8:
ORA-38913: Index specified in the index hint is invalid
[/code]

That did not work either.  Let&#039;s try again, this time with a unique index:
[code]
DROP INDEX IND_T_ID;
 
CREATE UNIQUE INDEX IND_T_ID ON T(ID);

ALTER SESSION SET TRACEFILE_IDENTIFIER=&#039;IGNORE_HINT3&#039;;
ALTER SESSION SET EVENTS &#039;10053 TRACE NAME CONTEXT FOREVER, LEVEL 1&#039;;

INSERT      /*+ append
		     ignore_row_on_dupkey_index(t IND_T_ID)
               */
INTO t
  SELECT ROWNUM, &#039;unique ig&#039;
    FROM DUAL
  CONNECT BY LEVEL &lt;= 13
  LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;

ALTER SESSION SET EVENTS &#039;10053 TRACE NAME CONTEXT OFF&#039;;

/* The output */
3 rows created.
[/code] 

In short, it appears that the IGNORE_ROW_ON_DUPKEY_INDEX hint is one index that refuses to be ignored.  :-)

Thank you for taking the time to put together the test case.]]></description>
		<content:encoded><![CDATA[<p>Mohamed,</p>
<p>Nice example using the unusual hint that is mentioned in this blog article:<br />
<a href="http://richardfoote.wordpress.com/2010/12/20/oracle11g-ignore_row_on_dupkey_index-hint-micro-cuts/" rel="nofollow">http://richardfoote.wordpress.com/2010/12/20/oracle11g-ignore_row_on_dupkey_index-hint-micro-cuts/</a></p>
<p>I think that your example is a demonstration of the third bullet point: &#8220;The hint is incompatible with another hint&#8221;.  I enabled a 10053 trace for the INSERT statement that used the IGNORE_ROW_ON_DUPKEY_INDEX hint, and found this at the end of the trace file:</p>
<pre class="brush: plain; title: ; notranslate">
Dumping Hints
=============
  atom_hint=(@=000000044B3920D8 err=0 resol=0 &lt;strong&gt;used=0&lt;/strong&gt; token=814 org=1 lvl=1 txt=APPEND ())
  atom_hint=(@=00000000216C9020 err=0 resol=1 &lt;strong&gt;used=1&lt;/strong&gt; token=1735 org=1 lvl=3 txt=IGNORE_ROW_ON_DUPKEY_INDEX ())
</pre>
<p>The above suggests that the APPEND hint was not used, and that was confirmed by the execution plan which was printed in the 10053 trace file:</p>
<pre class="brush: plain; title: ; notranslate">
============
Plan Table
============
--------------------------------------------------+-----------------------------------+
| Id  | Operation                       | Name    | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT                |         |       |       |     2 |           |
| 1   |  LOAD TABLE CONVENTIONAL        |         |       |       |       |           |
| 2   |   COUNT                         |         |       |       |       |           |
| 3   |    CONNECT BY WITHOUT FILTERING |         |       |       |       |           |
| 4   |     FAST DUAL                   |         |     1 |       |     2 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
 
Content of other_xml column
===========================
  db_version     : 11.2.0.1
  parse_schema   : TESTUSER
  plan_hash      : 1731520519
  plan_hash_2    : 2585177905
  Outline Data:
  /*+
    BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE('11.2.0.1')
      DB_VERSION('11.2.0.1')
      ALL_ROWS
      OUTLINE_LEAF(@&quot;SEL$1&quot;)
      OUTLINE_LEAF(@&quot;INS$1&quot;)
      FULL(@&quot;INS$1&quot; &quot;T&quot;@&quot;INS$1&quot;)
      NO_CONNECT_BY_FILTERING(@&quot;SEL$1&quot;)
      CONNECT_BY_COMBINE_SW(@&quot;SEL$1&quot;)
    END_OUTLINE_DATA
  */
</pre>
<p>I experimented a little with your test case.</p>
<pre class="brush: plain; title: ; notranslate">
CREATE TABLE t (ID NUMBER, text VARCHAR2(10));
 
INSERT INTO t
 SELECT     ROWNUM, 'Test DML'
   FROM DUAL
CONNECT BY LEVEL &lt;= 10;  
 
commit;
</pre>
<p>So I now have a table without a primary key constraint.  Let&#8217;s try the test SQL statement (the full test script followed by the output below the line /* The output */):</p>
<pre class="brush: plain; title: ; notranslate">
INSERT      /*+ append
		     ignore_row_on_dupkey_index(t)
               */
INTO t
  SELECT ROWNUM, 'unique ig'
    FROM DUAL
  CONNECT BY LEVEL &lt;= 13
  LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

/* The output */
                  *
ERROR at line 8:
ORA-38912: An index must be specified in the index hint
</pre>
<p>OK, that did not work since I do not have an index on the ID column, and the optimizer did not just use the APPEND hint and ignore the IGNORE_ROW_ON_DUPKEY_INDEX hint.  Let&#8217;s try again:</p>
<pre class="brush: plain; title: ; notranslate">
CREATE INDEX IND_T_ID ON T(ID);

ALTER SESSION SET TRACEFILE_IDENTIFIER='IGNORE_HINT2';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

INSERT      /*+ append
		     ignore_row_on_dupkey_index(t IND_T_ID)
               */
INTO t
  SELECT ROWNUM, 'unique ig'
    FROM DUAL
  CONNECT BY LEVEL &lt;= 13
  LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

/* The output */
                  *
ERROR at line 8:
ORA-38913: Index specified in the index hint is invalid
</pre>
<p>That did not work either.  Let&#8217;s try again, this time with a unique index:</p>
<pre class="brush: plain; title: ; notranslate">
DROP INDEX IND_T_ID;
 
CREATE UNIQUE INDEX IND_T_ID ON T(ID);

ALTER SESSION SET TRACEFILE_IDENTIFIER='IGNORE_HINT3';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

INSERT      /*+ append
		     ignore_row_on_dupkey_index(t IND_T_ID)
               */
INTO t
  SELECT ROWNUM, 'unique ig'
    FROM DUAL
  CONNECT BY LEVEL &lt;= 13
  LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

/* The output */
3 rows created.
</pre>
<p>In short, it appears that the IGNORE_ROW_ON_DUPKEY_INDEX hint is one index that refuses to be ignored.  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Thank you for taking the time to put together the test case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohamed</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-2566</link>
		<dc:creator><![CDATA[Mohamed]]></dc:creator>
		<pubDate>Sun, 02 Jan 2011 09:36:48 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-2566</guid>
		<description><![CDATA[Happy new year,

I just found another situation where a hint can be ignored; I don&#039;t know also where to categorize it.
[code]
SQL&gt; select * from v$version where rownum=1;

BANNER                                                                          
--------------------------------------------------------------------------------
Personal Oracle Database 11g Release 11.2.0.1.0 - Production                    

SQL&gt; drop table t;

Table dropped.

SQL&gt; drop table err$_t;

Table dropped.

SQL&gt; CREATE TABLE t (ID NUMBER PRIMARY KEY, text VARCHAR2(10));

Table created.

SQL&gt; INSERT INTO t
  2     SELECT     ROWNUM, &#039;Test DML&#039;
  3           FROM DUAL
  4     CONNECT BY LEVEL &lt;= 10;  

SQL&gt; commit;

Commit complete.

SQL&gt; exec DBMS_ERRLOG.create_error_log (dml_table_name =&gt; &#039;t&#039;);

PL/SQL procedure successfully completed.

SQL&gt; select count(1) from t;

  COUNT(1)                                                                      
----------                                                                      
        10                                                                      

SQL&gt; select count(1) from err$_t;

  COUNT(1)                                                                      
----------                                                                      
         0                                                                      

SQL&gt; INSERT      /*+ append */ INTO t
  2     SELECT ROWNUM, &#039;unique ap&#039;
  3       FROM DUAL
  4  CONNECT BY LEVEL &lt;= 13;
 
INSERT      /*+ append */ INTO t
*
ERROR at line 1:
ORA-00001: unique constraint (TESTUSER.SYS_C0028519) violated 
 
SQL&gt; select count(1) from err$_t;

  COUNT(1)                                                                      
----------                                                                      
         0       
[/code]
The DML Error logging doesn&#039;t work with direct path load.

But let&#039;s now use the new 11gR2 hint named ignore_row_on_dupkey_index as shown below:
[code]
SQL&gt; INSERT      /*+ ignore_row_on_dupkey_index(t(id))
  2                           append
  3                    */
  4   INTO t
  5     SELECT ROWNUM, &#039;unique ig&#039;
  6       FROM DUAL
  7   CONNECT BY LEVEL &lt;= 13 
  8   LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;
 
SQL&gt; select count(1) from t;

  COUNT(1)                                                                      
----------                                                                      
        13                                                                      

SQL&gt; rollback;

Rollback complete.

SQL&gt; INSERT      /*+ append
  2  			     ignore_row_on_dupkey_index(t(id))
  3                    */
  4   INTO t
  5     SELECT ROWNUM, &#039;unique ig&#039;
  6       FROM DUAL
  7   CONNECT BY LEVEL &lt;= 13
  8   LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;
 
3 rows created.

SQL&gt; commit;

Commit complete.
[/code]
The new hint ignore_row_on_dupkey_index makes the insert to silently ignore the hint append and to by passe the duplicate rows and to insert only new rows(3 rows)

Best Regards

Mohamed Houri

Mohamed

&lt;em&gt;(Edited to fix the Wordpress HTML problems when it encounters the LEVEL &lt;= syntax)&lt;/em&gt;]]></description>
		<content:encoded><![CDATA[<p>Happy new year,</p>
<p>I just found another situation where a hint can be ignored; I don&#8217;t know also where to categorize it.</p>
<pre class="brush: plain; title: ; notranslate">
SQL&gt; select * from v$version where rownum=1;

BANNER                                                                          
--------------------------------------------------------------------------------
Personal Oracle Database 11g Release 11.2.0.1.0 - Production                    

SQL&gt; drop table t;

Table dropped.

SQL&gt; drop table err$_t;

Table dropped.

SQL&gt; CREATE TABLE t (ID NUMBER PRIMARY KEY, text VARCHAR2(10));

Table created.

SQL&gt; INSERT INTO t
  2     SELECT     ROWNUM, 'Test DML'
  3           FROM DUAL
  4     CONNECT BY LEVEL &lt;= 10;  

SQL&gt; commit;

Commit complete.

SQL&gt; exec DBMS_ERRLOG.create_error_log (dml_table_name =&gt; 't');

PL/SQL procedure successfully completed.

SQL&gt; select count(1) from t;

  COUNT(1)                                                                      
----------                                                                      
        10                                                                      

SQL&gt; select count(1) from err$_t;

  COUNT(1)                                                                      
----------                                                                      
         0                                                                      

SQL&gt; INSERT      /*+ append */ INTO t
  2     SELECT ROWNUM, 'unique ap'
  3       FROM DUAL
  4  CONNECT BY LEVEL &lt;= 13;
 
INSERT      /*+ append */ INTO t
*
ERROR at line 1:
ORA-00001: unique constraint (TESTUSER.SYS_C0028519) violated 
 
SQL&gt; select count(1) from err$_t;

  COUNT(1)                                                                      
----------                                                                      
         0       
</pre>
<p>The DML Error logging doesn&#8217;t work with direct path load.</p>
<p>But let&#8217;s now use the new 11gR2 hint named ignore_row_on_dupkey_index as shown below:</p>
<pre class="brush: plain; title: ; notranslate">
SQL&gt; INSERT      /*+ ignore_row_on_dupkey_index(t(id))
  2                           append
  3                    */
  4   INTO t
  5     SELECT ROWNUM, 'unique ig'
  6       FROM DUAL
  7   CONNECT BY LEVEL &lt;= 13 
  8   LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;
 
SQL&gt; select count(1) from t;

  COUNT(1)                                                                      
----------                                                                      
        13                                                                      

SQL&gt; rollback;

Rollback complete.

SQL&gt; INSERT      /*+ append
  2  			     ignore_row_on_dupkey_index(t(id))
  3                    */
  4   INTO t
  5     SELECT ROWNUM, 'unique ig'
  6       FROM DUAL
  7   CONNECT BY LEVEL &lt;= 13
  8   LOG ERRORS INTO err$_t REJECT LIMIT UNLIMITED;
 
3 rows created.

SQL&gt; commit;

Commit complete.
</pre>
<p>The new hint ignore_row_on_dupkey_index makes the insert to silently ignore the hint append and to by passe the duplicate rows and to insert only new rows(3 rows)</p>
<p>Best Regards</p>
<p>Mohamed Houri</p>
<p>Mohamed</p>
<p><em>(Edited to fix the WordPress HTML problems when it encounters the LEVEL &lt;= syntax)</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-1575</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Mon, 26 Jul 2010 14:17:13 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-1575</guid>
		<description><![CDATA[Mark,

Thanks for another great example of why it may appear that the optimizer ignored a hint - the optimizer never saw the hint.  That is something that I did not consider.  It might be interesting to see if that is why the AND_EQUAL hint was apparently &quot;ignored&quot; in this recent OTN thread: http://forums.oracle.com/forums/thread.jspa?threadID=1104424 (this is in a 9.2.0.8 database, while the AND_EQUAL hint is deprecated in 10g).

Your comment helped me find another possible cause for a hint to be &quot;ignored&quot; - initialization parameter settings.  If an initialization parameter is set to explicitly disable a feature, a hint likely will not allow the optimizer to consider that feature (unless the hint explicitly sets an initialization parameter value).  For example, if we start with the T15 table from above (I restricted it to 1,000,000 rows rather than 10,000,000):
[code]
UPDATE
  T15
SET
  C3=0
WHERE
  C3 IS NULL;
 
EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=&gt;USER,TABNAME=&gt;&#039;T15&#039;,CASCADE=&gt;TRUE)
 
ALTER TABLE T15 MODIFY (C3 NUMBER NOT NULL);
[/code]

If we ask Oracle Database to count the rows in the table, it should use one of the indexes:
[code]
SET AUTOTRACE TRACEONLY EXPLAIN
 
SELECT
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 877827156
 
----------------------------------------------------------------------------
&#124; Id  &#124; Operation             &#124; Name       &#124; Rows  &#124; Cost (%CPU)&#124; Time     &#124;
----------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT      &#124;            &#124;     1 &#124;   282   (6)&#124; 00:00:02 &#124;
&#124;   1 &#124;  SORT AGGREGATE       &#124;            &#124;     1 &#124;            &#124;          &#124;
&#124;   2 &#124;   INDEX FAST FULL SCAN&#124; IND_T15_C3 &#124;  1000K&#124;   282   (6)&#124; 00:00:02 &#124;
----------------------------------------------------------------------------
[/code]

We are able to hint a different execution plan without any trouble:
[code]
SELECT /*+ FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 74626064
 
-------------------------------------------------------------------
&#124; Id  &#124; Operation          &#124; Name &#124; Rows  &#124; Cost (%CPU)&#124; Time     &#124;
-------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT   &#124;      &#124;     1 &#124;  5485   (2)&#124; 00:00:23 &#124;
&#124;   1 &#124;  SORT AGGREGATE    &#124;      &#124;     1 &#124;            &#124;          &#124;
&#124;   2 &#124;   TABLE ACCESS FULL&#124; T15  &#124;  1000K&#124;  5485   (2)&#124; 00:00:23 &#124;
-------------------------------------------------------------------
[/code]

Let&#039;s set a hidden initialization parameter to its default value and retry the test SQL statement:
[code]
ALTER SESSION SET &quot;_OPTIMIZER_IGNORE_HINTS&quot;=FALSE;
 
SELECT /*+ FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 74626064
 
-------------------------------------------------------------------
&#124; Id  &#124; Operation          &#124; Name &#124; Rows  &#124; Cost (%CPU)&#124; Time     &#124;
-------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT   &#124;      &#124;     1 &#124;  5485   (2)&#124; 00:00:23 &#124;
&#124;   1 &#124;  SORT AGGREGATE    &#124;      &#124;     1 &#124;            &#124;          &#124;
&#124;   2 &#124;   TABLE ACCESS FULL&#124; T15  &#124;  1000K&#124;  5485   (2)&#124; 00:00:23 &#124;
-------------------------------------------------------------------
[/code]

Now let&#039;s try again with a modified value for the parameter:
[code]
ALTER SESSION SET &quot;_OPTIMIZER_IGNORE_HINTS&quot;=TRUE;
 
SELECT /*+ FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 877827156

----------------------------------------------------------------------------
&#124; Id  &#124; Operation             &#124; Name       &#124; Rows  &#124; Cost (%CPU)&#124; Time     &#124;
----------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT      &#124;            &#124;     1 &#124;   282   (6)&#124; 00:00:02 &#124;
&#124;   1 &#124;  SORT AGGREGATE       &#124;            &#124;     1 &#124;            &#124;          &#124;
&#124;   2 &#124;   INDEX FAST FULL SCAN&#124; IND_T15_C3 &#124;  1000K&#124;   282   (6)&#124; 00:00:02 &#124;
----------------------------------------------------------------------------
[/code]

The optimizer ignored the index hint (because I told it to ignore the hint).

Another possibility of Oracle&#039;s optimizer &quot;ignoring&quot; a hint is accomplished using a hacked stored outline, as in this example:
http://hoopercharles.wordpress.com/2009/12/18/tracking-performance-problems-inserting-a-hint-into-sql-in-a-compiled-program/

One might wonder what would happen if a hint was provided that stated to ignore hints (I believe that the recursive dynamic sampling SQL will include this hint).  Will the hint to ignore hints be ignored?
[code]
ALTER SESSION SET &quot;_OPTIMIZER_IGNORE_HINTS&quot;=FALSE;
 
SELECT /*+ FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 74626064
 
-------------------------------------------------------------------
&#124; Id  &#124; Operation          &#124; Name &#124; Rows  &#124; Cost (%CPU)&#124; Time     &#124;
-------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT   &#124;      &#124;     1 &#124;  5485   (2)&#124; 00:00:23 &#124;
&#124;   1 &#124;  SORT AGGREGATE    &#124;      &#124;     1 &#124;            &#124;          &#124;
&#124;   2 &#124;   TABLE ACCESS FULL&#124; T15  &#124;  1000K&#124;  5485   (2)&#124; 00:00:23 &#124;
-------------------------------------------------------------------
[/code]

The hint was followed, as expected.  Now trying again:
[code]
SELECT /*+ IGNORE_OPTIM_EMBEDDED_HINTS FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 877827156

----------------------------------------------------------------------------
&#124; Id  &#124; Operation             &#124; Name       &#124; Rows  &#124; Cost (%CPU)&#124; Time     &#124;
----------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT      &#124;            &#124;     1 &#124;   282   (6)&#124; 00:00:02 &#124;
&#124;   1 &#124;  SORT AGGREGATE       &#124;            &#124;     1 &#124;            &#124;          &#124;
&#124;   2 &#124;   INDEX FAST FULL SCAN&#124; IND_T15_C3 &#124;  1000K&#124;   282   (6)&#124; 00:00:02 &#124;
----------------------------------------------------------------------------
[/code]

Oracle &quot;ignored&quot; my hint (this may fall under bullet point 3).]]></description>
		<content:encoded><![CDATA[<p>Mark,</p>
<p>Thanks for another great example of why it may appear that the optimizer ignored a hint &#8211; the optimizer never saw the hint.  That is something that I did not consider.  It might be interesting to see if that is why the AND_EQUAL hint was apparently &#8220;ignored&#8221; in this recent OTN thread: <a href="http://forums.oracle.com/forums/thread.jspa?threadID=1104424" rel="nofollow">http://forums.oracle.com/forums/thread.jspa?threadID=1104424</a> (this is in a 9.2.0.8 database, while the AND_EQUAL hint is deprecated in 10g).</p>
<p>Your comment helped me find another possible cause for a hint to be &#8220;ignored&#8221; &#8211; initialization parameter settings.  If an initialization parameter is set to explicitly disable a feature, a hint likely will not allow the optimizer to consider that feature (unless the hint explicitly sets an initialization parameter value).  For example, if we start with the T15 table from above (I restricted it to 1,000,000 rows rather than 10,000,000):</p>
<pre class="brush: plain; title: ; notranslate">
UPDATE
  T15
SET
  C3=0
WHERE
  C3 IS NULL;
 
EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=&gt;USER,TABNAME=&gt;'T15',CASCADE=&gt;TRUE)
 
ALTER TABLE T15 MODIFY (C3 NUMBER NOT NULL);
</pre>
<p>If we ask Oracle Database to count the rows in the table, it should use one of the indexes:</p>
<pre class="brush: plain; title: ; notranslate">
SET AUTOTRACE TRACEONLY EXPLAIN
 
SELECT
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 877827156
 
----------------------------------------------------------------------------
| Id  | Operation             | Name       | Rows  | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |            |     1 |   282   (6)| 00:00:02 |
|   1 |  SORT AGGREGATE       |            |     1 |            |          |
|   2 |   INDEX FAST FULL SCAN| IND_T15_C3 |  1000K|   282   (6)| 00:00:02 |
----------------------------------------------------------------------------
</pre>
<p>We are able to hint a different execution plan without any trouble:</p>
<pre class="brush: plain; title: ; notranslate">
SELECT /*+ FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 74626064
 
-------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Cost (%CPU)| Time     |
-------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |     1 |  5485   (2)| 00:00:23 |
|   1 |  SORT AGGREGATE    |      |     1 |            |          |
|   2 |   TABLE ACCESS FULL| T15  |  1000K|  5485   (2)| 00:00:23 |
-------------------------------------------------------------------
</pre>
<p>Let&#8217;s set a hidden initialization parameter to its default value and retry the test SQL statement:</p>
<pre class="brush: plain; title: ; notranslate">
ALTER SESSION SET &quot;_OPTIMIZER_IGNORE_HINTS&quot;=FALSE;
 
SELECT /*+ FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 74626064
 
-------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Cost (%CPU)| Time     |
-------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |     1 |  5485   (2)| 00:00:23 |
|   1 |  SORT AGGREGATE    |      |     1 |            |          |
|   2 |   TABLE ACCESS FULL| T15  |  1000K|  5485   (2)| 00:00:23 |
-------------------------------------------------------------------
</pre>
<p>Now let&#8217;s try again with a modified value for the parameter:</p>
<pre class="brush: plain; title: ; notranslate">
ALTER SESSION SET &quot;_OPTIMIZER_IGNORE_HINTS&quot;=TRUE;
 
SELECT /*+ FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 877827156

----------------------------------------------------------------------------
| Id  | Operation             | Name       | Rows  | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |            |     1 |   282   (6)| 00:00:02 |
|   1 |  SORT AGGREGATE       |            |     1 |            |          |
|   2 |   INDEX FAST FULL SCAN| IND_T15_C3 |  1000K|   282   (6)| 00:00:02 |
----------------------------------------------------------------------------
</pre>
<p>The optimizer ignored the index hint (because I told it to ignore the hint).</p>
<p>Another possibility of Oracle&#8217;s optimizer &#8220;ignoring&#8221; a hint is accomplished using a hacked stored outline, as in this example:<br />
<a href="http://hoopercharles.wordpress.com/2009/12/18/tracking-performance-problems-inserting-a-hint-into-sql-in-a-compiled-program/" rel="nofollow">http://hoopercharles.wordpress.com/2009/12/18/tracking-performance-problems-inserting-a-hint-into-sql-in-a-compiled-program/</a></p>
<p>One might wonder what would happen if a hint was provided that stated to ignore hints (I believe that the recursive dynamic sampling SQL will include this hint).  Will the hint to ignore hints be ignored?</p>
<pre class="brush: plain; title: ; notranslate">
ALTER SESSION SET &quot;_OPTIMIZER_IGNORE_HINTS&quot;=FALSE;
 
SELECT /*+ FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 74626064
 
-------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Cost (%CPU)| Time     |
-------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |     1 |  5485   (2)| 00:00:23 |
|   1 |  SORT AGGREGATE    |      |     1 |            |          |
|   2 |   TABLE ACCESS FULL| T15  |  1000K|  5485   (2)| 00:00:23 |
-------------------------------------------------------------------
</pre>
<p>The hint was followed, as expected.  Now trying again:</p>
<pre class="brush: plain; title: ; notranslate">
SELECT /*+ IGNORE_OPTIM_EMBEDDED_HINTS FULL(T15) */
  COUNT(*)
FROM
  T15;
 
Execution Plan
----------------------------------------------------------
Plan hash value: 877827156

----------------------------------------------------------------------------
| Id  | Operation             | Name       | Rows  | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |            |     1 |   282   (6)| 00:00:02 |
|   1 |  SORT AGGREGATE       |            |     1 |            |          |
|   2 |   INDEX FAST FULL SCAN| IND_T15_C3 |  1000K|   282   (6)| 00:00:02 |
----------------------------------------------------------------------------
</pre>
<p>Oracle &#8220;ignored&#8221; my hint (this may fall under bullet point 3).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark W. Farnham</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-1574</link>
		<dc:creator><![CDATA[Mark W. Farnham]]></dc:creator>
		<pubDate>Mon, 26 Jul 2010 13:26:09 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-1574</guid>
		<description><![CDATA[One interesting thing Mike Brown of Colibrilimited pointed out to me is that some client server interfaces discard /* */ comments. Of course looking in the v$ tables will reveal if the hint never arrived to the optimizer. But in the context of a list of why the optimizer &quot;ignored&quot; a hint, never having gotten it is a useful addition. By the way, most interfaces that do discard /* */ comment blocks respect the ANSI(?) rule of passing through -- format comments, which the Oracle optimizer thankfully respects as well. While I find block /* */ comments to be more readable, the -- format is probably the way to go if you really need a hint to be passed through.]]></description>
		<content:encoded><![CDATA[<p>One interesting thing Mike Brown of Colibrilimited pointed out to me is that some client server interfaces discard /* */ comments. Of course looking in the v$ tables will reveal if the hint never arrived to the optimizer. But in the context of a list of why the optimizer &#8220;ignored&#8221; a hint, never having gotten it is a useful addition. By the way, most interfaces that do discard /* */ comment blocks respect the ANSI(?) rule of passing through &#8212; format comments, which the Oracle optimizer thankfully respects as well. While I find block /* */ comments to be more readable, the &#8212; format is probably the way to go if you really need a hint to be passed through.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #196, A Carnival of the Vanities for DBAs &#124; The Pythian Blog</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-1571</link>
		<dc:creator><![CDATA[Log Buffer #196, A Carnival of the Vanities for DBAs &#124; The Pythian Blog]]></dc:creator>
		<pubDate>Fri, 23 Jul 2010 21:09:37 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-1571</guid>
		<description><![CDATA[[...] Charles Hooper blogs about an in-depth investigation on what can cause Oracle to ignore a hint. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Charles Hooper blogs about an in-depth investigation on what can cause Oracle to ignore a hint. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blogroll Report 16/07/2010 – 23/07/2010 &#171; Coskan&#8217;s Approach to Oracle</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-1568</link>
		<dc:creator><![CDATA[Blogroll Report 16/07/2010 – 23/07/2010 &#171; Coskan&#8217;s Approach to Oracle]]></dc:creator>
		<pubDate>Fri, 23 Jul 2010 15:18:13 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-1568</guid>
		<description><![CDATA[[...] 11-Why does Oracle / CBO ignores your Hint? Charles Hooper-Demonstration of Oracle “Ignoring” an Index Hint [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 11-Why does Oracle / CBO ignores your Hint? Charles Hooper-Demonstration of Oracle “Ignoring” an Index Hint [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-1563</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Wed, 21 Jul 2010 12:52:43 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-1563</guid>
		<description><![CDATA[Mohamed,

I think what you mention is a good example of bullet point #5 that likely is not an obvious reason why Oracle&#039;s optimizer would &lt;em&gt;not&lt;/em&gt; be able to use the hint - when I wrote the article I was only considering the possibility of NULL values in a column that has an index. (&lt;em&gt;Edit July 24, 2010:&lt;/em&gt; I just noticed that I wrote the word &quot;need&quot; rather than &quot;not&quot;.  I probably should have stated that Mohamed&#039;s comment is a &lt;em&gt;very&lt;/em&gt; good example of bullet point #5.)]]></description>
		<content:encoded><![CDATA[<p>Mohamed,</p>
<p>I think what you mention is a good example of bullet point #5 that likely is not an obvious reason why Oracle&#8217;s optimizer would <em>not</em> be able to use the hint &#8211; when I wrote the article I was only considering the possibility of NULL values in a column that has an index. (<em>Edit July 24, 2010:</em> I just noticed that I wrote the word &#8220;need&#8221; rather than &#8220;not&#8221;.  I probably should have stated that Mohamed&#8217;s comment is a <em>very</em> good example of bullet point #5.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohamed</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-1562</link>
		<dc:creator><![CDATA[Mohamed]]></dc:creator>
		<pubDate>Wed, 21 Jul 2010 06:21:36 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-1562</guid>
		<description><![CDATA[I would add to your list of situations where hints are ignored the following line (particularly for the /*+ append */ hint)

(a) The /*+ append */ hint is silently ignored when the inserted table contains triggers and/or Foreign key


Best Regards

Mohamed Houri]]></description>
		<content:encoded><![CDATA[<p>I would add to your list of situations where hints are ignored the following line (particularly for the /*+ append */ hint)</p>
<p>(a) The /*+ append */ hint is silently ignored when the inserted table contains triggers and/or Foreign key</p>
<p>Best Regards</p>
<p>Mohamed Houri</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-1556</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Tue, 20 Jul 2010 01:07:58 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-1556</guid>
		<description><![CDATA[Coskan,

Thank you for the comments and the link.  I forgot that the &quot;Troubleshooting Oracle Performance&quot; book had such a detailed section about using hints (I really need to finish the second read through of the book).]]></description>
		<content:encoded><![CDATA[<p>Coskan,</p>
<p>Thank you for the comments and the link.  I forgot that the &#8220;Troubleshooting Oracle Performance&#8221; book had such a detailed section about using hints (I really need to finish the second read through of the book).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: coskan</title>
		<link>http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/#comment-1555</link>
		<dc:creator><![CDATA[coskan]]></dc:creator>
		<pubDate>Mon, 19 Jul 2010 15:19:55 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2836#comment-1555</guid>
		<description><![CDATA[Very nice compilation Charles definitely a reference bookmark to share with people when they ask why their hint is not used. 

Another good reference to me is Troubleshooting Oracle Performance by Christian Antognini. Hints part of the book is available free  to everybody for further reading  on google books http://bit.ly/cKM2OE]]></description>
		<content:encoded><![CDATA[<p>Very nice compilation Charles definitely a reference bookmark to share with people when they ask why their hint is not used. </p>
<p>Another good reference to me is Troubleshooting Oracle Performance by Christian Antognini. Hints part of the book is available free  to everybody for further reading  on google books <a href="http://bit.ly/cKM2OE" rel="nofollow">http://bit.ly/cKM2OE</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
