Skip to content

Instantly share code, notes, and snippets.

View sashaaro's full-sized avatar

Aleksandr sashaaro

View GitHub Profile
@sashaaro
sashaaro / lock.sql
Last active July 26, 2023 16:39 — forked from moofkit/gist:2146f18953be9053ae372c063d28912b
lock monitor. postgresql
CREATE VIEW lock_monitor AS
SELECT COALESCE(((blockingl.relation)::regclass)::text, blockingl.locktype) AS locked_item,
(now() - blockeda.query_start) AS waiting_duration,
blockeda.pid AS blocked_pid,
blockeda.query AS blocked_query,
blockedl.mode AS blocked_mode,
blockinga.pid AS blocking_pid,
blockinga.query AS blocking_query,
blockingl.mode AS blocking_mode
FROM (((pg_locks blockedl