doc-exports/docs/dws/dev/dws_06_0226.html
Lu, Huayi a24ca60074 DWS DEVELOPER 811 version
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>
2023-01-19 13:37:49 +00:00

89 lines
26 KiB
HTML

<a name="EN-US_TOPIC_0000001145830717"></a><a name="EN-US_TOPIC_0000001145830717"></a>
<h1 class="topictitle1">VACUUM</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001145830717__s5f7bdd0d4677446eaa64ae35d4e4368e"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001145830717__a780d55c706514bef9dbf326f1f30a4d4"><strong id="EN-US_TOPIC_0000001145830717__b19257182614402">VACUUM</strong> reclaims storage space occupied by tables or B-tree indexes. In normal database operation, rows that have been deleted or obsoleted by an update are not physically removed from their table; they remain present until a <strong id="EN-US_TOPIC_0000001145830717__b1738963220409">VACUUM</strong> is done. Therefore, it is necessary to execute <strong id="EN-US_TOPIC_0000001145830717__b56508115015">VACUUM</strong> periodically, especially on frequently-updated tables.</p>
<p id="EN-US_TOPIC_0000001145830717__a179e79d60dad4271ba132f8b142a71a1"></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001145830717__s7e5c0f0dc67f4d92bd42a90da65bdd56"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001145830717__u216339b873a44c2696c2ba1bc1de4585"><li id="EN-US_TOPIC_0000001145830717__li139421524202111">With no table specified, <strong id="EN-US_TOPIC_0000001145830717__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_0000001145830717__b1337720401027">VACUUM</strong> processes only that table.</li><li id="EN-US_TOPIC_0000001145830717__lfd3d3ab4e6d64da29c2a8fb4f099f397">To vacuum a table, you must ordinarily be the table's owner or the system administrator. However, database owners are allowed to <strong id="EN-US_TOPIC_0000001145830717__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_0000001145830717__b6102617615442">VACUUM</strong> can only be executed by the system administrator). <strong id="EN-US_TOPIC_0000001145830717__b1236468015442">VACUUM</strong> skips over any tables that the calling user does not have the permission to vacuum.</li><li id="EN-US_TOPIC_0000001145830717__l9e21b7f61c554ad0b4973f9586fb6c02"><strong id="EN-US_TOPIC_0000001145830717__b4417326015442">VACUUM</strong> cannot be executed inside a transaction block.</li><li id="EN-US_TOPIC_0000001145830717__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_0000001145830717__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 database query optimizer to make better choices in planning user queries.</li><li id="EN-US_TOPIC_0000001145830717__l2bab399527cd4b2fa97a2da4da801b80"><strong id="EN-US_TOPIC_0000001145830717__b50637766161821">FULL</strong> is recommended only in special scenarios. An example is when you have deleted or updated most of the rows in a table and would like the table to physically shrink to occupy less disk space. <strong id="EN-US_TOPIC_0000001145830717__b611512434516">VACUUM FULL</strong> will usually shrink the table more than a plain <strong id="EN-US_TOPIC_0000001145830717__b152621461556">VACUUM</strong> would. 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_0000001145830717__b151151211151120">VACUUM FULL</strong>). If there are such transactions, run this command again when the transactions quit.</li><li id="EN-US_TOPIC_0000001145830717__l0a6727aa520e416082e887b896e61a99"><strong id="EN-US_TOPIC_0000001145830717__b6661830315442">VACUUM</strong> causes a substantial increase in I/O traffic, which might cause poor performance for other active sessions. Therefore, you are advised to do <strong id="EN-US_TOPIC_0000001145830717__b2027861116616">VACUUM</strong> to the database when services are not busy.</li><li id="EN-US_TOPIC_0000001145830717__l9bade9059c964dd88290ec76ff1149e5">When <strong id="EN-US_TOPIC_0000001145830717__b6269381615442">VERBOSE</strong> is specified, <strong id="EN-US_TOPIC_0000001145830717__b2737343715442">VACUUM</strong> prints progress messages to indicate which table is currently being processed. Various statistics about the tables are printed as well. However, if the <strong id="EN-US_TOPIC_0000001145830717__b3239936124014">VERBOSE</strong> option is specified in <strong id="EN-US_TOPIC_0000001145830717__b5244436144013">VACUUM</strong> executed for column-store tables, no output will be displayed.</li><li id="EN-US_TOPIC_0000001145830717__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_0000001145830717__li17588174212372"><strong id="EN-US_TOPIC_0000001145830717__b842352706135448">VACUUM</strong> and <strong id="EN-US_TOPIC_0000001145830717__b842352706135451">VACUUM FULL</strong> clear deleted tuples after the delay specified by <strong id="EN-US_TOPIC_0000001145830717__b84235270613553">vacuum_defer_cleanup_age</strong>.</li><li id="EN-US_TOPIC_0000001145830717__li18270174310219"><strong id="EN-US_TOPIC_0000001145830717__b1883765910718">VACUUM ANALYZE</strong> performs a <strong id="EN-US_TOPIC_0000001145830717__b2095818561973">VACUUM</strong> and then an <strong id="EN-US_TOPIC_0000001145830717__b214313551076">ANALYZE</strong> for each selected table. This is a handy combination form for routine maintenance scripts.</li><li id="EN-US_TOPIC_0000001145830717__li879952162614">Plain <strong id="EN-US_TOPIC_0000001145830717__b99497966652410">VACUUM</strong> (without <strong id="EN-US_TOPIC_0000001145830717__b109213457552410">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_0000001145830717__b46267859052410">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_0000001145830717__li664011311819">When you do <strong id="EN-US_TOPIC_0000001145830717__b463763613374">VACUUM</strong> to a column-store table, the following operations are internally performed: data in the delta table is migrated to the primary table, and the delta and desc tables of the primary table are vacuumed. <strong id="EN-US_TOPIC_0000001145830717__b142413694014">VACUUM</strong> does not reclaim the storage space of the delta table. To reclaim it, do <strong id="EN-US_TOPIC_0000001145830717__b154873823710">VACUUM DELTAMERGE</strong> to the column-store table.</li><li id="EN-US_TOPIC_0000001145830717__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></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001145830717__s4b75675b19e94f2495504d35844b9d8c"><h4 class="sectiontitle">Syntax</h4><ul id="EN-US_TOPIC_0000001145830717__u39b8a29fed5d4a5395afcc9a26478535"><li id="EN-US_TOPIC_0000001145830717__l88ef7230373c4283bf45744079953ecc">Reclaim space and update statistics information, with no requirements for the order of keywords.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001145830717__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="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><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001145830717__l7ebe0c5a127344028b6dedb72126858b">Reclaim space, without updating statistics information.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001145830717__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><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001145830717__l4ea7e71c9b174f669a3b044b14d48a14">Reclaim space and update statistics information, with a specific order of keywords required.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001145830717__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><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001145830717__l3116df7d0a5348c3b9a0458b427d82fb">For HDFS and column-store tables, migrate data from the delta table to the primary table.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001145830717__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="w"></span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001145830717__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_0000001145830717__se137166a469245e9a53a27d466caad8a"><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><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001145830717__se83e416dc0b242ca98b7568cca0d3721"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001145830717__uf0e23e064b1f4a23a7c36f51b83c6d9a"><li id="EN-US_TOPIC_0000001145830717__l524bf909d24d42a0889f9f4210f5c660"><strong id="EN-US_TOPIC_0000001145830717__a1bccac88dcf445c295e876f24440c9bd">FULL</strong><p id="EN-US_TOPIC_0000001145830717__a5bec58eb5e1248548f092ba85ca2f9f4">Selects "FULL" vacuum, which can reclaim more space, but takes much longer and exclusively locks the table. This method also requires additional disk space, because it writes a new copy of the table and does not free the old copy until the operation is complete. Generally, this option is used only when a large amount of space needs to be reclaimed from a table.</p>
<p id="EN-US_TOPIC_0000001145830717__aa42be404223a48a49d7f76d2daaf1e08"><strong id="EN-US_TOPIC_0000001145830717__b842352706164957">FULL</strong> options can also contain the <strong id="EN-US_TOPIC_0000001145830717__b842352706165018">COMPACT</strong> parameter, which is only used for the HDFS table. Specifying the <strong id="EN-US_TOPIC_0000001145830717__b892175117112335">COMPACT</strong> parameter improves <strong id="EN-US_TOPIC_0000001145830717__b514019716112319">VACUUM FULL</strong> operation performance.</p>
<p id="EN-US_TOPIC_0000001145830717__ac90ba3677dbf483b9e3b40bbd9f54917"><strong id="EN-US_TOPIC_0000001145830717__b842352706165341">COMPACT</strong> and <strong id="EN-US_TOPIC_0000001145830717__b842352706165344">PARTITION</strong> cannot be used at the same time.</p>
<div class="note" id="EN-US_TOPIC_0000001145830717__n57895ae63892457d800aea87a40bf72d"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001145830717__a133139aecff44a10b80c73391a72e3b5">Using <strong id="EN-US_TOPIC_0000001145830717__b18651614151617">FULL</strong> will cause statistics missing. To collect statistics, add the keyword <strong id="EN-US_TOPIC_0000001145830717__b160011119172">ANALYZE</strong> to <strong id="EN-US_TOPIC_0000001145830717__b1185081913171">VACUUM FULL</strong>.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001145830717__l51b262d8b6b64691b133af48cea732ad"><strong id="EN-US_TOPIC_0000001145830717__a6e9340ced0084094a6ebdaced44baa1b">FREEZE</strong><p id="EN-US_TOPIC_0000001145830717__a58abd6b93c3e4697a898b75d057c04a8">Is equivalent to executing <strong id="EN-US_TOPIC_0000001145830717__b5005541115263">VACUUM</strong> with the <strong id="EN-US_TOPIC_0000001145830717__b2795648515263">vacuum_freeze_min_age</strong> parameter set to <strong id="EN-US_TOPIC_0000001145830717__b4988279915263">zero</strong>.</p>
</li><li id="EN-US_TOPIC_0000001145830717__l8c7d8b480e4b427ba07e95e817f58f57"><strong id="EN-US_TOPIC_0000001145830717__a88b01d5ef1904ee5b9ebddac91287d87">VERBOSE</strong><p id="EN-US_TOPIC_0000001145830717__a445bdae44d784b2ca1e86c0812f7ad85">Prints a detailed vacuum activity report for each table.</p>
</li><li id="EN-US_TOPIC_0000001145830717__l8bd1eb6b8d9a4be091b980ff32a5004a"><strong id="EN-US_TOPIC_0000001145830717__a3fee0c4c7ceb472dbe7fad548c89c656">ANALYZE | ANALYSE</strong><p id="EN-US_TOPIC_0000001145830717__a246e780aefda41d5a3052589f31d6245">Updates statistics used by the planner to determine the most efficient way to execute a query.</p>
</li><li id="EN-US_TOPIC_0000001145830717__l1ee21fb7ce8a4f0ea39040c12b3c58cd"><strong id="EN-US_TOPIC_0000001145830717__a885f61484dc44005a4c28eb72d84db29">table_name</strong><p id="EN-US_TOPIC_0000001145830717__ad467aa7239404197aa852226a39149c3">Indicates the name (optionally schema-qualified) of a specific table to vacuum.</p>
<p id="EN-US_TOPIC_0000001145830717__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_0000001145830717__l37a69e2ca3054404a702f6248fc8986a"><strong id="EN-US_TOPIC_0000001145830717__a846e9d4698074065a002ad3e6e1ce0bd">column_name</strong><p id="EN-US_TOPIC_0000001145830717__a0e6052d387de4ed0807902e51eff4869">Indicates the name of a specific field to analyze.</p>
<p id="EN-US_TOPIC_0000001145830717__a67e50e8ba0344c5fbc676abb00b57468">Value range: Indicates the name of a specific field to analyze. Defaults are all columns.</p>
</li><li id="EN-US_TOPIC_0000001145830717__l541d88b952e3461b8646e75f31ba15bc"><strong id="EN-US_TOPIC_0000001145830717__a18bf6d74016845a7823a354e5d67c1aa">PARTITION</strong><p id="EN-US_TOPIC_0000001145830717__a791c43e8c9c444548bc992651a684f97">HDFS table does not support <strong id="EN-US_TOPIC_0000001145830717__b118679643916565">PARTITION</strong>. <strong id="EN-US_TOPIC_0000001145830717__b1386083275165546">COMPACT</strong> and <strong id="EN-US_TOPIC_0000001145830717__b450013450165546">PARTITION</strong> cannot be used at the same time.</p>
</li><li id="EN-US_TOPIC_0000001145830717__lb45a48b077ef4938aa8e27258f330009"><strong id="EN-US_TOPIC_0000001145830717__a39f9f7f6a0dc4547831d898d6d2030eb">partition_name</strong><p id="EN-US_TOPIC_0000001145830717__a71e10e8f0fad44068e7157c014b747dc">Indicates the partition name of a specific table to vacuum. Defaults are all partitions.</p>
</li><li id="EN-US_TOPIC_0000001145830717__l39da84c8002046578a19e9c44ca4f025"><strong id="EN-US_TOPIC_0000001145830717__a8dc44d683b564b13a31a144b298b53d8">DELTAMERGE</strong><p id="EN-US_TOPIC_0000001145830717__ab4de1ceec20b46d6901f5c3762f66994">(For HDFS and column-store tables) Migrates data from the delta table to primary tables. 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_0000001145830717__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_0000001145830717__note17960739113014"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001145830717__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_0000001145830717__b91894954813">EXPLAIN ANALYZE</strong>):</p>
<ul id="EN-US_TOPIC_0000001145830717__ul6513181416330"><li id="EN-US_TOPIC_0000001145830717__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_0000001145830717__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_0000001145830717__leb71aec9ff894fe59875a6eb504d9b21"><strong id="EN-US_TOPIC_0000001145830717__a2f797b6c271c4025bbc29fc9eea5ecbc">HDFSDIRECTORY</strong><p id="EN-US_TOPIC_0000001145830717__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_0000001145830717__s12262122d2d24f618cc6d20821bd0807"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001145830717__p322952914910">Delete all tables in the current database.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001145830717__screen87801933111315"><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><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001145830717__p18386141217413">Reclaim the space of partition <strong id="EN-US_TOPIC_0000001145830717__b24931949101512">P2</strong> of the <strong id="EN-US_TOPIC_0000001145830717__b64941537155"><span id="EN-US_TOPIC_0000001145830717__text5689123719919">tpcds.</span>web_returns_p1</strong> table without updating statistics.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001145830717__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><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001145830717__p375188173315">Reclaim the <strong id="EN-US_TOPIC_0000001145830717__b1388917165911"><span id="EN-US_TOPIC_0000001145830717__text1630541297">tpcds.</span>web_returns_p1</strong> table and update statistics.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001145830717__screen177512814336"><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><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001145830717__p182058269134">Delete all tables in the current database and collect statistics about the query optimizer.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001145830717__screen14088410151"><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><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001145830717__p78071095316">Delete only the <strong id="EN-US_TOPIC_0000001145830717__b18901229144">reason</strong> table.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001145830717__screen1827111503113"><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">reason</span><span class="p">;</span><span class="w"></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>