Files
doc-exports/docs/dws/dev/dws_04_0453.html
Lu, Huayi ef0ada5a59 DWS DEV 20240716 version
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>
2024-11-02 09:07:47 +00:00

105 lines
16 KiB
HTML

<a name="EN-US_TOPIC_0000001629230077"></a><a name="EN-US_TOPIC_0000001629230077"></a>
<h1 class="topictitle1">Adjusting Key Parameters During SQL Tuning</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_a64f605245dcf406aac16d5a75afd84d5">This section describes key CN parameters that affect <span id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_text650549764">GaussDB(DWS)</span> SQL optimization performance. For details about how to configure these parameters, see section <a href="dws_04_0885.html">Configuring GUC Parameters</a> in the .</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_ad39d2792a8e14f92b598d05fb2e19e27">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_aecfbd5f3946b4f9a887d8a7b83939668">Specifies how the optimizer uses <strong id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_b842352706204049">Nest Loop Join</strong>. If this parameter is set to <strong id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_b20852350">on</strong>, the optimizer preferentially uses <strong id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_b842352706204147">Nest Loop Join</strong>. If it is set to <strong id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_b2071530905161511">off</strong>, the optimizer preferentially uses other methods, if any.</p>
<div class="note" id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_n2a6adf8831a04b8dba4ebb4796234597"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_ac76fa50609414045913003845549e102">By default, this parameter is set to <strong id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_b842352706205148">off</strong>.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_a584f6419370b4971ab2727bef1a38747">Specifies whether the optimizer uses bitmap scanning. If the value is <strong id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_b17591975">on</strong>, bitmap scanning is used. If the value is <strong id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_b1714726175161836">off</strong>, it is not used.</p>
<div class="note" id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_nc451e59e47dd4d5e845e7e3303b602aa"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_ac76944843430412a93e7fde6038c4d06">The bitmap scanning applies only in the query condition where <strong id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_b84235270613173">a &gt; 1 and b &gt; 1</strong> and indexes are created on columns <strong id="EN-US_TOPIC_0000001629230077__en-us_topic_0000001188482282_b842352706205816">a</strong> and <strong id="EN-US_TOPIC_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_b84235270621048">off</strong> and check whether the performance is improved.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_ab9981efbe91f4a76abe472e1bf77b070">Specifies whether the optimizer uses a distribution framework. If the value is <strong id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_n2b799f1879c444e79676aaef5c28d431"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__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_0000001629230077__en-us_topic_0000001188482282_b84235270613279">off</strong> and check whether the performance is improved.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001629230077__row88551653183416"><td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001629230077__p1885595393414">enable_redistribute=on</p>
<p id="EN-US_TOPIC_0000001629230077__p177211414251">This parameter is supported only by clusters of version 8.2.1.300 or later.</p>
</td>
<td class="cellrowborder" valign="top" width="73.5%" headers="mcps1.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001629230077__p14855145393420">Controls the query optimizer's use of data transmission in <strong id="EN-US_TOPIC_0000001629230077__b05010251642">local redistribute</strong> and <strong id="EN-US_TOPIC_0000001629230077__b690952910416">split redistribute</strong> redistribution modes. This parameter corresponds to <strong id="EN-US_TOPIC_0000001629230077__b177306361414">enable_broadcast</strong>. The optimizer may overestimate the cost of <strong id="EN-US_TOPIC_0000001629230077__b551443352">local broadcast</strong> and <strong id="EN-US_TOPIC_0000001629230077__b13690135016517">split broadcast</strong>. As a result, the optimizer selects the <strong id="EN-US_TOPIC_0000001629230077__b1982061765">local redistribute</strong> or <strong id="EN-US_TOPIC_0000001629230077__b26521991661">split redistribute</strong> redistribution plan. This may cause performance deterioration. Therefore, when the actual data volume of the network transmission node (stream) is small, you can set this parameter to <strong id="EN-US_TOPIC_0000001629230077__b1458772619613">off</strong> so that the optimizer preferentially selects the <strong id="EN-US_TOPIC_0000001629230077__b77411734161">broadcast</strong> mode. Then you can check whether the performance is improved.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001629230077__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_0000001629230077__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_0000001629230077__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>