利用pg_stat_statements排查PostgreSQL中的慢SQL
条评论- 编辑
postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
track_activity_query_size = 16384
- 启用扩展
create extension pg_stat_statements
- 查找慢
SQL
select round((100 * total_time / sum(total_time) over ())::numeric, 2) percent,
round(total_time::numeric, 2) as total,
calls,
round(mean_time::numeric, 2) as mean,
query
from pg_stat_statements
order by total_time desc;
本文标题:利用pg_stat_statements排查PostgreSQL中的慢SQL
文章作者:牧云踏歌
发布时间:2019-03-24
最后更新:2020-10-30
原始链接:http://www.kankanzhijian.com/2019/03/24/pg_stat_statements/
版权声明:本博客文章均系本人原创,转载请注名出处