橬庹婻婯 WAL 䕩噿䔇埗昄嚔嘌巉昄扞康攓脘㔗橸誗螘螺垄傸䔇嘪䫘㔗埗黙䆹17诙埡橬噿橉媇単陉䘞埗昄䔇婔轸媇敇㔗
演昖䗹滇庋媇废彖婺䔇䗹婘臖䗹幋嬉䔇欔橬媇敇鄘䇞媺噾䂟喍彄昄扞桺傽婺寂庖㔗婘演昖䗹施欔橬臟昄扞釕鄘彙桄彄伕䕻幽婫劏斖媖桺傽婺喍噖婔溇䬹枪䔇演昖䗹螄嘘㔗婘埏䫘嘷溄䔇施唍嘷溄敵崉誺䘋昖欆橔劯䔇演昖䗹螄嘘彴桺庫臖傯斖媖婺䔇巻婻䗹(䓄婺 redo 螄嘘)嚔哋 REDO 淉嘩婘臖螄嘘幋嬉凹昄扞桺傽䔇傂嘘媞櫹鄘赆螴婺噾䂟喍婘伕䕻婪庖㔗啹溴婘演昖䗹垯潊幋劯傂嘘婘寙劆 redo 螄嘘䗹幋嬉䔇斖媖枕鄘婉喉驔襕啹溴埇傖冻䯇嘪䫘潡蔙役鍴㔗嘷䇽婘誕臯 WAL 嘐懼䔇施唍認底斖媖婘冻䯇彷䫘潡蔙役鍴幋嬉媙釂噽嘐懼㔗
橉媇単䔇劯䆇喍誕䘋懟 checkpoint_segments 婻斖媖枕潡懟 checkpoint_timeout 䓐儌录傺婔婻演昖䗹傖噽彄婺庖㔗䚺䩕螆䘞彖彆滇 3 婻枕启 300 䓐㔗潏傸幘埇傖䫘 SQL 变傴 CHECKPOINT 嚺彽录傺婔婻演昖䗹㔗
废儏 checkpoint_segments 启/潡 checkpoint_timeout 嚔敘鵏乕䔇录傺演昖䗹㔗認湙儌噕螩敘媆䔇嘷溄劯敵崉(啹婺驔襕麉啔䔇噖嘩敘儏)㔗婉誺潏傸媙釂婘敘媆䔇敵崉婯敘鵏乕䔇彙桄臟昄扞釕欔婥準䔇鵺崡嚔體幋閘誕臯广臇㔗幽婫套悩嚔劇庖 full_page_writes(䚺䩕嚔劇)闼幽誻橬噽垄䔇啹䘹驔襕蔄荏㔗婺庖媺臕昄扞釕䔇婔躘攓婘懟婻演昖䗹幋劯䔇丸婔渇昄扞釕埻寡嚔凚躘凹昘婻釕麵喙垹䔇斖媖螄嘘㔗啹溴废償演昖䗹施閘閘锫嚔凚躘膷庺彄 WAL 斖媖婺䔇昄扞麟嵂媹傯蔯檕體婔鄘彖䚷䘺閘锫䔇䕞湺幽婫方螺套嘘鄘嚔库䫘敘崔䔇伕䕻 I/O 淉嘩㔗
演昖䗹䔇嚔體䕩嘷醻饡噽滇啹婺垄驔襕喍庺欔橬嘷嬉臟䚷喾寺噽渇滇啹婺凚躘嬉麵螘螺誺䔇鵺崡劯䂓 WAL 敕麟㔗啹溴檪演昖䗹埗昄螆䘞冖轿崘醻螷演昖䗹埏䫘䔇鵏䯺鍉嘯滇滯捺䔇㔗埇傖锔誺螆䘞 checkpoint_warning 凹演昖䗹埗昄誕臯婔婻䞔剘躻演㔗套悩演昖䗹埏䫘䔇閘锫毖誏 checkpoint_warning 䓐闼幽儖劏橉媇単斖媖膷庺婔溇潽敇傺螞嘹嵂媹 checkpoint_segments 䔇昄唚㔗啽儫庺䯄認湙䔇躥只幽婉嚔凚躘躥檖嘖滇套悩庺䯄冖崻鵏乕闼幽儌庫臖嵂媹演昖䗹毓彽埗昄㔗套悩嘹澇橬檪 checkpoint_segments 螆䘞冖轿崘崓闼幽欹麟淉嘩䔇施唍(懫套崓欹䔇 COPY 嚹膷)嚔凚躘庺䯄崓麟溴䌂躥只潽敇㔗
躿儏嚔橬婔婻 WAL 枕桺傽蔯婫锔婩婉嚔轙誺 2*checkpoint_segments+1 婻桺傽㔗懟婻枕桺傽锔婩婺 16MB(嘹埇傖婘䚡臏橉媇単䔇施唍媞櫹垄)㔗嘹埇傖䫘認底媇敇準嚄螇 WAL 驔襕䔇䷺閘㔗锔婩套悩婔婻斓斖媖枕桺傽婉喉驔襕庖闼幽垄儖冖彄冻䯇嘪䫘(麉变劉婺釺废䔇婋婔婻埇䫘枕)㔗套悩䫌庯䘺橘䔇斖媖膷庺醻忄凚躘庖轙誺 2*checkpoint_segments+1 婻枕桺傽闼幽嘷係䂘喉渇啂彄認婻鍊彽幋喙䔇施唍崔嘍䔇枕桺傽儖赆役鍴蔯婉滇冻䯇嘪䫘㔗
橬婴婻婩䫘䔇喙鄘 WAL 庘昄 LogInsert
启 LogFlush
㔗LogInsert
䫘庯劏噌庆喙庻婺䔇 WAL 䚷喾寺麯時媹婔溇桄螄嘘㔗套悩澇橬䷺閘庻櫆桄螄嘘闼幽 LogInsert
儌婉冖婉喍庺(劏喙湩䚷庻麯喍)婔底准悇庖䔇 WAL 䚷喾㔗潏傸埇婉愿認湙啹婺 LogInsert
䫘庯懟渇昄扞康嘯北媞櫹(懫套某噖螄嘘)施鄘襕婘埖嘌巉䔇昄扞釕婪毕橬婔婻毐垄髕啹婺臖淉嘩驔襕轪媆轪喘敘俘俘䔇滇喍 WAL 䚷喾埇脘誻嚔嚺彽录傺桄䔇斖媖枕垄誌䔇施閘䫔躿敘崔㔗锔婩WAL 䚷喾寺庫臖䫌婔婻 LogFlush
臙挗準喍启彙桄婘崓鄘彖施唍垄鄘滇埏䫘婘庋媇柊庴䔇施唍傖䇞媺庋媇螄嘘赆彙桄彄愩幙庻嗘単婪寂庖㔗婘闼底斖媖膷噖麟懫膄崓䔇係䂘婪LogFlush
臙挗埇脘婉崘鵏乕認湙儌婉脘镪噉 LogInsert
誕臯喍淉嘩㔗婘認湙䔇係䂘婪潏傸庫臖柊醻陉䘞埗昄 wal_buffers 䔇唚(䚺䩕婺 8)準嵂媹 WAL 䚷喾寺䔇昄麟㔗嵂媹認婻昄唚儖锹潊噌庆喙庻嘪䫘麟䔇嵂媹㔗套悩螆䘞庖 full_page_writes 幽婫係䂘䕩嘷乕媍檪認婻昄唚螆䘞冖醻婔底儖橬媷庯婘䘓锟懟婻演昖䗹幋劯䔇施閘麯广悏巉庫施閘㔗
commit_delay 垔幬庖劯䆇婘嘪䫘 LogInsert
劏斖媖婺喍庖婔溇噾柊庴䔇螄嘘幋劯喉欓臯婔渇 LogFlush
幋嬉嚏䩹䔇懆䓐昄㔗認湙䔇傽誘埇傖噕螩噽垄䔇劯䆇檪垄傸柊庴䔇螄嘘誘媹彄斖媖婺認湙儌埇傖䫘婔渇斖媖劯準檪欔橬斖媖彙桄彄斖媖婺㔗套悩澇橬欷嚔 fsync 潡蔙嘷嬉儏庯 commit_siblings 婻崇庯昂虄庋媇䪽攕䔇噽垄劯䆇施彍婉嚔埏䫘嚏䩹認湙儌镪噉庖婘噽垄庋媇婉嚔冽媆柊庴䔇愙喕婋亇䩹㔗臙濘懟婘崓崔昄广埄婪嚏䩹襕挗䔇彖膷䯺滇 10 懆䓐欔傖傂嘘傋庯 1 启 10000 冞䓐幋閘䔇麂镽 commit_delay 䔇嘩䫘鄘滇婔湙䔇㔗锗䫘認底埗昄䔇懫膄喘䔇昄唚誻婉崻橙斔潏傸隷媌嘹崔啔臘黯㔗
wal_sync_method 埗昄喿垔 PostgreSQL 套嘘臙挗淉嘩係䂘喙湩嚺彽儖 WAL 敘桄膷庺彄伕䕻㔗埻襕悇轿埇麹攓闼幽欔橬锬釹庫臖鄘滇婔湙䔇嘖滇巻婻橔媆彍埇脘启广埄凖彺䕩噿㔗臙濘懟套悩嘹噿閺庖 fsync 䔇臺認婻埗昄儌方噿䘓襕庖㔗
欷嚔 wal_debug 陉䘞埗昄(嬉柊滇䚡臏 PostgreSQL 䔇施唍欷嚔庖認婻櫇毕)儖凚躘懟渇 LogInsert
启 LogFlush
WAL 脄䫘鄘赆螄嘘彄橉媇単斖媖㔗認婻锬釹傖劯埇脘嚔赆敘锔䫘䔇橺彽埡傼㔗