postgresql 运维常用脚本

1.查下超过10 s的查询语句

select 
*
From pg_stat_activity where query_start<=now()- interval10 sec and state not in (idle)
and pid<>pg_backend_pid() and query ilike select%
order by query_start
;

2. 超过10s的查询会被干掉

select 
pg_terminate_backend(pid)
From pg_stat_activity where query_start<=now()- interval10 sec and state not in (idle)
and pid<>pg_backend_pid() and query ilike select%
order by query_start
;

 

wenji发布的那些文档要找时间多看看了

postgresql 运维常用脚本

上一篇:操作数据库


下一篇:MySQL 5.7自动安装脚本(shell)