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>
30 lines
4.8 KiB
HTML
30 lines
4.8 KiB
HTML
<a name="EN-US_TOPIC_0000001233563115"></a><a name="EN-US_TOPIC_0000001233563115"></a>
|
|
|
|
<h1 class="topictitle1">Sublink Name Hints</h1>
|
|
<div id="body1534471018690"><div class="section" id="EN-US_TOPIC_0000001233563115__section290819468377"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001233563115__p164213954412">These hints specify the name of a sublink block.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233563115__section530131664410"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233563115__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="k">table</span><span class="p">)</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233563115__section41303128143838"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001233563115__ul7813152810126"><li id="EN-US_TOPIC_0000001233563115__li98131128181220"><em id="EN-US_TOPIC_0000001233563115__i846442452912">table</em> indicates the name you have specified for a sublink block.</li></ul>
|
|
</div>
|
|
<div class="note" id="EN-US_TOPIC_0000001233563115__note133365763113"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001233563115__ul3357282517550"><li id="EN-US_TOPIC_0000001233563115__li3371996917550">This hint is used by an outer query only when a sublink is pulled up. Currently, only the <strong id="EN-US_TOPIC_0000001233563115__b1336874413012">Agg</strong> equivalent join, <strong id="EN-US_TOPIC_0000001233563115__b123821116306">IN</strong>, and <strong id="EN-US_TOPIC_0000001233563115__b84331327203">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_0000001233563115__ul481942317312"><li id="EN-US_TOPIC_0000001233563115__li38181823123116">The subquery after the <strong id="EN-US_TOPIC_0000001233563115__b1857114810354">FROM</strong> keyword is hinted by using the subquery alias. In this case, <strong id="EN-US_TOPIC_0000001233563115__b45421518361">blockname</strong> becomes invalid.</li><li id="EN-US_TOPIC_0000001233563115__li6819102317313">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_0000001233563115__b181546142114">blockname</strong> also becomes invalid.</li></ul>
|
|
</div></div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233563115__section1127715590585"><h4 class="sectiontitle">Examples</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233563115__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_0000001233563115__p35873872152236"><strong id="EN-US_TOPIC_0000001233563115__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_0000001233563115__b104532046113818">store_sales</strong> by using <strong id="EN-US_TOPIC_0000001233563115__b10320727162811">nestloop</strong>. The optimized plan is as follows:</p>
|
|
<p id="EN-US_TOPIC_0000001233563115__p11537141123911"><span><img id="EN-US_TOPIC_0000001233563115__image253718112390" src="figure/en-us_image_0000001188323774.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>
|
|
|