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>
25 lines
3.5 KiB
HTML
25 lines
3.5 KiB
HTML
<a name="EN-US_TOPIC_0000001192746535"></a><a name="EN-US_TOPIC_0000001192746535"></a>
|
|
|
|
<h1 class="topictitle1">Do I Need to Run VACUUM FULL and ANALYZE on Common Tables Periodically?</h1>
|
|
<div id="body8662426"><p id="EN-US_TOPIC_0000001192746535__en-us_topic_0000001145816511_p99751926195117">Yes. For tables that involve frequent add, delete, or modify operations, perform <strong id="EN-US_TOPIC_0000001192746535__b921904815263">VACUUM FULL</strong> and <strong id="EN-US_TOPIC_0000001192746535__b15220174813269">ANALYZE</strong> to reclaim the disk space occupied by updated or deleted data, preventing performance deterioration caused by data expansion and inaccurate statistics.</p>
|
|
<p id="EN-US_TOPIC_0000001192746535__en-us_topic_0000001145816511_p135821048115418">Generally, you are advised to use <strong id="EN-US_TOPIC_0000001192746535__b529173814211">ANALYZE</strong> after multiple add and modify operations are performed on a table, and use <strong id="EN-US_TOPIC_0000001192746535__b1342782518455">VACUUM FULL</strong> after delete operations are performed. <strong id="EN-US_TOPIC_0000001192746535__b14556138184712">VACUUM FULL</strong> can be used only on special occasions, such as when you want to physically narrow a table to decrease the occupied disk space after deleting most rows of the table. <strong id="EN-US_TOPIC_0000001192746535__b122891534124915">VACUUM FULL</strong> usually shrinks a table more than <strong id="EN-US_TOPIC_0000001192746535__b8295183444911">VACUUM</strong> does.</p>
|
|
<div class="section" id="EN-US_TOPIC_0000001192746535__en-us_topic_0000001145816511_section1865663735214"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="EN-US_TOPIC_0000001192746535__en-us_topic_0000001145816511_screen4910132813119">-- Perform <strong id="EN-US_TOPIC_0000001192746535__b5280817195117">ANALYZE</strong> on a table.
|
|
ANALYZE <em id="EN-US_TOPIC_0000001192746535__i09141915500">Table name</em>;
|
|
-- Perform <strong id="EN-US_TOPIC_0000001192746535__b12573134918512">ANALYZE</strong> on all tables (non-foreign tables) in the database.
|
|
ANALYZE;
|
|
-- Perform <strong id="EN-US_TOPIC_0000001192746535__b1560161917508">VACUUM</strong> on a table.
|
|
VACUUM <em id="EN-US_TOPIC_0000001192746535__i116914486523">Table name</em>;
|
|
-- -- Perform <strong id="EN-US_TOPIC_0000001192746535__b521513517524">VACUUM FULL</strong> on a table.
|
|
VACUUM FULL <em id="EN-US_TOPIC_0000001192746535__i262568105312">Table_name</em>;</pre>
|
|
<p id="EN-US_TOPIC_0000001192746535__en-us_topic_0000001145816511_p98619201484">For details, see in "VACUUM" and "ANALYZE | ANALYSE" in the <em id="EN-US_TOPIC_0000001192746535__en-us_topic_0000001145816511_i54813415558">Developer Guide</em>.</p>
|
|
<div class="note" id="EN-US_TOPIC_0000001192746535__en-us_topic_0000001145816511_note548518259111"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001192746535__en-us_topic_0000001145816511_p44859252115">If the physical space usage does not decrease after you run the <strong id="EN-US_TOPIC_0000001192746535__b10267164105713">VACUUM FULL</strong> command, check whether there were other active transactions (started before you delete data transactions and not ended before you run <strong id="EN-US_TOPIC_0000001192746535__b151151211151120">VACUUM FULL</strong>). If yes, run this command again when the transactions have finished.</p>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_03_0065.html">Database Usage</a></div>
|
|
</div>
|
|
</div>
|
|
|