vacuum.7

来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 146 行

7
146
字号
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "VACUUM" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMEVACUUM \- garbage-collect and optionally analyze a database.SH SYNOPSIS.sp.nfVACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ \fItable\fR ]VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] ANALYZE [ \fItable\fR [ (\fIcolumn\fR [, ...] ) ] ].sp.fi.SH "DESCRIPTION".PP\fBVACUUM\fR reclaims storage occupied by deleted tuples.In normal PostgreSQL operation, tuples thatare deleted or obsoleted by an update are not physically removed fromtheir table; they remain present until a \fBVACUUM\fR isdone. Therefore it's necessary to do \fBVACUUM\fRperiodically, especially on frequently-updated tables..PPWith no parameter, \fBVACUUM\fR processes every table in thecurrent database. With a parameter, \fBVACUUM\fR processesonly that table..PP\fBVACUUM ANALYZE\fR performs a \fBVACUUM\fRand then an \fBANALYZE\fR for each selected table. Thisis a handy combination form for routine maintenance scripts. SeeANALYZE [\fBanalyze\fR(7)]for more details about its processing..PPPlain \fBVACUUM\fR (without FULL) simply reclaimsspace and makes itavailable for re-use. This form of the command can operate in parallelwith normal reading and writing of the table, as an exclusive lockis not obtained. \fBVACUUMFULL\fR does more extensive processing, including moving of tuplesacross blocks to try to compact the table to the minimum number of diskblocks. This form is much slower and requires an exclusive lock on eachtable while it is being processed..SH "PARAMETERS".TP\fBFULL\fRSelects ``full'' vacuum, which may reclaim morespace, but takes much longer and exclusively locks the table..TP\fBFREEZE\fRSelects aggressive ``freezing'' of tuples.Specifying FREEZE is equivalent to performing\fBVACUUM\fR with thevacuum_freeze_min_age parameterset to zero. The FREEZE option is deprecated andwill be removed in a future release; set the parameter instead..TP\fBVERBOSE\fRPrints a detailed vacuum activity report for each table..TP\fBANALYZE\fRUpdates statistics used by the planner to determine the mostefficient way to execute a query..TP\fB\fItable\fB\fRThe name (optionally schema-qualified) of a specific table tovacuum. Defaults to all tables in the current database..TP\fB\fIcolumn\fB\fRThe name of a specific column to analyze. Defaults to all columns..SH "OUTPUTS".PPWhen VERBOSE is specified, \fBVACUUM\fR emitsprogress messages to indicate which table is currently beingprocessed. Various statistics about the tables are printed as well..SH "NOTES".PP\fBVACUUM\fR cannot be executed inside a transaction block..PPWe recommend that active production databases bevacuumed frequently (at least nightly), in order toremove expired rows. After adding or deleting a large numberof rows, it may be a good idea to issue a \fBVACUUMANALYZE\fR command for the affected table. This will update thesystem catalogs withthe results of all recent changes, and allow thePostgreSQL query planner to make betterchoices in planning queries..PPThe \fBFULL\fR option is not recommended for routine use,but may be useful in special cases. An example is when you have deletedmost of the rows in a table and would like the table to physically shrinkto occupy less disk space. \fBVACUUM FULL\fR will usuallyshrink the table more than a plain \fBVACUUM\fR would.The \fBFULL\fR option does not shrink indexes; a periodic\fBREINDEX\fR is still recommended. In fact, it is often fasterto drop all indexes, \fBVACUUM FULL\fR, and recreate the indexes..PP\fBVACUUM\fR causes a substantial increase in I/O traffic,which can cause poor performance for other active sessions. Therefore,it is sometimes advisable to use the cost-based vacuum delay feature.See in the documentation for details..PPPostgreSQL includes an ``autovacuum''facility which can automate routine vacuum maintenance. For moreinformation about automatic and manual vacuuming, seein the documentation..SH "EXAMPLES".PPThe following is an example from running \fBVACUUM\fR on atable in the regression database:.sp.nfregression=# VACUUM VERBOSE ANALYZE onek;INFO:  vacuuming "public.onek"INFO:  index "onek_unique1" now contains 1000 tuples in 14 pagesDETAIL:  3000 index tuples were removed.0 index pages have been deleted, 0 are currently reusable.CPU 0.01s/0.08u sec elapsed 0.18 sec.INFO:  index "onek_unique2" now contains 1000 tuples in 16 pagesDETAIL:  3000 index tuples were removed.0 index pages have been deleted, 0 are currently reusable.CPU 0.00s/0.07u sec elapsed 0.23 sec.INFO:  index "onek_hundred" now contains 1000 tuples in 13 pagesDETAIL:  3000 index tuples were removed.0 index pages have been deleted, 0 are currently reusable.CPU 0.01s/0.08u sec elapsed 0.17 sec.INFO:  index "onek_stringu1" now contains 1000 tuples in 48 pagesDETAIL:  3000 index tuples were removed.0 index pages have been deleted, 0 are currently reusable.CPU 0.01s/0.09u sec elapsed 0.59 sec.INFO:  "onek": removed 3000 tuples in 108 pagesDETAIL:  CPU 0.01s/0.06u sec elapsed 0.07 sec.INFO:  "onek": found 3000 removable, 1000 nonremovable tuples in 143 pagesDETAIL:  0 dead tuples cannot be removed yet.There were 0 unused item pointers.0 pages are entirely empty.CPU 0.07s/0.39u sec elapsed 1.56 sec.INFO:  analyzing "public.onek"INFO:  "onek": 36 pages, 1000 rows sampled, 1000 estimated total rowsVACUUM.sp.fi.SH "COMPATIBILITY".PPThere is no \fBVACUUM\fR statement in the SQL standard..SH "SEE ALSO"vacuumdb [\fBvacuumdb\fR(1)], in the documentation

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?