PostgreSQL之鎖監控指令碼
1.pg鎖監控指令碼
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS current_statement_in_blocking_process,
blocked_activity.application_name AS blocked_application,
blocking_activity.application_name AS blocking_application
FROM pg_catalog.pg_locks blocked_locks
JOIN pg_catalog.pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pid
JOIN pg_catalog.pg_locks blocking_locks
ON blocking_locks.locktype = blocked_locks.locktype
AND blocking_locks.DATABASE IS NOT DISTINCT FROM blocked_locks.DATABASE
AND blocking_locks.relation IS NOT DISTINCT FROM blocked_locks.relation
AND blocking_locks.page IS NOT DISTINCT FROM blocked_locks.page
AND blocking_locks.tuple IS NOT DISTINCT FROM blocked_locks.tuple
AND blocking_locks.virtualxid IS NOT DISTINCT FROM blocked_locks.virtualxid
AND blocking_locks.transactionid IS NOT DISTINCT FROM blocked_locks.transactionid
AND blocking_locks.classid IS NOT DISTINCT FROM blocked_locks.classid
AND blocking_locks.objid IS NOT DISTINCT FROM blocked_locks.objid
AND blocking_locks.objsubid IS NOT DISTINCT FROM blocked_locks.objsubid
AND blocking_locks.pid != blocked_locks.pid
JOIN pg_catalog.pg_stat_activity blocking_activity ON blocking_activity.pid = blocking_locks.pid
WHERE NOT blocked_locks.GRANTED;
指令碼顯示結果:
blocked_pid | blocked_user | blocking_pid | blocking_user | blocked_statement | current_statement_in_blocking_process | blocked_application | blocking_application
-------------+--------------+--------------+---------------+----------------------+---------------------------------------+---------------------+----------------------
63809 | tuser | 90127 | tuser2 | update t1 set id3=1; | update t1 set id3=4; | psql | psql
71865 | pg13 | 63809 | tuser | update t1 set id2=1; | update t1 set id3=1; | psql | psql
(2 rows)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69990629/viewspace-2895861/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 監控指令碼指令碼
- 監控Oracle系統中鎖的常用指令碼Oracle指令碼
- mysql監控指令碼MySql指令碼
- DBA監控指令碼指令碼
- session指令碼監控Session指令碼
- 埠監控指令碼指令碼
- oracle 監控指令碼Oracle指令碼
- listener監聽監控指令碼指令碼
- 【SQL監控】SQL完全監控的指令碼SQL指令碼
- ogg監控指令碼指令碼
- stap監控IO指令碼指令碼
- 【shell】磁碟監控指令碼指令碼
- mysql 的一個監控指令碼,監控heartbeatMySql指令碼
- mysql mon 的一個監控指令碼,監控heartbeatMySql指令碼
- Oracle DBA常用監控指令碼Oracle指令碼
- memcached程式埠監控指令碼指令碼
- Nagios 監控ESXI指令碼iOS指令碼
- 監控cpu與memory指令碼指令碼
- 資料庫監控指令碼資料庫指令碼
- (Datagurad)監控指令碼指令碼
- 監控session數量指令碼Session指令碼
- 監控硬碟空間指令碼硬碟指令碼
- 監控sqlldr執行指令碼SQL指令碼
- 監控資料庫指令碼資料庫指令碼
- cacti自定義監控指令碼指令碼
- 小花狸監控之安全加固expect備份指令碼指令碼
- nagios監控例項 -- PostgreSQL監控iOSSQL
- PostgreSQL鎖等待監控珍藏級SQL-誰堵塞了誰SQL
- 監控系統告警指令碼集合指令碼
- 監控oracle表空間指令碼Oracle指令碼
- Goldengate for nrpe監控指令碼Go指令碼
- systemtap的網路監控指令碼指令碼
- stap監控cpu指令碼小結指令碼
- 指令碼監控MySQL伺服器指令碼MySql伺服器
- [zt]資料庫監控指令碼資料庫指令碼
- LINUX主機監控指令碼Linux指令碼
- 資料庫監控指令碼(一)資料庫指令碼
- 資料庫監控指令碼(二)資料庫指令碼