-
[PPAS / Postgresql] SQL 경합 현상 분석 쿼리Postgresql / PPAS/Lock 2014. 11. 18. 17:26
- SQL 경합 현상 분석 쿼리
SELECT bl.pid AS blocked_pid, a.usename AS blocked_user, ka.current_query AS blocking_statement,
TO_CHAR(NOW() - ka.query_start, 'HH24:MI:SS') AS blocking_duration,
kl.pid AS blocking_pid, ka.usename AS blocking_user,
a.current_query AS blocked_statement,
TO_CHAR(NOW() - a.query_start, 'HH24:MI:SS') AS blocked_duration
FROM pg_catalog.pg_locks bl
JOIN pg_catalog.pg_stat_activity a ON bl.pid = a.procpid
JOIN pg_catalog.pg_locks kl
JOIN pg_catalog.pg_stat_activity ka
ON kl.pid = ka.procpid
ON bl.transactionid = kl.transactionid AND bl.pid != kl.pid
WHERE bl.granted = 't';
-------------------------------------------------------------------------------
SELECT bl.pid AS blocked_pid, a.usename AS blocked_user, ka.query AS blocking_statement,
TO_CHAR(NOW() - ka.query_start, 'HH24:MI:SS') AS blocking_duration,
kl.pid AS blocking_pid, ka.usename AS blocking_user,
a.query AS blocked_statement,
TO_CHAR(NOW() - a.query_start, 'HH24:MI:SS') AS blocked_duration
FROM pg_catalog.pg_locks bl
JOIN pg_catalog.pg_stat_activity a ON bl.pid = a.pid
JOIN pg_catalog.pg_locks kl
JOIN pg_catalog.pg_stat_activity ka
ON kl.pid = ka.pid
ON bl.transactionid = kl.transactionid AND bl.pid != kl.pid
WHERE bl.granted = 'f'
'Postgresql / PPAS > Lock' 카테고리의 다른 글
[PostgreSQL] LOCK TABLE table_name IN A (0) 2015.01.28 PostgreSQL ShareLock Deadlocks (0) 2014.11.26 [PPAS / Postgresql] pg_locks 테이블을 참고하여 Transaction 사용하는 테이블 확인 (0) 2014.11.18