postgresql中的pg_cancel_backend

前端之家收集整理的这篇文章主要介绍了postgresql中的pg_cancel_backend前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

postgresql 中的一些定义,如下:

pg_cancel_backend and pg_terminate_backend send signals (SIGINT or SIGTERM respectively) to backend processes identified by process ID. The process ID of an active backend can be found from the procpid column of the pg_stat_activity view,or by listing the postgres processes on the server (using ps on Unix or the Task Manager on Windows ).

两者都是boolean 类型的,返回为true 或者false

pg_cancel_backend 用来取消一个进程

首先通过pg_stat_activity 查出你要取消的进程号

select procpid from pg_stat_activity where ......;

然后,用这个函数来取消

select pg_cancel_backend(procpid);

这个函数主要是取消某个进程,但是某个会话并不会因此而被强制退出

在实际场景中经常碰到一些比较复杂的查询,跑了很久跑不出来,使用这个函数也不起作用,去OS 直接killkill 不掉,就只有重启集群了。

原文链接:https://www.f2er.com/postgresql/197000.html

猜你在找的Postgre SQL相关文章