forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
19 lines
2.9 KiB
HTML
19 lines
2.9 KiB
HTML
<a name="EN-US_TOPIC_0000001146626780"></a><a name="EN-US_TOPIC_0000001146626780"></a>
|
|
|
|
<h1 class="topictitle1">Why Is SQL Execution Slow After Long GaussDB(DWS) Usage?</h1>
|
|
<div id="body8662426"><p id="EN-US_TOPIC_0000001146626780__en-us_topic_0000001145816583_p45396318595">When 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. This results in bloating tables and inaccurate statistics, deteriorating database performance.</p>
|
|
<p id="EN-US_TOPIC_0000001146626780__en-us_topic_0000001145816583_p8060118">You are advised to periodically perform <strong id="EN-US_TOPIC_0000001146626780__b146701353181719">VACUUM FULL</strong> and <strong id="EN-US_TOPIC_0000001146626780__b146701653141714">ANALYZE</strong> on tables that are frequently added, deleted, or modified.</p>
|
|
<ol id="EN-US_TOPIC_0000001146626780__en-us_topic_0000001145816583_ol349260184"><li id="EN-US_TOPIC_0000001146626780__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_0000001146626780__b1894512170516">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_0000001146626780__en-us_topic_0000001145816583_p817743916198"><span><img id="EN-US_TOPIC_0000001146626780__image11771439181918" src="figure/en-us_image_0000001192746637.png"></span></p>
|
|
</p></li><li id="EN-US_TOPIC_0000001146626780__en-us_topic_0000001145816583_li17492061187"><span>Perform <strong id="EN-US_TOPIC_0000001146626780__b31167277513">ANALYZE</strong> again. For details, see "ANALYZE | ANALYSE" in the <em id="EN-US_TOPIC_0000001146626780__en-us_topic_0000001145816583_i185616294513">Developer Guide</em>.</span><p><p id="EN-US_TOPIC_0000001146626780__en-us_topic_0000001145816583_p7111105992314"><span><img id="EN-US_TOPIC_0000001146626780__image1095717048" src="figure/en-us_image_0000001146626882.png"></span></p>
|
|
</p></li></ol>
|
|
<div class="note" id="EN-US_TOPIC_0000001146626780__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_0000001146626780__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_0000001146626780__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>
|
|
|