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>
19 lines
3.0 KiB
HTML
19 lines
3.0 KiB
HTML
<a name="EN-US_TOPIC_0000001330329176"></a><a name="EN-US_TOPIC_0000001330329176"></a>
|
|
|
|
<h1 class="topictitle1">Why Is SQL Execution Slow After Long GaussDB(DWS) Usage?</h1>
|
|
<div id="body0000001330329176"><p id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_p45396318595">After a database is used for a period of time, the table data increases as services grow, or the table data is frequently added, deleted, or modified. As a result, bloating tables and inaccurate statistics are incurred, deteriorating database performance.</p>
|
|
<p id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_p8060118">You are advised to periodically run <strong id="EN-US_TOPIC_0000001330329176__b94348218993213">VACUUM FULL</strong> and <strong id="EN-US_TOPIC_0000001330329176__b13780791893213">ANALYZE</strong> on tables that are frequently added, deleted, or modified. Perform the following operations:</p>
|
|
<ol id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_ol349260184"><li id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_li154916111817"><span>By default, 100 out of 30,000 records of statistics are collected. When a large amount of data is involved, the SQL execution is unstable, which may be caused by a changed execution plan. In this case, the sampling rate needs to be adjusted for statistics. You can run <strong id="EN-US_TOPIC_0000001330329176__b44705822493213">set default_statistics_target</strong> to increase the sampling rate, which helps the optimizer generate the optimal plan.</span><p><p id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_p817743916198"><span><img id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_image11771439181918" src="figure/en-us_image_0000001381728713.png"></span></p>
|
|
</p></li><li id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_li17492061187"><span>Run <strong id="EN-US_TOPIC_0000001330329176__b15295135992012">ANALYZE</strong> again. For details, see "ANALYZE | ANALYSE" in the <em id="EN-US_TOPIC_0000001330329176__i117040684893213">Developer Guide</em>.</span><p><p id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_p7111105992314"><span><img id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_image111135942313" src="figure/en-us_image_0000001381889321.png"></span></p>
|
|
</p></li></ol>
|
|
<div class="note" id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_note5791915164318"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_p202661848124413">To test whether disk fragments affect database performance, use the following function:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001330329176__en-us_topic_0000001145816583_screen8186212452">SELECT * FROM pgxc_get_stat_dirty_tables(30,100000);</pre>
|
|
</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>
|
|
|