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>
102 lines
13 KiB
HTML
102 lines
13 KiB
HTML
<a name="EN-US_TOPIC_0000001188482282"></a><a name="EN-US_TOPIC_0000001188482282"></a>
|
|
|
|
<h1 class="topictitle1">Adjusting Key Parameters During SQL Tuning</h1>
|
|
<div id="body8662426"><p id="EN-US_TOPIC_0000001188482282__a64f605245dcf406aac16d5a75afd84d5">This section describes key CN parameters that affect <span id="EN-US_TOPIC_0000001188482282__text650549764">GaussDB(DWS)</span> SQL optimization performance. For details about how to configure these parameters, see section in the .</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188482282__t69b44601812b4b668fac5667573af0a4" frame="border" border="1" rules="all"><caption><b>Table 1 </b>CN parameters</caption><thead align="left"><tr id="EN-US_TOPIC_0000001188482282__r9c57468779904a9d9071f523b1cc6b26"><th align="left" class="cellrowborder" valign="top" width="26.5%" id="mcps1.3.2.2.3.1.1"><p id="EN-US_TOPIC_0000001188482282__a0f39346627074a03aa89d93da8ac0eb6">Parameter/Reference Value</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="73.5%" id="mcps1.3.2.2.3.1.2"><p id="EN-US_TOPIC_0000001188482282__ad39d2792a8e14f92b598d05fb2e19e27">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188482282__r01ee6fe5a5fc4a11852aef3f2fea382b"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__adecb383d85df420ebceb2649e1d0dea1">enable_nestloop=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__aecfbd5f3946b4f9a887d8a7b83939668">Specifies how the optimizer uses <strong id="EN-US_TOPIC_0000001188482282__b842352706204049">Nest Loop Join</strong>. If this parameter is set to <strong id="EN-US_TOPIC_0000001188482282__b20852350">on</strong>, the optimizer preferentially uses <strong id="EN-US_TOPIC_0000001188482282__b842352706204147">Nest Loop Join</strong>. If it is set to <strong id="EN-US_TOPIC_0000001188482282__b2071530905161511">off</strong>, the optimizer preferentially uses other methods, if any.</p>
|
|
<div class="note" id="EN-US_TOPIC_0000001188482282__n2a6adf8831a04b8dba4ebb4796234597"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="EN-US_TOPIC_0000001188482282__aa738d6e3badd4c97b769f983d685a363">To temporarily change the value of this parameter in the current database connection (that is, the current session), run the following SQL statement:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188482282__sdf12b5bf2baf47959733e81ca7b37f8a"><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">SET</span><span class="w"> </span><span class="n">enable_nestloop</span><span class="w"> </span><span class="k">to</span><span class="w"> </span><span class="k">off</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div></div>
|
|
<p id="EN-US_TOPIC_0000001188482282__ac76fa50609414045913003845549e102">By default, this parameter is set to <strong id="EN-US_TOPIC_0000001188482282__b842352706204649">on</strong>. Change the value as required. Generally, nested loop join has the poorest performance among the three <strong id="EN-US_TOPIC_0000001188482282__b84235270620519">JOIN</strong> methods (nested loop join, merge join, and hash join). You are advised to set this parameter to <strong id="EN-US_TOPIC_0000001188482282__b842352706205148">off</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__r8c8749b7839342fcacaf08ed9e75dfb3"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__acf4f8544705c4de5b66dbcf254d249c0">enable_bitmapscan=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__a584f6419370b4971ab2727bef1a38747">Specifies whether the optimizer uses bitmap scanning. If the value is <strong id="EN-US_TOPIC_0000001188482282__b17591975">on</strong>, bitmap scanning is used. If the value is <strong id="EN-US_TOPIC_0000001188482282__b1714726175161836">off</strong>, it is not used.</p>
|
|
<div class="note" id="EN-US_TOPIC_0000001188482282__nc451e59e47dd4d5e845e7e3303b602aa"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="EN-US_TOPIC_0000001188482282__a318604c014d64f4fa9c576928a46157b">If you only want to temporarily change the value of this parameter during the current database connection (that is, the current session), run the following SQL statements:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188482282__sd7452fa5464c41a9aeba2caa6ad72297"><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">SET</span><span class="w"> </span><span class="n">enable_bitmapscan</span><span class="w"> </span><span class="k">to</span><span class="w"> </span><span class="k">off</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div></div>
|
|
<p id="EN-US_TOPIC_0000001188482282__ac76944843430412a93e7fde6038c4d06">The bitmap scanning applies only in the query condition where <strong id="EN-US_TOPIC_0000001188482282__b84235270613173">a > 1 and b > 1</strong> and indexes are created on columns <strong id="EN-US_TOPIC_0000001188482282__b842352706205816">a</strong> and <strong id="EN-US_TOPIC_0000001188482282__b842352706205820">b</strong>. During performance tuning, if the query performance is poor and bitmapscan operators are in the execution plan, set this parameter to <strong id="EN-US_TOPIC_0000001188482282__b84235270621048">off</strong> and check whether the performance is improved.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__r797f73ee266c44c9895790964bba9b58"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__a179702c3c3fe4b87bffcc32c81b8621c">enable_fast_query_shipping=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__ab9981efbe91f4a76abe472e1bf77b070">Specifies whether the optimizer uses a distribution framework. If the value is <strong id="EN-US_TOPIC_0000001188482282__b12329649">on</strong>, the execution plan is generated on both CNs and DNs. If the value is <strong id="EN-US_TOPIC_0000001188482282__b1084894937162137">off</strong>, the distribution framework is used, that is, the execution plan is generated on the CNs and then sent to DNs for execution.</p>
|
|
<div class="note" id="EN-US_TOPIC_0000001188482282__n2b799f1879c444e79676aaef5c28d431"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="EN-US_TOPIC_0000001188482282__acf28372790b54abe81b26951128b5de6">To temporarily change the value of this parameter in the current database connection (that is, the current session), run the following SQL statement:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188482282__s7032c6db5fbd41058201d091997391c6"><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">SET</span><span class="w"> </span><span class="n">enable_fast_query_shipping</span><span class="w"> </span><span class="k">to</span><span class="w"> </span><span class="k">off</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div></div>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__ra3fc59f49c704b12ae3e0f37feb551ea"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__aede5354e563040159c3acd3e3f508fc9">enable_hashagg=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__a782b876fa82944d9812296dbf472864e">Specifies whether to enable the optimizer's use of Hash-aggregation plan types.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__rd0ca66a52d2a40a693c7b739e46faf44"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__a75b346774e2348a68d8572379f9a52ce">enable_hashjoin=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__a9b62a53403fc4d1297bd349dc268169d">Specifies whether to enable the optimizer's use of Hash-join plan types.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__r75ad47314171442c93730ada16c4a445"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__a645d1829371543429be18d89f0d0ea98">enable_mergejoin=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__a8ed925c95cd14c138fdd415f48d33e52">Specifies whether to enable the optimizer's use of Hash-merge plan types.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__r7c8b70409f2b4aa9980e36d9a78a9544"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__a6702a6a865234c788dc7b0d78d082c3c">enable_indexscan=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__ab1186d35275b478eab02fc4131289994">Specifies whether to enable the optimizer's use of index-scan plan types.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__r0e6ef8d148ad4c0889e514aab2e78189"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__ae2decad7c42347219cdda5399a07a2cb">enable_indexonlyscan=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__a2653f011c9f442dda5dd1445864b21fb">Specifies whether to enable the optimizer's use of index-only-scan plan types.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__r6f777c61d09a456fa310c37fb6d20afa"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__afc6945c37692402988d5aa0b42e89999">enable_seqscan=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__ae706f553e65f440490f3c767c28c425f">Specifies whether the optimizer uses bitmap scanning. It is impossible to suppress sequential scans entirely, but setting this variable to <strong id="EN-US_TOPIC_0000001188482282__b41076330152658">off</strong> allows the optimizer to preferentially choose other methods if available.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__rd0adb902fcde417398436349b9a8866b"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__a85f1a38b791c417cb34de47a5a1f512c">enable_sort=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__ac184887fc9914123b9ea48e8987843d2">Specifies the optimizer sorts. It is impossible to fully suppress explicit sorts, but setting this variable to <strong id="EN-US_TOPIC_0000001188482282__en-us_topic_0058968309_b22292535152658">off</strong> allows the optimizer to preferentially choose other methods if available.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__r931ae054e818406db535b63b01c452c9"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__af42b486887224fc69b9e5f955096159c">enable_broadcast=on</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__ab822d758c2eb4ec29a63ee86ffa20ab1">Specifies whether enable the optimizer's use of data broadcast. In data broadcast, a large amount of data is transferred on the network. When the number of transmission nodes (stream) is large and the estimation is inaccurate, set this parameter to <strong id="EN-US_TOPIC_0000001188482282__b84235270613279">off</strong> and check whether the performance is improved.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188482282__row91254119407"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482282__p5125511194014">rewrite_rule</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482282__p3125411124017">Specifies whether the optimizer enables a specific rewriting rule.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0430.html">SQL Optimization Guide</a></div>
|
|
</div>
|
|
</div>
|
|
|