有几种情况
1. 查看历史慢sql
首先要设置log_min_duration_statement,记录慢sql。
然后在参数log_directory 指定的目录中查看日志。
2. 查看当前慢sql
select * from pg_stat_activity where state<>'idle' and now()-query_start > interval '1 s' order by query_start ;
postgres=# select * from pg_stat_activity where state<>'idle' and now()-query_start > interval '1 s' order by query_start;