posgresql auto_explain 扩展参考


auto_explain可以定义sql执行的时间以记录在postgres中日志中,包含sql的直接计划,在线上优化时可以说是一个非常好用的工具,
另外结合pg_stat_statements,可以说是分析线上慢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'  #记录执行超过1s的sql
auto_explain.log_min_duration = 100   #记录执行超过100ms的sql
#auto_explain.log_min_duration = 0      #记录全部执行的sql
auto_explain.log_timing = on
auto_explain.log_verbose = on

重启数据库:
pg_ctl restart -m fast
备注:
auto_explain.log_min_duration 可以随时修改,修改后reload即可,线上可以根据需要进行在线调整
修改需要重启数据库shared_preload_libraries = 'auto_explain' ;

上一篇:微信小程序api视频课程-界面-交互-wx.showToast 消息提示框的使用


下一篇:PHP如何获取视频总时长与码率等信息