PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔媆誕嬉誕

VACUUM

劉䓄

VACUUM -- 傄婆櫽镖傖埪埇锬婄彖悊婔婻昄扞康

臺濘

VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ table ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] ANALYZE [ table [ (column [, ...] ) ] ]

柟誄

VACUUM 啂櫽噾役鍴臯剹扞䔇庻嗘䷺閘㔗婘婔轸䔇 PostgreSQL 淉嘩麯闼底噾䂟 DELETE 䔇臯潡蔙赆 UPDATE 誺劯誺施䔇臯幽澇橬傯垄傸欔匂䔇臘婺䬷䊖役鍴婘垯潊 VACUUM 幋嬉垄傸傉䇽庻婘㔗啹溴橬媙釂变橘婄誊臯 VACUUM 䬹彆滇婘䂟婩敘桄䔇臘婪㔗

套悩澇橬埗昄VACUUM 崇䊖嘷嬉昄扞康麯懟婻臘套悩橬埗昄VACUUM 埻崇䊖闼婻臘㔗

VACUUM ANALYZE 噽欓臯婔婻 VACUUM 䇽劯滇䂍懟婻锬垔䔇臘欓臯婔婻 ANALYZE 㔗凹庯斖婩䂘檴臔橸蔯蘔認滇婔婻冽桹冪䔇䂇劽㔗埗黙 ANALYZE 诙埡敘崔橬噿噽崇䊖䔇䂖誗㔗

䞔剘䔇 VACUUM(澇橬 FULL)埻滇䞔剘婄啂櫽䷺閘幽婫傴噽埇傖喉渇嘪䫘㔗認䓉嘵嚟䔇变傴埇傖启凹臘䔇捞锔臂喍幽埏淉嘩啹婺澇橬臙挗毐傡髕㔗VACUUM FULL 欓臯敘幪濕䔇崇䊖寙拸虘庖䓂媘臯傖冪檪臘寋䚷彄橔儏䔇伕䕻庖昄䕞麯㔗認䓉嘵嚟襕晵螩崔幽婫婘崇䊖䔇施唍驔襕婘臘婪桘媹婔婻毐垄髕㔗

埗昄

FULL

锬拷"垯噘"橙䊖認湙埇傖敵崉敘崔䔇䷺閘嘖滇誌䔇施閘敘崔幽婫婘臘婪桘媹庖毐垄髕㔗

FREEZE

锬拷檔誕䔇臯"喂䂷"㔗毺垔 FREEZE 䕩嘷庯欓臯 VACUUM 施儖 vacuum_freeze_min_age 埗昄螆婺镽㔗FREEZE 锬釹儖婘橻準䔇䬽橸婺赆埡潽幽婫埉凹嘪䫘嘹庫嘷嘪䫘螆䘞溼䇞䔇埗昄唚䔇桹濘準膆彄䕞䔇㔗

VERBOSE

婺懟婻臘欷剄婔傘臥䂖䔇橙䊖噖嘩檖只

ANALYZE

敘桄䫘庯嚻寡単䔇䂘螇媇敇傖喿垔欓臯昖臵䔇橔橬昽桹濘㔗

table

襕橙䊖䔇臘䔇劉䓄(埇傖橬昇嚟媞閄)㔗䚺䩕施滇嘷嬉昄扞康婺䔇欔橬臘㔗

column

襕彖悊䔇噙嘷䔇庖枕劉䓄㔗䚺䩕滇欔橬庖枕㔗

膷庺

套悩毺垔庖 VERBOSE 闼幽 VACUUM 儖埏庺崇䊖誺䘋婺䔇媇敇傖臘滯嘷嬉溼婘崇䊖闼婻臘㔗劇䓉橬噿認底臘䔇䂘螇幘嚔欷剄庺準㔗

濘懟

VACUUM 婉脘婘庋媇庖喙欓臯㔗

傺螞䫘库昄扞康䂟婩橙䊖(躿儏懟捔婔渇)傖媺臕婉桺婄役鍴崌昽䔇臯㔗儴噽滇婘嵂役庖崓麟螄嘘幋劯凹埖嘌巉䔇臘欓臯 VACUUM ANALYZE 变傴滇婔婻冽喘䔇幹愇㔗認湙啔儖敘桄係䂘䕞嘘婺橔誏䔇敘櫹幽婫噕螩 PostgreSQL 昖臵嚻寡単婘蓇彐䫘潙昖臵施橬敘喘䔇锬拷㔗

婉傺螞斖婩嘪䫘 FULL 锬釹嘖滇埇傖婘䬹枪愙喕婋嘪䫘㔗婔婻冋床儌滇婘嘹役鍴庖婔婻臘䔇崓鄘彖臯幋劯婯橕傯䬷䊖婪䚷償臖臘傖废儏伕䕻䷺閘剹䫘㔗VACUUM FULL 锔婩襕懫剘亇䔇 VACUUM 櫽䚷敘崔䔇臘儺凩㔗FULL 锬釹幽婉橙䊖䘵嚘㔗傉䇽毘艊变橘攓䔇誊臯 REINDEX 变傴㔗垂鍙婪饡噽役鍴欔橬䘵嚘喉誊臯 VACUUM FULL 变傴橔劯麉傺䘵嚘锔婩滇冽媆䔇㔗

VACUUM 凚躘 I/O 敕麟嵂媹埇脘嚔凚躘噽垄昂媘嚔臺䔇攓脘敽媼㔗啹溴橬施唍嚔傺螞嘪䫘嘺庯嚔體䔇 vacuum 傽誘䬹攓㔗埗黙誗17.4.4诙埡䂖誗㔗

PostgreSQL 寙劆婔婻"autovacuum"螆桘垄埇傖躻媘誕臯斖婩䔇 vacuum 䂘檴㔗噿庯欋媘启躻媘橙䊖䔇敘崔䂖誗埗蓕誗22.1

冋床

婋麵滇婔婻婘詘埻(regression)昄扞康麯昊婻臘婪欓臯 VACUUM 䔇婔婻冋床

regression=# VACUUM VERBOSE ANALYZE onek;
INFO:  vacuuming "public.onek"
INFO:  index "onek_unique1" now contains 1000 tuples in 14 pages
DETAIL:  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 pages
DETAIL:  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 pages
DETAIL:  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 pages
DETAIL:  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 pages
DETAIL:  CPU 0.01s/0.06u sec elapsed 0.07 sec.
INFO:  "onek": found 3000 removable, 1000 nonremovable tuples in 143 pages
DETAIL:  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 rows
VACUUM

噚垹攓

SQL 湺庖麯澇橬 VACUUM 臺埖㔗

埽蓕

vacuumdb, 嘺庯嚔體䔇橙䊖傽誘

劯锔饡釕嬉誕
UPDATE婪婔亓VALUES