forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: luhuayi <luhuayi@huawei.com> Co-committed-by: luhuayi <luhuayi@huawei.com>
92 lines
33 KiB
HTML
92 lines
33 KiB
HTML
<a name="EN-US_TOPIC_0000001764516338"></a><a name="EN-US_TOPIC_0000001764516338"></a>
|
|
|
|
<h1 class="topictitle1">VACUUM</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001764516338__s5f7bdd0d4677446eaa64ae35d4e4368e"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001764516338__a780d55c706514bef9dbf326f1f30a4d4"><strong id="EN-US_TOPIC_0000001764516338__b19257182614402">VACUUM</strong> reclaims storage space occupied by tables or B-tree indexes. In normal database operation, rows that have been deleted are not physically removed from their table; they remain present until a <strong id="EN-US_TOPIC_0000001764516338__b1738963220409">VACUUM</strong> is done. Therefore, it is necessary to execute <strong id="EN-US_TOPIC_0000001764516338__b56508115015">VACUUM</strong> periodically, especially on frequently-updated tables.</p>
|
|
<p id="EN-US_TOPIC_0000001764516338__a179e79d60dad4271ba132f8b142a71a1"></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001764516338__s7e5c0f0dc67f4d92bd42a90da65bdd56"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001764516338__u216339b873a44c2696c2ba1bc1de4585"><li id="EN-US_TOPIC_0000001764516338__li139421524202111">With no table specified, <strong id="EN-US_TOPIC_0000001764516338__b65171128220">VACUUM</strong> processes all the tables that the current user has permission to vacuum in the current database. With a table specified, <strong id="EN-US_TOPIC_0000001764516338__b1337720401027">VACUUM</strong> processes only that table.</li><li id="EN-US_TOPIC_0000001764516338__lfd3d3ab4e6d64da29c2a8fb4f099f397">To perform <strong id="EN-US_TOPIC_0000001764516338__b13962152404016">VACUUM</strong> on a table, you must be the owner of the table, granted with the <strong id="EN-US_TOPIC_0000001764516338__b09633247408">VACUUM</strong> permission on the table, or granted with the <strong id="EN-US_TOPIC_0000001764516338__b3964102444020">gs_role_vacuum_any</strong> role. By default, a system administrator has this permission. However, database owners are allowed to <strong id="EN-US_TOPIC_0000001764516338__b126961147191619">VACUUM</strong> all tables in their databases, except shared catalogs. (The restriction for shared catalogs means that a true database-wide <strong id="EN-US_TOPIC_0000001764516338__b6102617615442">VACUUM</strong> can only be executed by the system administrator). <strong id="EN-US_TOPIC_0000001764516338__b1236468015442">VACUUM</strong> skips over any tables that the calling user does not have the permission to vacuum.</li><li id="EN-US_TOPIC_0000001764516338__l9e21b7f61c554ad0b4973f9586fb6c02"><strong id="EN-US_TOPIC_0000001764516338__b4417326015442">VACUUM</strong> cannot be executed inside a transaction block.</li><li id="EN-US_TOPIC_0000001764516338__l383522e91af241e681662fecd8c60100">It is recommended that active production databases be vacuumed frequently (at least nightly), in order to remove dead rows. After adding or deleting a large number of rows, it might be a good idea to execute the <strong id="EN-US_TOPIC_0000001764516338__b6201502015442">VACUUM ANALYZE</strong> command for the affected table. This will update the system catalogs with the results of all recent changes, and allow the query planner to make better choices in planning queries.</li><li id="EN-US_TOPIC_0000001764516338__l2bab399527cd4b2fa97a2da4da801b80"><strong id="EN-US_TOPIC_0000001764516338__b50637766161821">FULL</strong> is recommended only in special scenarios. For example, you wish to physically narrow the table to decrease the occupied disk space after deleting most rows of a table. <strong id="EN-US_TOPIC_0000001764516338__b187018472162">VACUUM FULL</strong> usually shrinks more table size than <strong id="EN-US_TOPIC_0000001764516338__b15701134713161">VACUUM</strong>. If the physical space usage does not decrease after you run the command, check whether there are other active transactions (that have started before you delete data transactions and not ended before you run <strong id="EN-US_TOPIC_0000001764516338__b151151211151120">VACUUM FULL</strong>). If there are such transactions, run this command again when the transactions quit.</li><li id="EN-US_TOPIC_0000001764516338__l0a6727aa520e416082e887b896e61a99"><strong id="EN-US_TOPIC_0000001764516338__b6661830315442">VACUUM</strong> causes a substantial increase in I/O traffic, which might cause poor performance for other active sessions. Therefore, it is sometimes advisable to use the cost-based VACUUM delay feature.</li><li id="EN-US_TOPIC_0000001764516338__l9bade9059c964dd88290ec76ff1149e5">When <strong id="EN-US_TOPIC_0000001764516338__b6269381615442">VERBOSE</strong> is specified, <strong id="EN-US_TOPIC_0000001764516338__b2737343715442">VACUUM</strong> prints progress messages to indicate which table is currently being processed. Various statistics about the tables are printed as well. </li><li id="EN-US_TOPIC_0000001764516338__l0995fb8a8957452e9dd55c61e76e6780">When the option list is surrounded by parentheses, the options can be written in any order. If there are no brackets, the options must be given in the order displayed in the syntax.</li><li id="EN-US_TOPIC_0000001764516338__li17588174212372"><strong id="EN-US_TOPIC_0000001764516338__b9738437287">VACUUM</strong> and <strong id="EN-US_TOPIC_0000001764516338__b1673943711816">VACUUM FULL</strong> clear deleted tuples after the delay specified by <strong id="EN-US_TOPIC_0000001764516338__b27402371386">vacuum_defer_cleanup_age</strong>.</li><li id="EN-US_TOPIC_0000001764516338__li18270174310219"><strong id="EN-US_TOPIC_0000001764516338__b55386423413">VACUUM ANALYZE</strong> executes a VACUUM operation and then an ANALYZE operation for each selected table. This is a handy combination form for routine maintenance scripts.</li><li id="EN-US_TOPIC_0000001764516338__li879952162614">Plain <strong id="EN-US_TOPIC_0000001764516338__b3428328815015">VACUUM</strong> (without <strong id="EN-US_TOPIC_0000001764516338__b4011414415015">FULL</strong>) recycles space and makes it available for reuse. This form of the command can operate in parallel with normal reading and writing of the table, as an exclusive lock is not obtained. <strong id="EN-US_TOPIC_0000001764516338__b2548298015015">VACUUM FULL</strong> executes wider processing, including moving rows across blocks to compress tables so they occupy minimum number of disk blocks. This form is much slower and requires an exclusive lock on each table while it is being processed.</li><li id="EN-US_TOPIC_0000001764516338__li664011311819">During VACUUM on column-store tables, four internal operations occur: VACUUM on the primary table, VACUUM on the Desc table of the primary table, VACUUM on the delta table of the primary table, and migration of data from the delta table to the primary table. <strong id="EN-US_TOPIC_0000001764516338__b142413694014">VACUUM</strong> does not reclaim the storage space of the delta table. To reclaim it, do <strong id="EN-US_TOPIC_0000001764516338__b154873823710">VACUUM DELTAMERGE</strong> to the column-store table. By default, the VACUUM primary table operation is enabled. You can disable this function by setting the <strong id="EN-US_TOPIC_0000001764516338__b15448150182111">colvacuum_threshold_scale_factor</strong> parameter.</li><li id="EN-US_TOPIC_0000001764516338__li12507161710108">The <strong id="EN-US_TOPIC_0000001764516338__b1591522123516">VACUUM</strong> operation on column-store primary tables does not support temporary tables, multi-temperature tables, and time series tables.</li><li id="EN-US_TOPIC_0000001764516338__li187032581117">The <strong id="EN-US_TOPIC_0000001764516338__b7983174415347">VACUUM</strong> operation on column-store primary tables reclaims space with a delay. To reclaim space immediately, run the <strong id="EN-US_TOPIC_0000001764516338__b1430511623617">vac_fileclear_relation</strong> function after VACUUM is executed. Then, an exclusive lock is added to a specified table to reclaim its space.</li><li id="EN-US_TOPIC_0000001764516338__li16984175473614">Running <strong id="EN-US_TOPIC_0000001764516338__b187401510215">VACUUM FULL</strong> on system catalogs can only be done when the database is offline. Otherwise, table locks, exceptions, and errors may occur.</li><li id="EN-US_TOPIC_0000001764516338__li1039564945512">If you perform VACUUM FULL when a long-running query accesses a system table, the long-running query may prevent VACUUM FULL from accessing the system table. As a result, the connection times out and an error is reported.</li><li id="EN-US_TOPIC_0000001764516338__li629385684114">Running <strong id="EN-US_TOPIC_0000001764516338__b1063637892103655">VACUUM FULL</strong> on a column-store partitioned table locks the table and its partitions.</li><li id="EN-US_TOPIC_0000001764516338__li1754316493269">A distributed deadlock may occur when VACUUM FULL and DML statements run concurrently in the following scenarios:<ul id="EN-US_TOPIC_0000001764516338__ul1089017812293"><li id="EN-US_TOPIC_0000001764516338__li9831115102919"><strong id="EN-US_TOPIC_0000001764516338__b1444311133214">VACUUM FULL</strong> on subpartitions and <strong id="EN-US_TOPIC_0000001764516338__b544381319211">INSERT</strong>/<strong id="EN-US_TOPIC_0000001764516338__b17443181320213">UPDATE</strong>/<strong id="EN-US_TOPIC_0000001764516338__b11444151310214">DELETE</strong> on the primary table</li><li id="EN-US_TOPIC_0000001764516338__li672212952916"><strong id="EN-US_TOPIC_0000001764516338__b1461530122113">VACUUM FULL</strong> on a full table and <strong id="EN-US_TOPIC_0000001764516338__b13462930102119">SELECT</strong> on a full table or <strong id="EN-US_TOPIC_0000001764516338__b14631730102111">SELECT</strong> on subpartitions</li></ul>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__li128461710193719">In the storage-compute decoupling architecture, a message is displayed indicating that the full database VACCUM, full database VACUUM FULL, and full database VACUUM DELTAMERGE are not supported.</li></ul>
|
|
<div class="warning" id="EN-US_TOPIC_0000001764516338__note1464181313472"><span class="warningtitle"><img src="public_sys-resources/warning_3.0-en-us.png"> </span><div class="warningbody"><ul id="EN-US_TOPIC_0000001764516338__en-us_topic_0000001188110586_ul9819201616479"><li id="EN-US_TOPIC_0000001764516338__en-us_topic_0000001188110586_li162251446124710">When a <strong id="EN-US_TOPIC_0000001764516338__en-us_topic_0000001188110586_b18440164215120">VACUUM FULL</strong> operation is performed on a table, it triggers table rebuilding. During this rebuilding process, data is dumped into a new data file. Once the rebuilding is complete, the original file is deleted. However, it is important to note that if the table is large, the rebuilding process can consume a significant amount of disk space. When the disk space is insufficient, exercise caution when performing the <strong id="EN-US_TOPIC_0000001764516338__en-us_topic_0000001188110586_b1241135435118">VACUUM FULL</strong> operation on large tables to prevent the cluster from being read-only.</li><li id="EN-US_TOPIC_0000001764516338__en-us_topic_0000001188110586_li168191016104710">Execute <strong id="EN-US_TOPIC_0000001764516338__en-us_topic_0000001188110586_b97241821121412">VACUUM FULL</strong> on tables with a high dirty page rate and small CU ratio exceeding 25% at regular intervals. Perform <strong id="EN-US_TOPIC_0000001764516338__en-us_topic_0000001188110586_b172462151419">VACUUM FULL</strong> on common tables during low-traffic hours and on system tables when they are offline.</li><li id="EN-US_TOPIC_0000001764516338__en-us_topic_0000001188110586_li1733911814715">For more information about development and design specifications, see "GaussDB(DWS) Development and Design Proposal" in the <em id="EN-US_TOPIC_0000001764516338__en-us_topic_0000001188110586_i723692571414">Data Warehouse Service (DWS) Developer Guide</em>.</li></ul>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001764516338__s4b75675b19e94f2495504d35844b9d8c"><h4 class="sectiontitle">Syntax</h4><ul id="EN-US_TOPIC_0000001764516338__u39b8a29fed5d4a5395afcc9a26478535"><li id="EN-US_TOPIC_0000001764516338__l88ef7230373c4283bf45744079953ecc">Reclaim space and update statistics. The keyword sequence must be given in the order in which the syntax is displayed.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__sd21f5016f55343f2836d700533a9cd51"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">FREEZE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">VERBOSE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="err">{</span><span class="k">ANALYZE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">ANALYSE</span><span class="w"> </span><span class="err">}}</span><span class="w"> </span><span class="p">[,...]</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">]</span>
|
|
<span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">(</span><span class="k">column_name</span><span class="w"> </span><span class="p">[,</span><span class="w"> </span><span class="p">...]</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">partition_name</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">];</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l7ebe0c5a127344028b6dedb72126858b">Reclaim space, without updating statistics information.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__s3c5480df05c34bbdb1549263d1b502d5"><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">VACUUM</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="p">[</span><span class="n">COMPACT</span><span class="p">]</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">FREEZE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">VERBOSE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">partition_name</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">];</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l4ea7e71c9b174f669a3b044b14d48a14">Reclaim space and update statistics information, with a specific order of keywords required.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__s9ca41f0090ba42d0b8d94e564ecdab1c"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">FREEZE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">VERBOSE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="k">ANALYZE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">ANALYSE</span><span class="w"> </span><span class="err">}</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">VERBOSE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">(</span><span class="k">column_name</span><span class="w"> </span><span class="p">[,</span><span class="w"> </span><span class="p">...]</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">partition_name</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">];</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l3116df7d0a5348c3b9a0458b427d82fb">For HDFS and column-store tables, migrate data from the delta table to the primary table. The <strong id="EN-US_TOPIC_0000001764516338__b162092181264">partition_name</strong> parameter is supported only by 8.2.1.200 and later cluster versions.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__s254c3369a8824ff9956f4c2beb7d0cdf"><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">VACUUM</span><span class="w"> </span><span class="n">DELTAMERGE</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">][</span><span class="n">partition_name</span><span class="p">];</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l5340ea229cd2495a8dd7c0e38b978bdf">For HDFS tables, delete the empty value partition directory of HDFS table in HDFS storage.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__screen624410348416"><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">VACUUM</span><span class="w"> </span><span class="n">HDFSDIRECTORY</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">];</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001764516338__se83e416dc0b242ca98b7568cca0d3721"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001764516338__uf0e23e064b1f4a23a7c36f51b83c6d9a"><li id="EN-US_TOPIC_0000001764516338__l524bf909d24d42a0889f9f4210f5c660"><strong id="EN-US_TOPIC_0000001764516338__a1bccac88dcf445c295e876f24440c9bd">FULL</strong><p id="EN-US_TOPIC_0000001764516338__a5bec58eb5e1248548f092ba85ca2f9f4">Selects "FULL" vacuum, which can reclaim more space, but takes much longer and exclusively locks the table.</p>
|
|
<p id="EN-US_TOPIC_0000001764516338__aa42be404223a48a49d7f76d2daaf1e08"><strong id="EN-US_TOPIC_0000001764516338__b842352706164957">FULL</strong> options can also contain the <strong id="EN-US_TOPIC_0000001764516338__b842352706165018">COMPACT</strong> parameter, which is only used for the HDFS table. Specifying the <strong id="EN-US_TOPIC_0000001764516338__b892175117112335">COMPACT</strong> parameter improves <strong id="EN-US_TOPIC_0000001764516338__b514019716112319">VACUUM FULL</strong> operation performance.</p>
|
|
<p id="EN-US_TOPIC_0000001764516338__ac90ba3677dbf483b9e3b40bbd9f54917"><strong id="EN-US_TOPIC_0000001764516338__b842352706165341">COMPACT</strong> and <strong id="EN-US_TOPIC_0000001764516338__b842352706165344">PARTITION</strong> cannot be used at the same time.</p>
|
|
<div class="note" id="EN-US_TOPIC_0000001764516338__n57895ae63892457d800aea87a40bf72d"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764516338__a133139aecff44a10b80c73391a72e3b5">Using <strong id="EN-US_TOPIC_0000001764516338__b18651614151617">FULL</strong> will cause statistics missing. To collect statistics, add the keyword <strong id="EN-US_TOPIC_0000001764516338__b160011119172">ANALYZE</strong> to <strong id="EN-US_TOPIC_0000001764516338__b1185081913171">VACUUM FULL</strong>.</p>
|
|
</div></div>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l51b262d8b6b64691b133af48cea732ad"><strong id="EN-US_TOPIC_0000001764516338__a6e9340ced0084094a6ebdaced44baa1b">FREEZE</strong><p id="EN-US_TOPIC_0000001764516338__a58abd6b93c3e4697a898b75d057c04a8">Is equivalent to executing <strong id="EN-US_TOPIC_0000001764516338__b5005541115263">VACUUM</strong> with the <strong id="EN-US_TOPIC_0000001764516338__b2795648515263">vacuum_freeze_min_age</strong> parameter set to <strong id="EN-US_TOPIC_0000001764516338__b4988279915263">zero</strong>.</p>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l8c7d8b480e4b427ba07e95e817f58f57"><strong id="EN-US_TOPIC_0000001764516338__a88b01d5ef1904ee5b9ebddac91287d87">VERBOSE</strong><p id="EN-US_TOPIC_0000001764516338__a445bdae44d784b2ca1e86c0812f7ad85">Prints a detailed vacuum activity report for each table.</p>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l8bd1eb6b8d9a4be091b980ff32a5004a"><strong id="EN-US_TOPIC_0000001764516338__a3fee0c4c7ceb472dbe7fad548c89c656">ANALYZE | ANALYSE</strong><p id="EN-US_TOPIC_0000001764516338__a246e780aefda41d5a3052589f31d6245">Updates statistics used by the planner to determine the most efficient way to execute a query.</p>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l1ee21fb7ce8a4f0ea39040c12b3c58cd"><strong id="EN-US_TOPIC_0000001764516338__a885f61484dc44005a4c28eb72d84db29">table_name</strong><p id="EN-US_TOPIC_0000001764516338__ad467aa7239404197aa852226a39149c3">Indicates the name (optionally schema-qualified) of a specific table to vacuum.</p>
|
|
<p id="EN-US_TOPIC_0000001764516338__ac96f70dcd0cf43e988ca430aaed24ef4">Value range: The name of a specific table to vacuum. Defaults are all tables in the current database.</p>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l37a69e2ca3054404a702f6248fc8986a"><strong id="EN-US_TOPIC_0000001764516338__a846e9d4698074065a002ad3e6e1ce0bd">column_name</strong><p id="EN-US_TOPIC_0000001764516338__a0e6052d387de4ed0807902e51eff4869">Indicates the name of a specific field to analyze.</p>
|
|
<p id="EN-US_TOPIC_0000001764516338__a67e50e8ba0344c5fbc676abb00b57468">Value range: Indicates the name of a specific field to analyze. Defaults are all columns.</p>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l541d88b952e3461b8646e75f31ba15bc"><strong id="EN-US_TOPIC_0000001764516338__a18bf6d74016845a7823a354e5d67c1aa">PARTITION</strong><p id="EN-US_TOPIC_0000001764516338__p745615302351">HDFS table does not support <strong id="EN-US_TOPIC_0000001764516338__b72289671825653">PARTITION</strong>. <strong id="EN-US_TOPIC_0000001764516338__b120992633125653">COMPACT</strong> and <strong id="EN-US_TOPIC_0000001764516338__b208594738925653">PARTITION</strong> cannot be used at the same time.</p>
|
|
<div class="note" id="EN-US_TOPIC_0000001764516338__note11898153111182"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764516338__p88981031101819">If the <strong id="EN-US_TOPIC_0000001764516338__b70787969425653">PARTITION</strong> and <strong id="EN-US_TOPIC_0000001764516338__b64185315525653">COMPACT</strong> parameters are used at the same time, the following error message is displayed: <strong id="EN-US_TOPIC_0000001764516338__b160073927825653">COMPACT can not be used with PARTITION</strong>.</p>
|
|
</div></div>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__lb45a48b077ef4938aa8e27258f330009"><strong id="EN-US_TOPIC_0000001764516338__a39f9f7f6a0dc4547831d898d6d2030eb">partition_name</strong><p id="EN-US_TOPIC_0000001764516338__a71e10e8f0fad44068e7157c014b747dc">Indicates the partition name of a specific table to vacuum. Defaults are all partitions.</p>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__l39da84c8002046578a19e9c44ca4f025"><strong id="EN-US_TOPIC_0000001764516338__a8dc44d683b564b13a31a144b298b53d8">DELTAMERGE</strong><p id="EN-US_TOPIC_0000001764516338__ab4de1ceec20b46d6901f5c3762f66994">For HDFS tables and column-store tables, migrate data in the delta table of HDFS tables or column-store tables to the primary table. If the data volume of the delta table is less than 60,000 rows, the data will not be migrated. Otherwise, the data will be migrated to HDFS, and the delta table will be cleared by <strong id="EN-US_TOPIC_0000001764516338__b12490613142218">TRUNCATE</strong>. For a column-store table, this operation always transfers all data in the delta table to the CU.</p>
|
|
<div class="note" id="EN-US_TOPIC_0000001764516338__note17960739113014"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764516338__p1396014390304">The following DFX functions are provided to return the data storage in the delta table of a column-store table (for an HDFS table, it can be returned by <strong id="EN-US_TOPIC_0000001764516338__b91894954813">EXPLAIN ANALYZE</strong>):</p>
|
|
<ul id="EN-US_TOPIC_0000001764516338__ul6513181416330"><li id="EN-US_TOPIC_0000001764516338__li1515214113311">pgxc_get_delta_info(TEXT): The input parameter is a column-store table name. The delta table information on each node is collected and displayed, including the number of active tuples, table size, and maximum block ID.</li><li id="EN-US_TOPIC_0000001764516338__li19515914183313">get_delta_info(TEXT): The input parameter is a column-store table name. The system summarizes the results returned from pgxc_get_delta_info and returns the total number of active tuples, total table size, and maximum block ID in the delta table. When querying delta information about a temporary table, you need to specify the schema of the temporary table. Otherwise, an error is reported, indicating that the table cannot be found.</li></ul>
|
|
</div></div>
|
|
</li><li id="EN-US_TOPIC_0000001764516338__leb71aec9ff894fe59875a6eb504d9b21"><strong id="EN-US_TOPIC_0000001764516338__a2f797b6c271c4025bbc29fc9eea5ecbc">HDFSDIRECTORY</strong><p id="EN-US_TOPIC_0000001764516338__a8aa91fe0414e48b4b43eb784e23a8bca">Deletes the empty value partition directory of HDFS table in HDFS storage for HDFS table.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001764516338__s12262122d2d24f618cc6d20821bd0807"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001764516338__p12649163574715">Delete all tables in the current database.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__screen8649133511474"><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">VACUUM</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001764516338__p18386141217413">Reclaim the space of partition <strong id="EN-US_TOPIC_0000001764516338__b929214319402">P2</strong> of the <strong id="EN-US_TOPIC_0000001764516338__b029453114409"><span id="EN-US_TOPIC_0000001764516338__text1829383117400">tpcds.</span>web_returns_p1</strong> table without updating statistics.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__screen6130652195011"><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">VACUUM</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="n">tpcds</span><span class="p">.</span><span class="n">web_returns_p1</span><span class="w"> </span><span class="n">PARTITION</span><span class="p">(</span><span class="n">P2</span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001764516338__p10560366269">Reclaim the space of the <strong id="EN-US_TOPIC_0000001764516338__b84414915385"><span id="EN-US_TOPIC_0000001764516338__text3441189143815">tpcds.</span>web_returns_p1</strong> table and update statistics.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__screen1392110247263"><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">VACUUM</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="k">ANALYZE</span><span class="w"> </span><span class="n">tpcds</span><span class="p">.</span><span class="n">web_returns_p1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001764516338__p964912356478">Delete all tables in the current database and collect statistics about the query optimizer.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__screen19649163517472"><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">VACUUM</span><span class="w"> </span><span class="k">ANALYZE</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001764516338__p1464993511478">Delete only the <strong id="EN-US_TOPIC_0000001764516338__b15539185810385">reason</strong> table.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__screen3649835124710"><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">VACUUM</span><span class="w"> </span><span class="p">(</span><span class="k">VERBOSE</span><span class="p">,</span><span class="w"> </span><span class="k">ANALYZE</span><span class="p">)</span><span class="w"> </span><span class="n">tpcds</span><span class="p">.</span><span class="n">reason</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001764516338__p1950717401285">Perform the <strong id="EN-US_TOPIC_0000001764516338__b10661711173612">DELTAMERGE</strong> operation on the column-store table <strong id="EN-US_TOPIC_0000001764516338__b7245151873610">table_delta</strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__screen165232516819"><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">VACUUM</span><span class="w"> </span><span class="n">DELTAMERGE</span><span class="w"> </span><span class="n">tpcds</span><span class="p">.</span><span class="n">table_delta</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001764516338__p196801115391">Perform the <strong id="EN-US_TOPIC_0000001764516338__b6579624123620">DELTAMERGE</strong> operation only on partition <strong id="EN-US_TOPIC_0000001764516338__b262117288362">p1</strong> of the column-store table <strong id="EN-US_TOPIC_0000001764516338__b10154193115361">table_delta</strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516338__screen1819012247912"><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">VACUUM</span><span class="w"> </span><span class="n">DELTAMERGE</span><span class="w"> </span><span class="n">tpcds</span><span class="p">.</span><span class="n">table_delta</span><span class="w"> </span><span class="n">partition</span><span class="p">(</span><span class="n">p1</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_06_0118.html">DDL Syntax</a></div>
|
|
</div>
|
|
</div>
|
|
|