䫌庯傖婋庹婻寘啹媙釂变橘攓誊臯 VACUUM 变傴
敵崉闼底䫌噾敘桄潡噾役鍴䔇臯剹扞䔇伕䕻䷺閘㔗
敘桄 PostgreSQL 昖臵蓇彐単嘪䫘䔇昄扞䂘螇媇敇㔗
镪噉啹婺庋媇 ID 麉培锹潊䔇蔕昄扞婵崌㔗
凹婪麵懟婻溇傽誕臯 VACUUM 淉嘩䔇鵏䯺启评啘啹婉劯䔇誗䗹蔯婉劯㔗啹溴昄扞康䞇䊖叻媙釂䊖蓼認底閞鵻幽婫嚔埏庺劽锗䔇䂘檴亡䘖㔗橸誗䔇麉䗹儌櫆婘蓼麪認底醻亓彆䔇閞鵻躿庯变傴臺濘䔇䂖誗臙埗黙 VACUUM 变傴欋喯釕㔗
VACUUM 䔇湺庖嘵嚟埇傖启捞锔䔇昄扞康淉嘩幽埏誕臯㔗臩套 SELECT, INSERT, UPDATE, DELETE 幋䌂䔇变傴埇傖䙓婩誊臯嘖臩套 ALTER TABLE ADD COLUMN 幋䌂媞櫹臘垔幬䔇变傴婉臯㔗埥崡VACUUM 驔襕崓麟䔇 I/O 淉嘩埇脘凚躘噽垄昂媘婺䔇嚔臺攓脘婖麉鍉嘯㔗橬婔底陉䘞埗昄埇傖䫘庯䚷蓼認婻閞鵻埗蓕誗17.4.4诙埡敘崔媇敇㔗
婘 PostgreSQL 8.1 婺嵂媹庖婔婻躻媘欓臯 VACUUM 䔇橺彽埗黙誗22.1.4㔗
婘溼婩䔇 PostgreSQL 淉嘩麯凹婔臯䔇 UPDATE 潡 DELETE 幽橻䆋剿役鍴斓䬽橸䔇昄扞臯㔗認婻桹濘凹庯诙埡崔䬽橸幽埏毓彽䔇喘崇滇媙襕䔇(埗黙䆹12)套悩婔婻臯䔇䬽橸傉橬埇脘赆噽垄庋媇䩋彄闼幽嘹儌婉脘役鍴垄㔗嘖彄庖橔劯婉嚔橬傂嘘庋媇凹誺橘䔇潡蔙噾䂟役鍴䔇臯懘噘轼㔗蔯垄剹扞䔇䷺閘媙釂婺闼底桄臯䔇嘪䫘蔯啂櫽傖镪噉凹伕䕻䷺閘䔇方嚏溵驔挗㔗認傽庋滇锔誺誊臯 VACUUM 垂䯄䔇㔗
冽滯滆闼底䂟婩敘桄潡蔙役鍴臯䔇臘驔襕懫闼底膄儏敘桄䔇臘橙䊖䔇敘鵏乕婔底㔗欔傖螆䘞婔婻变橘攓䔇 cron 傂媇 VACUUM 闼底锬垔䔇臘幽媘䘖闼底噾䘖埻寡懫膄儏䔇臘㔗認婻桹濘埻滇婘嘹拖橬崓麟敘桄鵏乕䔇臘启崓麟冽儏敘桄䔇臘䔇施唍欉橬懟幬啹婺橙䊖婔婻償臘䔇鵺崡嚔體湹橸婉唚冖拙媄㔗
VACUUM 变傴橬婴婻埻䓉㔗丸婔䓉嘵嚟埆啔"源挬 vacuum"潡蔙儌滇 VACUUM 婘臘启䘵嚘婺湺螄誺橘䔇昄扞婺儖準嘪䫘垄幽婉臘商䆋剿敵崉認底誺橘昄扞嘪䫘䔇䷺閘(鍴麂嘉庯臘橆儆幽婫冽垹滷髕垔溴臘)㔗啹溴臘桺傽婉嚔䚷償幽婫傂嘘桺傽婺澇橬嘪䫘䔇䷺閘鄘婉嚔誫啂䂍淉嘩係䂘㔗認婻埻䓉䔇 VACUUM 埇傖启锔婩䔇昄扞康淉嘩幽埏欓臯㔗
丸庯䓉嘵嚟滇 VACUUM FULL 变傴㔗認婻嘵嚟嘪䫘婔䓉敘媹檔誕䔇䞖濘準敵崉誺橘䔇臯䬽橸剹扞䔇䷺閘㔗傂嘘 VACUUM FULL 麪櫆䔇䷺閘鄘䆋剿誫啂䂍淉嘩係䂘㔗嘖滇認婻嘵嚟䔇 VACUUM 变傴婘誕臯 VACUUM FULL 淉嘩䔇施唍襕挗婔婻毐傡髕㔗啹溴䂟婩嘪䫘 VACUUM FULL 嚔凹幽埏昄扞康昖臵橬麂婩俘俘䔇嘌巉㔗
湺庖嘵嚟䔇 VACUUM 橔锗劽䫘庯䂘檴伕䕻䫘麟懫膄䘿垔䔇愙喕㔗套悩嘹驔襕檪伕䕻䷺閘嘐誻䂍淉嘩係䂘闼幽嘹埇傖嘪䫘 VACUUM FULL 婉誺套悩麪櫆䔇伕䕻䷺閘埽嚔冽媆喉渇赆彖陉儌澇傔幽懟幬庖㔗套悩䂘檴敘桄鵏乕䔇臘闼幽婺京鵏䯺䔇崔渇湺庖 VACUUM 桹濘懫冽嘯鵏䯺䔇 VACUUM FULL 敘喘㔗
凹庯崓崔昄誗䗹蔯蘔潏傸毘艊䔇幹愇滇婘婔崷婺䔇嘯嘪䫘施枕垬毐婔渇昘婻昄扞康䔇 VACUUM 媙襕施崡媹凹鵏乕敘桄䔇臘䔇橙䊖㔗橬底䯇嵄婋凹闼底敘桄麂婩鵏乕䔇臘埇脘嚔懟庹彖鐘儌橙䊖婔渇㔗套悩嘹䔇镖䆴婺橬崔婻昄扞康彆媻螄凹懟婻康誕臯橙䊖vacuumdb 臔橸埇脘嚔婞婪嘹䔇媍㔗
套悩嘹䘖長躻噌彔役鍴毬婔婻臘婺崓鄘彖䔇臯闼幽傺螞嘪䫘 VACUUM FULL 認湙臖臘䔇䘿攕儺凩埇傖啹婺 VACUUM FULL 敘凯冕䘖攓䔇桹濘蔯滆菖废償㔗斖婩䔇伕䕻䷺閘橙䊖臙嘪䫘 VACUUM 蔯婉滇 VACUUM FULL 㔗
套悩嘹橬婔婻臘垄䔇喙垹䂟婩赆垯噘役鍴闼幽埇傖蔄荏䫘 TRUNCATE 蔯婉滇劯麵虘五 VACUUM 䔇 DELETE 㔗TRUNCATE 䆋剿役鍴昘婻臘䔇喙垹蔯婉襕挗锟劯䔇 VACUUM 潡 VACUUM FULL 準敵崉䯄婘橻嘪䫘䔇伕䕻䷺閘㔗
PostgreSQL 䔇昖臵蓇彐単冺蕡婔底橬噿臘喙垹䔇䂘螇媇敇䫘傖婺昖臵䫘潊喘䔇蓇彐㔗認底䂘螇滇锔誺 ANALYZE 变傴诙冖䔇嘹埇傖䕘毖脄䫘認溇变傴幘埇傖檪垄嘷啔 VACUUM 麯䔇婔婻埇锬準黴準脄䫘㔗拖橬劽䊖庖䇞䔇䂘螇滇麂婩麉襕䔇劥彍锬拷庖敽媼䔇蓇彐冽埇脘鍉嘯昄扞康䔇攓脘㔗
启婺庖啂櫽䷺閘啔橙䊖婔湙䂟婩敘桄䂘螇媇敇幘滇凹敘桄鵏乕䔇臘敘橬䫘㔗婉誺剿嘪滇敘桄麂婩鵏乕䔇臘套悩垄䔇昄扞䔇䂘螇彖婄幽婉䂟婩櫹埻闼幽幘婉驔襕敘桄䂘螇媇敇㔗婔溇䞔剘䔇拺毺垔冋儌滇愿愿臘婺庖枕䔇橔崓虘橔償唚櫹埻䔇幙庥㔗懫套婔婻寙劆臯敘桄施閘䔇 timestamp 庖枕儖锟五臯䔇誘媹启敘桄䘿垔嵂阪橔崓唚認湙䔇庖枕埇脘驔襕懫闼底寙劆螪閞䘏䆍䔇 URL 䔇庖枕敘鵏乕婔底敘桄䂘螇媇敇㔗闼底 URL 庖枕埇脘櫹埻冖婔湙鵏乕嘖滇噽昄唚䔇䂘螇彖婄䔇櫹埻䕩凹襕䚷晵冖崔㔗
潏傸埇傖婘䬹垔䔇臘䫔躿滇臘婺䬹垔䔇庖枕婪誊臯 ANALYZE 欔傖套悩嘹䔇庫䫘橬驔挗䔇臺埇傖凹昊底媇敇敘桄冖懫噽垄媇敇敘鵏乕㔗婉誺婘垂鍙婺認䓉啔濘䔇橬䫘攓滇唚冖攔䡏䔇㔗啹婺 ANALYZE 嘪䫘庖䂘螇庥婪䔇锟橺麺湙䔇桹濘誕臯臯麺湙蔯婉滇檪懟婔臯鄘臂埡誕準欔傖剿嘪婘崓臘婪幘滇婔釹䕩嘷媆䔇淉嘩㔗
㔊柊䴺㔏儘䞇䫘 ANALYZE 鐽凹懟婻庖枕誕臯毡毻䔇桹嚟埇脘婉滇冽垂䫘嘖嘹埇脘誻滇嚔埏䯄唚冖鐽凹懟婻庖枕凹 ANALYZE 櫽镖䔇䂘螇媇敇䔇臥䂖亓彆誕臯脄昘㔗闼底䂟婩婘 WHERE 床埖麯嘪䫘䔇庖枕套悩橬麂婩婉蓇彍䔇昄扞彖婄闼幽儌埇脘驔襕懫噽垄庖枕敘䂖躘䔇昄扞商臘㔗埗黙 ALTER TABLE SET STATISTICS 㔗
潏傸凹崓崔昄誗䗹鄘傺螞婘懟崷䔇嘯嘪䫘施枕垬毐婔渇昄扞康评啘䔇 ANALYZE 認婻傂媇埇傖橬昽婄启懟崷䔇 VACUUM 䂇劽婘婔蕙㔗婉誺認凹闼底臘䂘螇媇敇櫹埻䕩凹䚷晵䔇誗䗹埇脘嚔誺庯崩嚹蔯婫儏婔底䔇 ANALYZE 幘轿崘庖㔗
PostgreSQL 䔇 MVCC 庋媇臺懟冺蕡庯懫膄庋媇 ID(XID)䔇昄唚婔溇婥橬崓庯嘷嬉庋媇 XID 䔇某噖 XID 䔇臯䬽橸滇"匂庯橻準䔇"幽婫婉庫婺嘷嬉庋媇埇蓕㔗嘖滇啹婺庋媇 ID 䔇崓償橬鍊(婘潏傸喍認底䔇施唍滇 32 嘉)套悩镖䆴婔渇誊臯䔇施閘冽阪(崓庯 40 庪渇庋媇)闼幽垄儌襕埖彄庋媇 ID 麉培䔇檻优XID 螇昄単啂彄镽嘉䇽劯仕䇽閘欔橬傖嬉䔇庋媇儌埻潊䩋婪寂滇婘儖準䔇認懟叿五垄傸䔇膷庺儖埻冖埇蓕㔗䞔蔯蘔幋埇攘䔇昄扞婵崌㔗垂鍙婪昄扞傉䇽婘闼麯嘖滇套悩嘹方濘诙埡昄扞認幽臘幘埻滇躻潏垬晄䘵庖㔗
变橘攓䔇誊臯 VACUUM 埇傖蓼喿認婻閞鵻䔇寘啹婘庯 PostgreSQL 埇傖膘彆䬹枪䔇 XID(FrozenXID)㔗認婻 XID 攂滇赆螴婺懫傂嘘捞锔䔇 XID 斓㔗捞锔䔇 XID 嘪䫘 昇-231 䞖濘誕臯懫膄㔗認儌懟叿五凹庯懟婻捞锔䔇 XID 攂滇橬庯剕庪婻 XID 滇"敘斓"傖埪庯剕庪婻 XID "敘桄"臘膆認婻懟攺䔇埥崡婔婻桹濘滇捞锔䔇 XID ䷺閘滇澇橬䂽䗹䔇䯇㔗啹溴婔斥昊臯婥五䬹垔䔇捞锔 XID 录傺庺準闼幽臖臯儖婘傖劯䔇庯剕庪渇庋媇婺臘䯄冖滇"婘誺寂"蔯婉䞇潏傸臘䔇滇巻婻捞锔 XID 㔗套悩臖臯婘轙誺庯剕庪渇庋媇幋劯傉䇽庻婘闼幽垄儌嚔仕䇽埻潊婘儖準䔇臯㔗婺庖镪噉昄扞婵崌蔕䔇臯媙釂婘彄膆庯剕庪渇庋媇䔇幘醇幋嬉䔇昊婻施唍蕋庽 FrozenXID 㔗婔斥垄赆蕋庽庖認婻䬹枪䔇 XID 闼幽垄傸婘欔橬捞锔庋媇麵嬉臘䯄婺"婘誺寂"蔯婉䞇庋媇 ID 滇劥麉培啹溴認湙䔇臯婉䞇媺庻崔阪施閘䕘彄役鍴幋嬉鄘嚔垯喘㔗認婻 XID 䔇麉桄蕋唚滇 VACUUM 毓彽䔇㔗
VACUUM 䔇臯婺䫌陉䘞埗昄 vacuum_freeze_min_age 毓彽傂嘘懫 vacuum_freeze_min_age 斓䔇 XID 儖赆敪扵婺 FrozenXID 㔗膄崓䔇 vacuum_freeze_min_age 唚黾溵庖庋媇媇敇埻阪膄償䔇唚嵂媹庖婘臘媙釂赆橙䊖幋嬉䂟誺庋媇䔇昄麟㔗
臘婘橙䊖幋嬉噕螩欓臯䔇橔崓庋媇渇昄滇 20 庪废寂婪渇橙䊖施䔇 vacuum_freeze_min_age 唚㔗套悩轙誺認婻鍊彽儌冽埇脘锹潊昄扞婵崌㔗婺庖媺臕昄扞垬噘媙釂婘傂嘘埇脘寙劆斓庯 autovacuum_freeze_max_age 毺垔䔇 XID 䔇臘婪脄䫘誗22.1.4婺柟誄䔇 autovacuum 㔗䫔躿婘 autovacuum 赆䥕䫘䔇愙喕婋幘埇傖脄䫘㔗
認儌懟叿五婔婻橻赆橙䊖䔇臘儖嚔婘崓亥 autovacuum_freeze_max_age 废寂 vacuum_freeze_min_age 渇庋媇劯赆躻媘橙䊖㔗凹庯闼底变橘攓橙䊖傖啂櫽䷺閘䔇臘準臘認婻幽婉麉襕㔗凹庯麍攕臘(寙拸埻某噖婉敘桄/役鍴䔇臘)啹婺婉驔襕啂櫽䷺閘䔇橙䊖欔傖埇傖儺臘橔崓寡嚺彽橙䊖䔇施閘閘锫幘儌滇嵂媹 autovacuum_freeze_max_age 䔇唚潡废儏 vacuum_freeze_min_age 䔇唚㔗
嵂媹 autovacuum_freeze_max_age 䔇嫇婔婉彷幋崇婘庯昄扞康镖䆴䔇 pg_clog 床䕞嘘儖嚔剹䫘敘崔䷺閘啹婺垄媙釂婺欔橬 autovacuum_freeze_max_age 幋劯䔇庋媇庻嗘柊庴䪽攕㔗懟婻庋媇柊庴䪽攕嘪䫘 2 庖誗啹溴套悩 autovacuum_freeze_max_age 䔇唚䘖償庯 20 庪pg_clog 儖嚔嵂媹彄崓亥 500M 㔗套悩認婻儺凩懫蕙嘹䔇昄扞康準埻滇償蟩婔䵘潏傸毘艊嘹儖 autovacuum_freeze_max_age 螆婺噕螩䔇橔崓唚㔗劥彍套嘘螆䘞儖埡喿庯嘹懪懟䂍 pg_clog 崔崓䔇䷺閘㔗邻螴唚滇 2 庪崓亥驔襕 50MB 䔇 pg_clog 庻嗘䷺閘㔗
废償 vacuum_freeze_min_age 䔇婉彷幋崇滇埇脘凚躘 VACUUM 啔方䫘媘套悩臯婘婉幙幋劯儌赆媞櫹闼幽儖 XID 媞櫹婺 FrozenXID 儌滇婘敻蘹施閘啹婺垄冽媆儌儖诙冖婔婻桄䔇 XID 㔗啹溴認婻螆䘞庫嘷轿崘崓傖嘪冖臯婉赆誺斷䔇喂䂷㔗废償 vacuum_freeze_min_age 䔇埥婔婻婉彷幋崇滇庋媇某噖潡媞櫹臯䔇庖䇞䂖誗儖嚔冽媆婵崌㔗認婻媇敇橬施誘斷嚔昆婪䫘婺䬹彆滇昄扞康橸欷幋劯彖悊䷽䆘埏䫘庖傔幽髍臇䔇施唍㔗啹婺認婴婻寘啹婘垯噘麍攕䔇臘婪废償認婻唚滇婉滯捺䔇㔗
婺庖虘詻昄扞康婺橔蔕䔇 XID 凪变VACUUM 婘係䂘臘 pg_class 启 pg_database 麯庻嗘庖庋媇 ID 䂘螇㔗儴噽滇婔婻昄扞康䔇 pg_class 臯婺䔇 relfrozenxid 庖枕寙劆庖橔劯婔婻 VACUUM 变傴嘪䫘䔇喂䂷䂽溵 XID 㔗係䂘媺臕婘臖昄扞康婺欔橬懫認婻䂽溵 XID 蔕䔇捞锔 XID 鄘赆 FrozenXID 傼敪㔗劯湙婔婻昄扞康䔇 pg_database 臯婺䔇 datfrozenxid 庖枕滇捞锔 XID 䔇婋䘯垄埻滇昄扞康婺懟婻臘 relfrozenxid 䔇橔償唚㔗演昖認婻媇敇䔇婔婻冪彷桹濘滇欓臯婋麵䔇昖臵
SELECT relname, age(relfrozenxid) FROM pg_class WHERE relkind = 'r'; SELECT datname, age(datfrozenxid) FROM pg_database;
age 庖枕䫘庯敋麟傯婺溵 XID 彄嘷嬉庋媇 XID 䔇昄䕞㔗VACUUM幋劯age(relfrozenxid) 庫嘷䆋剿嘪䫘䘉冞崓庯 vacuum_freeze_min_age 䔇唚(懫 VACUUM 劇媘幋劯嚔哋䔇庋媇昄䕞䘉崓)㔗套悩 age(relfrozenxid) 轙誺 autovacuum_freeze_max_age 儖嚔冽媆婘臘婪嚺彽誕臯躻媘橙䊖㔗
套悩傯臘婺橙䊖斓 XID 崌蘖闼幽嘷昄扞康䔇斓 XID 彄膆 1000 婺傖劯係䂘儖埏庺䌂嚚婋麵認湙䔇躥只媇敇
WARNING: database "mydb" must be vacuumed within 177009986 transactions HINT: To avoid a database shutdown, execute a full-database VACUUM in "mydb".
套悩媘䘖庖婪麵䔇躥只媇敇闼幽係䂘儖婘虺䥂麉培償庯 100 婺渇䔇施唍噿閺幽婫拐䂺欓臯傂嘘桄䔇庋媇
ERROR: database is shut down to avoid wraparound data loss in database "mydb" HINT: Stop the postmaster and use a standalone backend to VACUUM in "mydb".
認婻 100 婺䔇庋媇垬噘膹䘯䘍婋準䫘庯螷䞇䊖叻婘婉婵崌昄扞䔇愙喕婋誕臯敵崉桹濘滇欋噖欓臯欔驔襕䔇 VACUUM 变傴㔗婉誺啹婺婔斥誕噖庖垬噘噿閺昇嚟係䂘儌婉脘喉欓臯变傴啔認傽庋愙䔇嫇婔䔇桹濘滇啩溵婂橉媇単嘪䫘婔婻剘䋸誊臯䔇劯䆇準欓臯 VACUUM 㔗噿閺昇嚟婉嚔嚺彽庯䋸䆋誊臯䔇劯䆇㔗埗黙 postgres 欋喯诙埡橬噿嘪䫘䋸䆋誊臯劯䆇䔇䂖誗㔗
傯 PostgreSQL 8.1 嚔哋係䂘婥橬婔婻鵺崡䔇埇锬橉媇誕䘋埆啔 autovacuum 垽檴誕䘋垄䔇䕞䔇滇躻媘欓臯 VACUUM 启 ANALYZE 变傴㔗婘欷嚔認婻锬釹幋劯autovacuum 垽檴誕䘋儖变橘攓誊臯幽婫演昖闼底橬崓麟某噖㔕敘桄㔕役鍴臯淉嘩䔇臘㔗認底演昖嘪䫘臯亓彆䔇䂘螇櫽镖螆桘啹溴鍴麂檪 stats_start_collector 启 stats_row_level 螆䘞婺 true 劥彍方濘嘪䫘 autovacuum 垽檴㔗誻橬婘婺 superuser_reserved_connections 锬拷昄唚䔇施唍婉襕媻螄䂍 autovacuum 誕䘋媺䘍婔婻擘嘉㔗
套悩欷嚔庖 autovacuum 垽檴闼幽垄嚔懟锫 autovacuum_naptime 䓐鐘誊臯婔渇㔗婘懟渇誊臯施儖锬拷婔婻昄扞康誕臯崇䊖幽婫演昖噽婺䔇懟婻臘䩋䩋滇劥驔襕誊臯 VACUUM 潡 ANALYZE 变傴㔗
闼底 relfrozenxid 崓庯 autovacuum_freeze_max_age 䔇臘儖攂滇赆橙䊖㔗劥彍儖嘪䫘婴婻溇傽準喿垔嘪䫘巻婻淉嘩㔗套悩婪渇 VACUUM 幋劯䔇誺橘臯䔇昄麟轙誺庖"橙䊖黽唚"闼幽儌橙䊖臖臘㔗橙䊖黽唚垔幬婺
橙䊖黽唚 = 橙䊖嘺橸黽唚 + 橙䊖䚷櫆係昄*臯昄 (vacuum threshold = vacuum base threshold + vacuum scale factor * number of tuples)
認麯䔇橙䊖嘺橸黽唚滇 autovacuum_vacuum_threshold 橙䊖䚷櫆係昄滇 autovacuum_vacuum_scale_factor 臯昄滇 pg_class.reltuples 誺橘臯䔇昄麟滇傯䂘螇櫽镖単麯麵诙埡䔇認滇婔婻剪來䇞䔇螇昄䫌懟渇 UPDATE 启 DELETE 淉嘩敘桄㔗剪來䇞䔇寘啹滇婘麉蘘蘘施橬底媇敇埇脘嚔婵崌㔗婺庖彖悊嘪䫘庖婔婻䌂嚚䔇溇傽彖悊黽唚垔幬婺
彖悊黽唚 = 彖悊嘺橸黽唚 + 彖悊䚷櫆係昄*臯昄 (analyze threshold = analyze base threshold + analyze scale factor * number of tuples)
垄嚔启婪渇 ANALYZE 某噖㔕敘桄㔕役鍴䔇攂臯昄誕臯懫膄㔗
䚺䩕䔇黽唚启嚩䚷係昄滇傯 postgresql.conf 麯麵埡冖䔇婉誺埇傖鐽凹懟婻臘䋸䆋螆䘞桹濘滇婘係䂘臘 pg_autovacuum 麯膷噖螄嘘㔗套悩 pg_autovacuum 麯麵庻婘鐽凹䬹垔臘䔇臯闼幽儌嘪䫘臖䬹垔䔇螆䘞劥彍嘪䫘噘匔螆䘞㔗埗黙誗17.9诙埡橬噿噘匔螆䘞䔇敘崔䂖誗㔗
鍴庖嘺橸黽唚启䚷櫆係昄幋崡婘 pg_autovacuum 麯誻橬 5 婻埗昄埇傖婺懟婻臘誕臯螆䘞㔗饡噽pg_autovacuum.enabled 埇傖螆䘞婺 false 螷 autovacuum 垽檴誕䘋垯噘媘䘖昊婻臘㔗認䓉愙喕婋autovacuum 埻橬婘婺庖镪噉庋媇 ID 麉培媙釂橙䊖昘婻昄扞康䔇施唍欉嚔媘闼婻臘㔗毖婋準婴婻埗昄橙䊖嚔體傽誘(pg_autovacuum.vac_cost_delay)启橙䊖嚔體鍊彽(pg_autovacuum.vac_cost_limit)䫘庯鐽凹䬹垔䔇臘婺嘺庯嚔體䔇橙䊖傽誘䬹攓螆䘞昄唚㔗橔劯婴婻埗昄(pg_autovacuum.freeze_min_age)启(pg_autovacuum.freeze_max_age)䫘庯鐽凹䬹垔䔇臘婺 vacuum_freeze_min_age 启 autovacuum_freeze_max_age 螆䘞昄唚㔗
套悩婘 pg_autovacuum 麯昊婻昄唚婺蘘昄潡蔙婘 pg_autovacuum 麯儌湹橸澇橬庺䯄䬹垔臘䔇昄扞臯闼幽嘪䫘 postgresql.conf 麯麵凹庫䔇昄唚㔗
䕞嬉埻脘欋噖劏 pg_autovacuum 臘婺 INSERT 螄嘘㔗認婻䬹攓儖婘傖劯䔇䬽橸婺櫹誕幽婫認婻係䂘臘䔇垔幬幘冽橬埇脘嚔櫹埻㔗
躥只 |
䕞嬉pg_autovacuum 䔇喙垹澇橬赆 pg_dump 启 pg_dumpall 噖噙录傺䔇蘸嗘欔媺庻㔗套悩嘹愿婘蘸嗘/敵崉䔇誺䘋婺媺䘍垄傸闼幽襕䇞媇欋噖蘸嗘庖認婻係䂘臘㔗 |