首页 > 数据库技术 > 详细

postgresql 运维常用脚本

时间:2021-08-10 23:38:16      阅读:43      评论:0      收藏:0      [点我收藏+]

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 运维常用脚本

原文:https://www.cnblogs.com/hixiaowei/p/15125895.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!