会话出现了锁等待,想要快速查询到堵塞的会话,可以使用 sys_blocking_pids 函数来实现这一目的。
sys_blocking_pids:获取哪些会话阻塞了某个会话(输入参数).
sys_backend_pid:返回当前会话的pid
示例:
会话1:
test=# select sys_backend_pid();
sys_backend_pid
-----------------
89147
(1 行记录)
test=# begin;
BEGIN
test=# update t_pindex set name ='QQ' where id =1;
UPDATE 1
会话2:(出现等待)
test=# select sys_backend_pid();
pg_backend_pid
----------------
96639
(1 行记录)
test=# truncate table t_pindex;
会话3:
test=# select sys_blocking_pids(96639);
sys_blocking_pids
-------------------
{89147}
(1 行记录)
标签:pid,sys,会话,test,pids,KingbaseES,blocking
From: https://www.cnblogs.com/kingbase/p/16651964.html