Postgresql - extension - auto_explain

auto_explain module 提供了在不需要手动执行explain时,自动记录慢SQL的功能。
针对跟踪 优化SQL非常有帮助。

加载方式:

  1. 在postgresql.conf中配置(需要重启)
shared_preload_libraries = 'auto_explain'
  1. 在会话中开启(必须是superuser)
LOAD 'auto_explain';

参数配置:

auto_explain.log_min_duration (integer): 记录的最短执行时间,milliseconds
auto_explain.log_analyze (boolean): explain 是否输出为 explain analyze
auto_explain.log_buffers (boolean): explain 中是否记录buffers
auto_explain.log_timing (boolean): explain 中是否记录timing
auto_explain.log_triggers (boolean): trigger执行时间是否包含在内
auto_explain.log_verbose (boolean): explain 中是否记录verbose
auto_explain.log_settings (boolean): 更该信息是否记录。
auto_explain.log_format (enum): 记录格式 (text, xml, json, and yaml)
auto_explain.log_level (enum): 日志记录级别(DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, INFO, NOTICE, WARNING, and LOG)
auto_explain.log_nested_statements (boolean): 是否将嵌套语句(在函数内部执行的语句)视为记录日志。 禁用时,仅记录顶级查询计划。
auto_explain.sample_rate (real): 是否仅解释每个会话中的一部分语句。 默认值为1,表示解释所有查询。 如果是嵌套语句,将全部解释或不解释。
发布了213 篇原创文章 · 获赞 7 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/chuckchen1222/article/details/103277544