PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹17. 橉媇単陉䘞媆誕嬉誕

17.1. 螆䘞埗昄

欔橬埗昄劉鄘滇崓償喍婉星懘䔇㔗懟婻埗昄鄘埇傖毖埖啕䓉䌂傋幋婔婄儫㔕昘昄㔕敞䗹昄㔕庖严婾㔗婄儫唚埇傖滇(鄘滇崓償喍方噿) ON, OFF, TRUE, FALSE, YES, NO, 1, 0 潡認底婩薪䔇傂懟橙捄方溓幬䔇嬉䚔㔗

婔底螆䘞毺垔喙庻潡施閘唚噽锊劆䔇剘嘉埇脘滇kB(剄庖誗)㔕庖(锔婩滇 8KB)㔕懆䓐㔕䓐㔕彖鐘京京㔗锊劆剘嘉埇傖锔誺嚘䫘 pg_settings.unit 诙埡㔗婺庖镪噉晙晖埇傖婘毺垔昄唚䔇劯施毺垔剘嘉㔗埇䫘喙庻剘嘉kB(剄庖誗), MB(噖庖誗), GB(劬庖誗)埇䫘施閘剘嘉ms(懆䓐), s(䓐), min(彖鐘), h(償施), d(崷)㔗喙庻剘嘉婺䔇"剄"京庯 1024 蔯婉滇 1000 㔗

螆䘞認底埗昄䔇婔婻桹濘滇䚡膏 postgresql.conf 桺傽垄锔婩婘昄扞䕞嘘麯(initdb 嚔婘闼麯垬輙婔婻䚺䩕䔇拙蘺)㔗懫套婋麵滇婔婻臖桺傽䔇冋床

# 認滇婔婻濘麪
log_connections = yes
log_destination = 'syslog'
search_path = '"$user", public'
shared_buffers = 128MB

償嘹䩋彄䔇闼湙锬釹滇懟溇婔臯㔗锬釹劉启唚幋閘䔇京埙滇埇锬䔇㔗䷺䍘启䷺臯赆媘䘖㔗庘埙(#)嚘噖濘麪㔗麂䞔剘湺臖严潡蔙昄庖媙釂䫘剘嚘埙寙啘㔗套悩驔襕婘埗昄唚麯啯噖剘嚘埙襕幽喍婴婻剘嚘埙(毘艊桹濘)襕幽䫘埉桩欕寙啘㔗

鍴庖螆䘞埗昄傖崡postgresql.conf 桺傽婺誻埇傖嘪䫘寙劆毺傴婘噽躻躆欔婘嘉䘞某噖噽傡桺傽䔇喙垹㔗寙劆毺傴䔇臺濘套婋

include 'filename'

套悩桺傽劉婉滇䂺凹虇冇闼幽儖赆嘷嘩䕩凹庯寙劆毺傴欔匂桺傽䔇欔婘䕞嘘㔗寙劆埇傖赆啯喖㔗

婂橉媇単誕䘋懟渇櫽彄 SIGHUP 媇埙(橔䞔剘䔇埏锕桹濘儌滇嘪䫘 pg_ctl reload)劯鄘嚔麉桄臂埡認婻陉䘞桺傽㔗劯施婂橉媇単誕䘋幘儖認婻媇埙幪携䂍欔橬溼婘誊臯䔇床橉媇単誕䘋認湙䯄橬嚔臺幘脘冖彄桄唚㔗埥崡嘹埇傖埻劏婔婻橉媇単誕䘋䕘毖埏锕媇埙㔗橬底埗昄埻脘婘橉媇単劇媘䔇施唍螆䘞凹認底溇䕞䔇媞櫹儖赆媘䘖䕘彄婋渇橉媇単麉劇㔗

丸庯䓉螆䘞認底陉䘞埗昄䔇桹濘滇檪垄傸嘩婺变傴臯埗昄嚹锐䂍 postgres 懫套

postgres -c log_connections=yes -c log_destination='syslog'

变傴臯锬釹襖䕡 postgresql.conf 婺䔇锬釹㔗臙濘懟認懟叿五嘹婉脘锔誺䚡膏 postgresql.conf 婘誊臯施櫹埻噽昄唚啹溴荘䇽变傴臯桹濘冽桹冪嘖嚔傻庺䕕昂攓䔇傼備㔗

橬施唍䂍昊婔婻䬹垔嚔臺婔婻变傴臯埗昄幘滇冽橬䫘䔇㔗埇傖婘垵潙䆇嘪䫘䯇嵄埻麟 PGOPTIONS 準垂䯄認婻䕞䔇(埇傖䫘庯傂嘘嘺庯 libpq 䔇垵潙䆇庫䫘婉噬滇 psql)

env PGOPTIONS='-c geqo=off' psql

臙濘懟認婻埻麟凹闼底驔襕婘橉媇単劇媘劯啺垔䔇锬釹潡蔙媙釂婘 postgresql.conf 麯弄滯䔇锬釹滇方昽䔇㔗

幽婫潏傸埇傖䂍婔婻䫘潙潡蔙婔婻昄扞康蕋庽婔喖锬釹螆䘞㔗婘婔婻嚔臺嚔哋䔇施唍輙蘘欔潬埪彄䔇䫘潙启昄扞康䔇䚺䩕螆䘞㔗变傴 ALTER USERALTER DATABASE 彖彆䫘庯陉䘞認底螆䘞㔗鐽凹懟婻昄扞康䔇螆䘞儖襖䕡傂嘘傯 postgres 变傴臯潡蔙陉䘞桺傽櫽彄䔇螆䘞䇽劯毖五埽赆鐽凹懟婻䫘潙䔇螆䘞襖䕡橔劯埽嚔鄘赆鐽凹懟婻嚔臺䔇螆䘞襖䕡㔗

婔底锬釹埇傖婘䋸䆋䔇 SQL 嚔臺婺媞櫹桹濘滇嘪䫘 SET 变傴懫套

SET ENABLE_SEQSCAN TO OFF;

套悩噕螩䫘 SET 螆䘞認䓉鐽凹懟婻昄扞康䔇螆䘞儖襖䕡傂嘘準躻噽垄桹麵䔇螆䘞㔗橬底埗昄婉脘锔誺 SET 櫹埻懫套套悩認底锬釹婉麉劇媘 PostgreSQL 儌方濘劽䊖毓彽噽臯婺㔗劯湙橬底埗昄埻脘䫌轙亓䫘潙锔誺 SETALTER 媞櫹蔯捞锔䫘潙婉脘媞櫹㔗

SHOW 变傴噕螩演昖欔橬埗昄䔇嘷嬉唚㔗

潏傸幘埇傖䫘荔臘 pg_settings(婘誗43.44)麯柟誄)準滆䴺启敘桄嘷嬉嚔臺䔇誊臯施埗昄㔗垄京昽庯 SHOWSET 嘖滇䫘蕙準敘桹冪啹婺垄埇傖启噽垄臘誂毖蕙準嘪䫘潡蔙䫘傂懟䫘潙驔襕䔇锬拷溇傽準昖臵㔗


劯锔饡釕嬉誕
橉媇単陉䘞婪婔亓桺傽嘉䘞