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>
37 lines
6.3 KiB
HTML
37 lines
6.3 KiB
HTML
<a name="EN-US_TOPIC_0000001188323736"></a><a name="EN-US_TOPIC_0000001188323736"></a>
|
|
|
|
<h1 class="topictitle1">Rows Hints</h1>
|
|
<div id="body1534471018690"><div class="section" id="EN-US_TOPIC_0000001188323736__section290819468377"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188323736__p4189348153917">These hints specify the number of rows in an intermediate result set. Both absolute values and relative values are supported.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188323736__section6280155403"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188323736__screen104876227404"><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">rows</span><span class="p">(</span><span class="n">table_list</span><span class="w"> </span><span class="o">#|+|-|*</span><span class="w"> </span><span class="n">const</span><span class="p">)</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188323736__section55696776143642"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001188323736__ul1778319872017"><li id="EN-US_TOPIC_0000001188323736__li178378142012"><strong id="EN-US_TOPIC_0000001188323736__b13527183815202">#</strong>,<strong id="EN-US_TOPIC_0000001188323736__b5527738132010">+</strong>,<strong id="EN-US_TOPIC_0000001188323736__b148213416206">-</strong>, and <strong id="EN-US_TOPIC_0000001188323736__b01684286209">*</strong> are operators used for hinting the estimation. <strong id="EN-US_TOPIC_0000001188323736__b2498111414615">#</strong> indicates that the original estimation is used without any calculation. <strong id="EN-US_TOPIC_0000001188323736__b5527738132010_1">+</strong>,<strong id="EN-US_TOPIC_0000001188323736__b148213416206_1">-</strong>, and <strong id="EN-US_TOPIC_0000001188323736__b01684286209_1">*</strong> indicate that the original estimation is calculated using these operators. The minimum calculation result is 1. <em id="EN-US_TOPIC_0000001188323736__i116631341135914">table_list</em> specifies the tables to be joined. The values are the same as those of <a href="dws_04_0457.html#EN-US_TOPIC_0000001233563309__li1090312446510">table_list</a> in <a href="dws_04_0457.html">Join Operation Hints</a>.</li></ul>
|
|
</div>
|
|
<ul id="EN-US_TOPIC_0000001188323736__ul9783180208"><li id="EN-US_TOPIC_0000001188323736__li127831884207"><em id="EN-US_TOPIC_0000001188323736__i175371325514">const</em> can be any non-negative number and supports scientific notation.</li></ul>
|
|
<p id="EN-US_TOPIC_0000001188323736__p1648295411923">For example:</p>
|
|
<p id="EN-US_TOPIC_0000001188323736__p1412886411923"><strong id="EN-US_TOPIC_0000001188323736__b179871438218">rows(t1 #5)</strong>: The result set of <strong id="EN-US_TOPIC_0000001188323736__b29773416216">t1</strong> is five rows.</p>
|
|
<p id="EN-US_TOPIC_0000001188323736__p6005091311923"><strong id="EN-US_TOPIC_0000001188323736__b97618511824">rows(t1 t2 t3 *1000)</strong>: Multiply the result set of joined <strong id="EN-US_TOPIC_0000001188323736__b583212777">t1</strong>, <strong id="EN-US_TOPIC_0000001188323736__b15151961071">t2</strong>, and <strong id="EN-US_TOPIC_0000001188323736__b790168371">t3</strong> by 1000.</p>
|
|
<div class="section" id="EN-US_TOPIC_0000001188323736__section99281150122819"><h4 class="sectiontitle">Suggestion</h4><ul id="EN-US_TOPIC_0000001188323736__ul19827192311618"><li id="EN-US_TOPIC_0000001188323736__li208275234618">The hint using <strong id="EN-US_TOPIC_0000001188323736__b14770538155813">*</strong> for two tables is recommended, because this hint will take effect for a join as long as the two tables appear on both sides of this join. For example, if the hint is <strong id="EN-US_TOPIC_0000001188323736__b13430657558">rows(t1 t2 * 3)</strong>, the join result of <strong id="EN-US_TOPIC_0000001188323736__b132271625565">(t1 t3 t4)</strong> and <strong id="EN-US_TOPIC_0000001188323736__b74025331867">(t2 t5 t6)</strong> will be multiplied by 3 because <strong id="EN-US_TOPIC_0000001188323736__b63006361187">t1</strong> and <strong id="EN-US_TOPIC_0000001188323736__b1456983918813">t2</strong> appear on both sides of the join.</li><li id="EN-US_TOPIC_0000001188323736__li19827323764"><strong id="EN-US_TOPIC_0000001188323736__b515810241216">rows</strong> hints can be specified for the result sets of a single table, multiple tables, function tables, and subquery scan tables.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188323736__section1127715590585"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188323736__p1698632723710">Hint the query plan in <a href="dws_04_0455.html#EN-US_TOPIC_0000001188642062__section671421102912">Examples</a> as follows:</p>
|
|
</div>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188323736__screen260013817409"><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">/*+ rows(store_sales store_returns *50) */</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_0000001188323736__p35873872152236">Multiply the result set of joined <strong id="EN-US_TOPIC_0000001188323736__b20520103713135">store_sales</strong> and <strong id="EN-US_TOPIC_0000001188323736__b1652163731315">store_returns</strong> by 50. The optimized plan is as follows:</p>
|
|
<p id="EN-US_TOPIC_0000001188323736__p16558410377"><span><img id="EN-US_TOPIC_0000001188323736__image56552041163718" src="figure/en-us_image_0000001188482348.png"></span></p>
|
|
<p id="EN-US_TOPIC_0000001188323736__p47433577154030">The estimation value after the hint in row 11 is <strong id="EN-US_TOPIC_0000001188323736__b1325264591615">360</strong>, and the original value is rounded off to 7.</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>
|
|
|