1. 查看占io的sql: postgres=# select userid::regrole, dbid, query from pg_stat_statements order by total_time desc limit 5;
ERROR: pg_stat_statements must be loaded via shared_preload_libraries
2. 添加配置
#postgresql.conf
#------------------------------------------------------------------------------
# PG_STAT_STATEMENTS OPTIONS
#------------------------------------------------------------------------------
shared_preload_libraries = 'pg_stat_statements'
custom_variable_classes = 'pg_stat_statements'
pg_stat_statements.max = 1000
pg_stat_statements.track = all
————————————————
用一个例子来演示会更加清晰