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>
38 lines
6.8 KiB
HTML
38 lines
6.8 KiB
HTML
<a name="EN-US_TOPIC_0000001510283821"></a><a name="EN-US_TOPIC_0000001510283821"></a>
|
|
|
|
<h1 class="topictitle1">Sublink Name Hints</h1>
|
|
<div id="body1534471018690"><div class="section" id="EN-US_TOPIC_0000001510283821__section290819468377"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001510283821__p164213954412">These hints specify the name of a sublink block.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510283821__section530131664410"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283821__screen12840329184412"><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="n">blockname</span><span class="w"> </span><span class="p">([</span><span class="o">@</span><span class="n">block_name</span><span class="p">]</span><span class="w"> </span><span class="k">table</span><span class="p">)</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510283821__section67199225285"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001510283821__ul22710325280"><li id="EN-US_TOPIC_0000001510283821__li3271332142815">This block name hint is used by an outer query only when a sublink is pulled up. Currently, only the <strong id="EN-US_TOPIC_0000001510283821__b683362248858">Agg</strong> equivalent join, <strong id="EN-US_TOPIC_0000001510283821__b1039787224858">IN</strong>, and <strong id="EN-US_TOPIC_0000001510283821__b1854350925858">EXISTS</strong> sublinks can be pulled up. This hint is usually used together with the hints described in the previous sections.</li></ul>
|
|
<ul id="EN-US_TOPIC_0000001510283821__ul8271432162817"><li id="EN-US_TOPIC_0000001510283821__li227432172816">The subquery after the <strong id="EN-US_TOPIC_0000001510283821__b148901523510">FROM</strong> keyword is hinted by using the subquery alias. In this case, <strong id="EN-US_TOPIC_0000001510283821__b6890221158">block_name hint</strong> becomes invalid.</li><li id="EN-US_TOPIC_0000001510283821__li1427163216286">If a sublink contains multiple tables, the tables will be joined with the outer-query tables in a random sequence after the sublink is pulled up. In this case, <strong id="EN-US_TOPIC_0000001510283821__b1508623298858">blockname</strong> also becomes invalid.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510283821__section41303128143838"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001510283821__ul7813152810126"><li id="EN-US_TOPIC_0000001510283821__li04162152619"><em id="EN-US_TOPIC_0000001510283821__en-us_topic_0000001510402197_i172885331829">block_name</em> indicates the block name of the statement block. For details, see <a href="dws_04_0456.html#EN-US_TOPIC_0000001460722632__li99021444551">block_name</a>.</li><li id="EN-US_TOPIC_0000001510283821__li98131128181220"><em id="EN-US_TOPIC_0000001510283821__i846442452912">table</em> indicates the name you have specified for a sublink block.<div class="note" id="EN-US_TOPIC_0000001510283821__note132271328371"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001510283821__en-us_topic_0000001460722632_ul114831571316"><li id="EN-US_TOPIC_0000001510283821__en-us_topic_0000001460722632_li134831971819">The syntax format of the table is as follows:<p id="EN-US_TOPIC_0000001510283821__en-us_topic_0000001460722632_p6483117519"><a name="EN-US_TOPIC_0000001510283821__en-us_topic_0000001460722632_li134831971819"></a><a name="en-us_topic_0000001460722632_li134831971819"></a>[schema.]table[@block_name]</p>
|
|
<p id="EN-US_TOPIC_0000001510283821__en-us_topic_0000001460722632_p204832718119">The table name can contain the schema name or block name before the subquery statement block is promoted. If the subquery statement block is optimized and rewritten by the optimizer, the value of <strong id="EN-US_TOPIC_0000001510283821__en-us_topic_0000001460722632_b1442317392810">block_name</strong> is different from that of <strong id="EN-US_TOPIC_0000001510283821__en-us_topic_0000001460722632_b152968102815">block_name</strong> in leading.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510283821__en-us_topic_0000001460722632_li3483157118">If a table has an alias, the alias is preferentially used to represent the table.</li></ul>
|
|
</div></div>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510283821__section1127715590585"><h4 class="sectiontitle">Example</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283821__screen1347124316443"><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">explain</span><span class="w"> </span><span class="k">select</span><span class="w"> </span><span class="cm">/*+nestloop(store_sales tt) */</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="n">store_sales</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">ss_item_sk</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="p">(</span><span class="k">select</span><span class="w"> </span><span class="cm">/*+blockname(tt)*/</span><span class="w"> </span><span class="n">i_item_sk</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="n">item</span><span class="w"> </span><span class="k">group</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001510283821__p35873872152236"><strong id="EN-US_TOPIC_0000001510283821__b71590573369">tt</strong> indicates the sublink block name. After being pulled up, the sublink is joined with the outer-query table <strong id="EN-US_TOPIC_0000001510283821__b104532046113818">store_sales</strong> by using <strong id="EN-US_TOPIC_0000001510283821__b10320727162811">nestloop</strong>. The optimized plan is as follows:</p>
|
|
<p id="EN-US_TOPIC_0000001510283821__p11537141123911"><span><img id="EN-US_TOPIC_0000001510283821__image253718112390" src="figure/en-us_image_0000001510523041.png" height="122.69250000000001" width="523.6875" title="Click to enlarge" class="imgResize"></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>
|
|
|
|
|
|
<script language="JavaScript">
|
|
<!--
|
|
image_size('.imgResize');
|
|
var msg_imageMax = "view original image";
|
|
var msg_imageClose = "close";
|
|
//--></script> |