<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ORATraining Blog &#187; Applications Performance Tuning</title>
	<atom:link href="http://www.oratraining.com/blog/category/oracle/applications/applications-performance-tuning/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oratraining.com/blog</link>
	<description>Not just another Oracle Blog</description>
	<lastBuildDate>Tue, 25 May 2010 12:22:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Oracle SQL hints</title>
		<link>http://www.oratraining.com/blog/2009/04/oracle-sql-hints/</link>
		<comments>http://www.oratraining.com/blog/2009/04/oracle-sql-hints/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 06:56:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Applications Performance Tuning]]></category>
		<category><![CDATA[Database Performance Tuning]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle DBA]]></category>
		<category><![CDATA[Concurrent manager]]></category>
		<category><![CDATA[oracle applications]]></category>
		<category><![CDATA[Oracle Applications DBA]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=89</guid>
		<description><![CDATA[/*+ hint */
/*+ hint(argument) */
/*+ hint(argument-1 argument-2) */
All hints except /*+ rule */ cause the CBO to be used. Therefore, it is good practise to analyze the underlying tables if hints are used (or the query is fully hinted.
There should be no schema names in hints. Hints must use aliases if alias names are used [...]]]></description>
			<content:encoded><![CDATA[<p>/*+ hint */</p>
<p>/*+ hint(argument) */</p>
<p>/*+ hint(argument-1 argument-2) */</p>
<p>All hints except /*+ rule */ cause the CBO to be used. Therefore, it is good practise to analyze the underlying tables if hints are used (or the query is <em>fully</em> hinted.</p>
<p>There should be no schema names in hints. Hints must use aliases if alias names are used for table names. So the following is wrong:</p>
<p>select /*+ index(scott.emp ix_emp) */ from scott.emp <strong>emp_alias</strong></p>
<p>better:</p>
<p>select /*+ index(<strong>emp_alias</strong> ix_emp) */ &#8230; from scott.emp <strong>emp_alias</strong></p>
<p><strong>Why using hints</strong></p>
<p><span id="more-89"></span><br />
It is a perfect valid question to ask why hints should be used. Oracle comes with an <span style="text-decoration: underline;">optimizer</span> that promises to optimize a <span style="text-decoration: underline;">query&#8217;s execution plan</span>. When this optimizer is really doing a good job, no hints should be required at all.</p>
<p>Sometimes, however, the characteristics of the data in the database are changing rapidly, so that the optimizer (or more accuratly, its statistics) are out of date. In this case, a hint could help.</p>
<p>It must also be noted, that Oracle allows to <em>lock</em> the statistics when they look ideal which should make the hints meaningless again.</p>
<p><strong>Hint categories</strong></p>
<p>Hints can be categorized as follows:</p>
<ul class="unIndentedList">
<li> Hints for Optimization Approaches and Goals,</li>
<li> Hints for Access Paths, Hints for Query Transformations,</li>
<li> Hints for Join Orders,</li>
<li> Hints for Join Operations,</li>
<li> Hints for Parallel Execution,</li>
<li> Additional Hints</li>
</ul>
<p><strong>Documented Hints</strong></p>
<p><strong>Hints for Optimization Approaches and Goals</strong></p>
<ul class="unIndentedList">
<li> ALL_ROWS<br />
One of the hints that &#8216;invokes&#8217; the <span style="text-decoration: underline;">Cost based optimizer</span><br />
ALL_ROWS is usually used for <em>batch processing</em> or <em>data warehousing</em> systems.</li>
<li> FIRST_ROWS<br />
One of the hints that &#8216;invokes&#8217; the <span style="text-decoration: underline;">Cost based optimizer</span><br />
FIRST_ROWS is usually used for <em>OLTP</em> systems.</li>
<li> CHOOSE<br />
One of the hints that &#8216;invokes&#8217; the <span style="text-decoration: underline;">Cost based optimizer</span><br />
This hint lets the server choose (between ALL_ROWS and FIRST_ROWS, based on <span style="text-decoration: underline;">statistics gathered</span>.</li>
<li> RULE<br />
The RULE hint should be considered deprecated as it is dropped from Oracle9i2.</li>
</ul>
<p>See also the following initialization parameters: <span style="text-decoration: underline;">optimizer_mode</span>, <span style="text-decoration: underline;">optimizer_max_permutations</span>, <span style="text-decoration: underline;">optimizer_index_cost_adj</span>, <span style="text-decoration: underline;">optimizer_index_caching</span> and</p>
<p><strong>Hints for Access Paths</strong></p>
<ul class="unIndentedList">
<li> CLUSTER<br />
Performs a <span style="text-decoration: underline;">nested loop</span> by the cluster index of one of the tables.</li>
<li> FULL<br />
Performs <span style="text-decoration: underline;">full table scan</span>.</li>
<li> HASH<br />
Hashes one table (full scan) and creates a hash index for that table. Then hashes other table and uses hash index to find corresponding records. Therefore not suitable for &lt; or &gt; join conditions.</li>
<li> ROWID<br />
Retrieves the row by <span style="text-decoration: underline;">rowid</span></li>
<li> INDEX<br />
Specifying that index index_name should be used on table tab_name: /*+ index (tab_name index_name) */<br />
Specifying that the index should be used the the <span style="text-decoration: underline;">CBO</span> thinks is most suitable. (Not always a good choice).<br />
Starting with Oracle 10g, the index hint can be described: /*+ index(my_tab my_tab(col_1, col_2)) */. Using the index on my_tab that starts with the columns col_1 and col_2.</li>
<li> INDEX_ASC</li>
<li> INDEX_COMBINE</li>
<li> INDEX_DESC</li>
<li> INDEX_FFS</li>
<li> INDEX_JOIN</li>
<li> NO_INDEX</li>
<li> AND_EQUAL<br />
The AND_EQUAL hint explicitly chooses an execution plan that uses an access path that merges the scans on several single-column indexes</li>
</ul>
<p><strong>Hints for Query Transformations</strong></p>
<ul class="unIndentedList">
<li> FACT<br />
The FACT hint is used in the context of the star transformation to indicate to the transformation that the hinted table should be considered as a fact table.</li>
<li> MERGE</li>
<li> NO_EXPAND</li>
<li> NO_EXPAND_GSET_TO_UNION</li>
<li> NO_FACT</li>
<li> NO_MERGE</li>
<li> NOREWRITE</li>
<li> REWRITE</li>
<li> STAR_TRANSFORMATION</li>
<li> USE_CONCAT</li>
</ul>
<p><strong>Hints for Join Operations</strong></p>
<ul class="unIndentedList">
<li> DRIVING_SITE</li>
<li> HASH_AJ</li>
<li> HASH_SJ</li>
<li> LEADING</li>
<li> MERGE_AJ</li>
<li> MERGE_SJ</li>
<li> NL_AJ</li>
<li> NL_SJ</li>
<li> USE_HASH</li>
<li> USE_MERGE</li>
<li> USE_NL</li>
</ul>
<p><strong>Hints for Parallel Execution</strong></p>
<ul class="unIndentedList">
<li> NOPARALLEL</li>
<li> PARALLEL</li>
<li> NOPARALLEL_INDEX</li>
<li> PARALLEL_INDEX</li>
<li> PQ_DISTRIBUTE</li>
</ul>
<p><strong>Additional Hints</strong></p>
<ul class="unIndentedList">
<li> ANTIJOIN <a name="append"></a></li>
<li> APPEND<br />
If a table or an index is specified with <span style="text-decoration: underline;">nologging</span>, this hint applied with an insert statement produces a <strong>direct path insert</strong> which reduces generation of <span style="text-decoration: underline;">redo</span>.</li>
<li> BITMAP</li>
<li> BUFFER</li>
<li> CACHE</li>
<li> CARDINALITY</li>
<li> CPU_COSTING</li>
<li> <span style="text-decoration: underline;">DYNAMIC_SAMPLING</span></li>
<li> INLINE</li>
<li> MATERIALIZE</li>
<li> NO_ACCESS</li>
<li> NO_BUFFER</li>
<li> NO_MONITORING</li>
<li> NO_PUSH_PRED</li>
<li> NO_PUSH_SUBQ</li>
<li> NO_QKN_BUFF</li>
<li> NO_SEMIJOIN</li>
<li> NOAPPEND</li>
<li> NOCACHE</li>
<li> OR_EXPAND</li>
<li> ORDERED</li>
<li> ORDERED_PREDICATES</li>
<li> PUSH_PRED</li>
<li> PUSH_SUBQ</li>
<li> <span style="text-decoration: underline;">QB_NAME</span></li>
<li> <span style="text-decoration: underline;">RESULT_CACHE</span> (<span style="text-decoration: underline;">Oracle 11g</span>)</li>
<li> SELECTIVITY</li>
<li> SEMIJOIN</li>
<li> SEMIJOIN_DRIVER</li>
<li> STAR<br />
The STAR hint forces a star query plan to be used, if possible. A star plan has the largest table in the query last in the join order and joins it with a nested loops join on a concatenated index. The STAR hint applies when there are at least three tables, the large table&#8217;s concatenated index has at least three columns, and there are no conflicting access or join method hints. The optimizer also considers different permutations of the small tables.</li>
<li> SWAP_JOIN_INPUTS</li>
<li> USE_ANTI</li>
<li> USE_SEMI</li>
</ul>
<p><strong>Undocumented hints:</strong></p>
<ul class="unIndentedList">
<li> BYPASS_RECURSIVE_CHECK<br />
Workaraound for bug 1816154</li>
<li> BYPASS_UJVC</li>
<li> CACHE_CB</li>
<li> CACHE_TEMP_TABLE</li>
<li> CIV_GB</li>
<li> COLLECTIONS_GET_REFS</li>
<li> CUBE_GB</li>
<li> CURSOR_SHARING_EXACT</li>
<li> DEREF_NO_REWRITE</li>
<li> DML_UPDATE</li>
<li> DOMAIN_INDEX_NO_SORT</li>
<li> DOMAIN_INDEX_SORT</li>
<li> DYNAMIC_SAMPLING</li>
<li> DYNAMIC_SAMPLING_EST_CDN</li>
<li> EXPAND_GSET_TO_UNION</li>
<li> FORCE_SAMPLE_BLOCK</li>
<li> GBY_CONC_ROLLUP</li>
<li> GLOBAL_TABLE_HINTS</li>
<li> HWM_BROKERED</li>
<li> IGNORE_ON_CLAUSE</li>
<li> IGNORE_WHERE_CLAUSE</li>
<li> INDEX_RRS</li>
<li> INDEX_SS</li>
<li> INDEX_SS_ASC</li>
<li> INDEX_SS_DESC</li>
<li> LIKE_EXPAND</li>
<li> LOCAL_INDEXES</li>
<li> MV_MERGE</li>
<li> NESTED_TABLE_GET_REFS</li>
<li> NESTED_TABLE_SET_REFS</li>
<li> NESTED_TABLE_SET_SETID</li>
<li> NO_FILTERING</li>
<li> NO_ORDER_ROLLUPS</li>
<li> NO_PRUNE_GSETS</li>
<li> NO_STATS_GSETS</li>
<li> NO_UNNEST</li>
<li> NOCPU_COSTING</li>
<li> OVERFLOW_NOMOVE</li>
<li> PIV_GB</li>
<li> PIV_SSF</li>
<li> PQ_MAP</li>
<li> PQ_NOMAP</li>
<li> REMOTE_MAPPED</li>
<li> RESTORE_AS_INTERVALS</li>
<li> SAVE_AS_INTERVALS</li>
<li> SCN_ASCENDING</li>
<li> SKIP_EXT_OPTIMIZER</li>
<li> SQLLDR</li>
<li> SYS_DL_CURSOR</li>
<li> SYS_PARALLEL_TXN</li>
<li> SYS_RID_ORDER</li>
<li> TIV_GB</li>
<li> TIV_SSF</li>
<li> UNNEST</li>
<li> USE_TTT_FOR_GSETS</li>
</ul>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2009%2F04%2Foracle-sql-hints%2F&amp;linkname=Oracle%20SQL%20hints"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2009/04/oracle-sql-hints/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
