forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
39 lines
5.7 KiB
HTML
39 lines
5.7 KiB
HTML
<a name="EN-US_TOPIC_0000001188323694"></a><a name="EN-US_TOPIC_0000001188323694"></a>
|
|
|
|
<h1 class="topictitle1">Scan Operation Hints</h1>
|
|
<div id="body1534471018690"><div class="section" id="EN-US_TOPIC_0000001188323694__section290819468377"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188323694__p18841126184211">These hints specify a scan operation, which can be <strong id="EN-US_TOPIC_0000001188323694__b4971143352713">tablescan</strong>, <strong id="EN-US_TOPIC_0000001188323694__b1436844115184">indexscan</strong>, or <strong id="EN-US_TOPIC_0000001188323694__b1767375122620">indexonlyscan</strong>.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188323694__section17380317104213"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188323694__screen0396113074210"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="p">[</span><span class="k">no</span><span class="p">]</span><span class="w"> </span><span class="n">tablescan</span><span class="o">|</span><span class="n">indexscan</span><span class="o">|</span><span class="n">indexonlyscan</span><span class="p">(</span><span class="k">table</span><span class="w"> </span><span class="p">[</span><span class="k">index</span><span class="p">])</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188323694__section35087980143822"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001188323694__ul12666121741113"><li id="EN-US_TOPIC_0000001188323694__li76667177115"><strong id="EN-US_TOPIC_0000001188323694__b1032416913113">no</strong> indicates that the specified hint will not be used for a join.</li></ul>
|
|
</div>
|
|
<ul id="EN-US_TOPIC_0000001188323694__ul162295411118"><li id="EN-US_TOPIC_0000001188323694__li152296414118"><em id="EN-US_TOPIC_0000001188323694__i188894474198">table</em> specifies the table to be scanned. You can specify only one table. Use a table alias (if any) instead of a table name.</li><li id="EN-US_TOPIC_0000001188323694__li72291148110"><em id="EN-US_TOPIC_0000001188323694__i8856173202115">index</em> indicates the index for <strong id="EN-US_TOPIC_0000001188323694__b570142117227">indexscan</strong> or <strong id="EN-US_TOPIC_0000001188323694__b245052811221">indexonlyscan</strong>. You can specify only one index.</li></ul>
|
|
<div class="note" id="EN-US_TOPIC_0000001188323694__note22524892145054"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001188323694__p1609102014512"><strong id="EN-US_TOPIC_0000001188323694__b9215191663615">indexscan</strong> and <strong id="EN-US_TOPIC_0000001188323694__b655183115360">indexonlyscan</strong> hints can be used only when the specified index belongs to the table.</p>
|
|
<p id="EN-US_TOPIC_0000001188323694__p1060146014512">Scan operation hints can be used for row-store tables, column-store tables, HDFS tables, HDFS foreign tables, OBS tables, and subquery tables. HDFS tables include primary tables and delta tables. The delta tables are invisible to users. Therefore, scan operation hints are used only for primary tables.</p>
|
|
</div></div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188323694__section1127715590585"><h4 class="sectiontitle">Example</h4><p id="EN-US_TOPIC_0000001188323694__p50606497145546">To specify an index-based hint for a scan, create an index named <strong id="EN-US_TOPIC_0000001188323694__b4513195415518">i</strong> on the<strong id="EN-US_TOPIC_0000001188323694__b1851365435511"> i_item_sk</strong> column of the <strong id="EN-US_TOPIC_0000001188323694__b10514154155511">item</strong> table.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188323694__screen27545314435"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">create</span><span class="w"> </span><span class="k">index</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="k">on</span><span class="w"> </span><span class="n">item</span><span class="p">(</span><span class="n">i_item_sk</span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001188323694__p1698632723710">Hint the query plan in <a href="dws_04_0455.html#EN-US_TOPIC_0000001188642062__section671421102912">Examples</a> as follows:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188323694__screen194951433184320"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">explain</span>
|
|
<span class="k">select</span><span class="w"> </span><span class="cm">/*+ indexscan(item i) */</span><span class="w"> </span><span class="n">i_product_name</span><span class="w"> </span><span class="n">product_name</span><span class="w"> </span><span class="p">...</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001188323694__p35873872152236"><strong id="EN-US_TOPIC_0000001188323694__b11234148172410">item</strong> is scanned based on an index. The optimized plan is as follows:</p>
|
|
<p id="EN-US_TOPIC_0000001188323694__p2249174015383"><span><img id="EN-US_TOPIC_0000001188323694__image3249174043812" src="figure/en-us_image_0000001188323806.png"></span></p>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0454.html">Hint-based Tuning</a></div>
|
|
</div>
|
|
</div>
|
|
|