postgres开启慢查询日志

1.全局设置
修改配置postgres.conf:

log_min_duration_statement=5000

然后加载配置:

postgres=# select pg_reload_conf()
postgres=# show log_min_duration_statement;
 log_min_duration_statement 
----------------------------
 5s
(1 row)

  

2.也可以针对某个用户或者某数据库进行设置

postgres=# alter database test set log_min_duration_statement=5000;

  

原文地址:https://www.cnblogs.com/abclife/p/11188449.html