溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

posgresql auto_explain 擴(kuò)展參考

發(fā)布時間:2020-07-27 14:19:19 來源:網(wǎng)絡(luò) 閱讀:448 作者:春秋小記 欄目:數(shù)據(jù)庫


auto_explain可以定義sql執(zhí)行的時間以記錄在postgres中日志中,包含sql的直接計劃,在線上優(yōu)化時可以說是一個非常好用的工具,
另外結(jié)合pg_stat_statements、log_min_duration_statement和log_statement = all 可以說是分析線上慢sql的利器,auto_explain包含在安裝軟件中,可以直接安裝使用:
[root@my1 ~]# cd postgresql-10.0/contrib/auto_explain
[root@my1 auto_explain]# make &&  make install

配置postgresql.conf文件:
shared_preload_libraries = 'auto_explain'
# auto_explain
#auto_explain.log_min_duration = '1s'  #記錄執(zhí)行超過1s的sql
auto_explain.log_min_duration = 100   #記錄執(zhí)行超過100ms的sql
#auto_explain.log_min_duration = 0      #記錄全部執(zhí)行的sql
auto_explain.log_timing = on
auto_explain.log_verbose = on

重啟數(shù)據(jù)庫:
pg_ctl restart -m fast
備注:
auto_explain.log_min_duration 可以隨時修改,修改后reload即可,線上可以根據(jù)需要進(jìn)行在線調(diào)整
修改需要重啟數(shù)據(jù)庫shared_preload_libraries = 'auto_explain' ;

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI