forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Reviewed-by: Rechenburg, Matthias <matthias.rechenburg@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
60 lines
12 KiB
HTML
60 lines
12 KiB
HTML
<a name="EN-US_TOPIC_0000001533476366"></a><a name="EN-US_TOPIC_0000001533476366"></a>
|
|
|
|
<h1 class="topictitle1">Why the Tasks Executed by an Ordinary User Are Slower Than That Executed by the dbadmin User?</h1>
|
|
<div id="body0000001533476366"><p id="EN-US_TOPIC_0000001533476366__p8060118">The execution speed of an ordinary user is slower than that of the dbadmin user in the following scenarios:</p>
|
|
<div class="section" id="EN-US_TOPIC_0000001533476366__section987518164715"><h4 class="sectiontitle">Scenario 1: Ordinary users are subject to resource management.</h4><p id="EN-US_TOPIC_0000001533476366__p39771181275">Ordinary users queuing: <strong id="EN-US_TOPIC_0000001533476366__b9235132313156">waiting in queue/waiting in global queue/waiting in ccn queue</strong></p>
|
|
<ol id="EN-US_TOPIC_0000001533476366__ol11292115919515"><li id="EN-US_TOPIC_0000001533476366__li5292175920517">Ordinary users will be <strong id="EN-US_TOPIC_0000001533476366__b130813020247">waiting in queue/waiting in global queue</strong> when the number of active statements exceeds the value of <strong id="EN-US_TOPIC_0000001533476366__b1615104752618">max_active_statements</strong>. While administrators do not need to queue.<p id="EN-US_TOPIC_0000001533476366__p105896512529">You can increase the value of this parameter or clear some statements to avoid queuing.</p>
|
|
<p id="EN-US_TOPIC_0000001533476366__en-us_topic_0000001081821913_p176990581261">Change the value of <strong id="EN-US_TOPIC_0000001533476366__b12567185192818">max_active_statements</strong> on the management console.</p>
|
|
<ol type="a" id="EN-US_TOPIC_0000001533476366__en-us_topic_0000001081821913_ol15504184015616"><li id="EN-US_TOPIC_0000001533476366__en-us_topic_0000001081821913_li250418407611">Log in to the GaussDB(DWS) management console.</li><li id="EN-US_TOPIC_0000001533476366__en-us_topic_0000001081821913_li25046401764">In the navigation tree on the left, choose <strong id="EN-US_TOPIC_0000001533476366__b1450515415359">Clusters</strong> > <strong id="EN-US_TOPIC_0000001533476366__b421019793512">Dedicated Clusters</strong>.</li><li id="EN-US_TOPIC_0000001533476366__en-us_topic_0000001081821913_li1050414402614">In the cluster list, find the target cluster and click the cluster name. The <span class="wintitle" id="EN-US_TOPIC_0000001533476366__wintitle14881577003422"><b>Basic Information</b></span> page is displayed.</li><li id="EN-US_TOPIC_0000001533476366__en-us_topic_0000001081821913_li21833413716">Go to the <span class="wintitle" id="EN-US_TOPIC_0000001533476366__en-us_topic_0000001081821913_wintitle36801517161117"><b>Parameter Modifications</b></span> page of the cluster, search for the <strong id="EN-US_TOPIC_0000001533476366__b13110114272818">max_active_statements</strong> parameter, change its value, and click <span class="uicontrol" id="EN-US_TOPIC_0000001533476366__en-us_topic_0000001081821913_uicontrol193071952183210"><b>Save</b></span>.</li></ol>
|
|
</li><li id="EN-US_TOPIC_0000001533476366__li6152193011524">It takes a long time for ordinary users to wait in the ccn queue. When dynamic resource management is enabled (<strong id="EN-US_TOPIC_0000001533476366__b866165514334">enable_dynamic_workload</strong> is set to <strong id="EN-US_TOPIC_0000001533476366__b32195763311">on</strong>), if the concurrency is high and the available memory is small, ordinary users may get into this state when executing statements. Administrators are not controlled. You can stop some statements or increase the memory parameter value. If the memory usage of each DN is not high, you can disable the dynamic resource management parameter <strong id="EN-US_TOPIC_0000001533476366__b1686352513358">enable_dynamic_workload</strong> by setting it to <strong id="EN-US_TOPIC_0000001533476366__b448518528355">off</strong>.</li></ol>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001533476366__section1270915186144"><h4 class="sectiontitle">Scenario 2: The <strong id="EN-US_TOPIC_0000001533476366__b1138063318394">OR</strong> condition in the execution plan checks the statements executed by common users one by one. This consumes a lot of time.</h4><p id="EN-US_TOPIC_0000001533476366__p16390622191420">The <strong id="EN-US_TOPIC_0000001533476366__b83541224164112">OR</strong> conditions in the execution plans contain permission-related checks. This scenario usually occurs when the system view is used. For example, in the following SQL statement:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001533476366__screen203206380155"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span>
|
|
<span class="normal">3</span>
|
|
<span class="normal">4</span>
|
|
<span class="normal">5</span>
|
|
<span class="normal">6</span>
|
|
<span class="normal">7</span>
|
|
<span class="normal">8</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="k">distinct</span><span class="p">(</span><span class="n">dtp</span><span class="p">.</span><span class="k">table_name</span><span class="p">),</span>
|
|
<span class="w"> </span><span class="n">ta</span><span class="p">.</span><span class="n">table_catalog</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="n">ta</span><span class="p">.</span><span class="n">table_schema</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="n">ta</span><span class="p">.</span><span class="k">table_name</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="n">ta</span><span class="p">.</span><span class="n">table_type</span><span class="w"> </span>
|
|
<span class="k">from</span><span class="w"> </span><span class="n">information_schema</span><span class="p">.</span><span class="n">tables</span><span class="w"> </span><span class="n">ta</span><span class="w"> </span><span class="k">left</span><span class="w"> </span><span class="k">outer</span><span class="w"> </span><span class="k">join</span><span class="w"> </span><span class="n">DBA_TAB_PARTITIONS</span><span class="w"> </span><span class="n">dtp</span><span class="w"> </span>
|
|
<span class="k">on</span><span class="w"> </span><span class="p">(</span><span class="n">dtp</span><span class="p">.</span><span class="k">schema</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ta</span><span class="p">.</span><span class="n">table_schema</span><span class="w"> </span><span class="k">and</span><span class="w"> </span><span class="n">dtp</span><span class="p">.</span><span class="k">table_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ta</span><span class="p">.</span><span class="k">table_name</span><span class="p">)</span><span class="w"> </span>
|
|
<span class="k">where</span><span class="w"> </span><span class="n">ta</span><span class="p">.</span><span class="n">table_schema</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'public'</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001533476366__p670945316166">Part of the execution plan is as follows:</p>
|
|
<p id="EN-US_TOPIC_0000001533476366__p121051325101613"><span><img id="EN-US_TOPIC_0000001533476366__image676214279161" src="figure/en-us_image_0000001533637710.png" title="Click to enlarge" class="imgResize"></span></p>
|
|
<p id="EN-US_TOPIC_0000001533476366__p189417468245">In the system view, the <strong id="EN-US_TOPIC_0000001533476366__b1313143724215">OR</strong> condition is used for permission check.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001533476366__screen169616201219"><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">pg_has_role</span><span class="p">(</span><span class="k">c</span><span class="p">.</span><span class="n">relowner</span><span class="p">,</span><span class="w"> </span><span class="s1">'USAGE'</span><span class="p">::</span><span class="nb">text</span><span class="p">)</span><span class="w"> </span><span class="k">OR</span><span class="w"> </span><span class="n">has_table_privilege</span><span class="p">(</span><span class="k">c</span><span class="p">.</span><span class="n">oid</span><span class="p">,</span><span class="w"> </span><span class="s1">'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'</span><span class="p">::</span><span class="nb">text</span><span class="p">)</span><span class="w"> </span><span class="k">OR</span><span class="w"> </span><span class="n">has_any_column_privilege</span><span class="p">(</span><span class="k">c</span><span class="p">.</span><span class="n">oid</span><span class="p">,</span><span class="w"> </span><span class="s1">'SELECT, INSERT, UPDATE, REFERENCES'</span><span class="p">::</span><span class="nb">text</span><span class="p">)</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001533476366__p13545212112514"><strong id="EN-US_TOPIC_0000001533476366__b13861191719451">true</strong> is always returned for <strong id="EN-US_TOPIC_0000001533476366__b54741117436">pg_has_role</strong> of the <strong id="EN-US_TOPIC_0000001533476366__b21228580445">dbadmin</strong> use. Therefore, the conditions after <strong id="EN-US_TOPIC_0000001533476366__b1696094724514">OR</strong> do not need to be checked.</p>
|
|
<p id="EN-US_TOPIC_0000001533476366__p126974195178">While the <strong id="EN-US_TOPIC_0000001533476366__b1641717599461">OR</strong> conditions of an ordinary user need to be checked one by one. If there are a large number of tables in the database, the execution time of the ordinary user is longer than that of the <strong id="EN-US_TOPIC_0000001533476366__b9658731194716">dbadmin</strong> user.</p>
|
|
<p id="EN-US_TOPIC_0000001533476366__p969741971710">In this scenario, if the number of output result sets is small, you can set <strong id="EN-US_TOPIC_0000001533476366__b12176163785214">set enable_hashjoin</strong> and <strong id="EN-US_TOPIC_0000001533476366__b79981252195211">enable_seqscan</strong> to <strong id="EN-US_TOPIC_0000001533476366__b17801164420529">off</strong>, to use the index+nestloop plan.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001533476366__section1944523211179"><h4 class="sectiontitle">Scenario 3: The resource pools allocated to ordinary users and administrators are different.</h4><p id="EN-US_TOPIC_0000001533476366__p1757202314585">Run the following command to check whether the resource pools corresponding to an ordinary user are the same as that of the administrator user. If they are different, check whether the tenant resources allocated to the two users are different.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001533476366__screen10419541115810"><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">SELECt</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">pg_user</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_03_0035.html">Database Performance</a></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script language="JavaScript">
|
|
<!--
|
|
image_size('.imgResize');
|
|
var msg_imageMax = "view original image";
|
|
var msg_imageClose = "close";
|
|
//--></script> |