Skip to content

Commit 93c73a8

Browse files
authored
Add current_queries_status_with_locks for pg10
1 parent ac81ce6 commit 93c73a8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,35 @@ SELECT count(pg_stat_activity.pid) AS number_of_queries,
5151
ORDER BY max_wait_time DESC;
5252
```
5353

54+
### current_queries_status_with_locks (pg10)
55+
```sql
56+
PREPARE current_queries_status_with_locks AS
57+
SELECT count(pg_stat_activity.pid) AS number_of_queries,
58+
substring(trim(LEADING
59+
FROM regexp_replace(pg_stat_activity.query, '[\n\r]+'::text,
60+
' '::text, 'g'::text))
61+
FROM 0
62+
FOR 200) AS query_name,
63+
max(age(CURRENT_TIMESTAMP, query_start)) AS max_wait_time,
64+
wait_event,
65+
usename,
66+
locktype,
67+
mode,
68+
granted
69+
FROM pg_stat_activity
70+
LEFT JOIN pg_locks ON pg_stat_activity.pid = pg_locks.pid
71+
WHERE query != '<IDLE>'
72+
AND query NOT ILIKE '%pg_%' AND query NOT ILIKE '%application_name%' AND query NOT ILIKE '%inet%'
73+
AND age(CURRENT_TIMESTAMP, query_start) > '5 milliseconds'::interval
74+
GROUP BY query_name,
75+
wait_event,
76+
usename,
77+
locktype,
78+
mode,
79+
granted
80+
ORDER BY max_wait_time DESC;
81+
```
82+
5483
### query_stats
5584
```sql
5685
PREPARE query_stats AS

0 commit comments

Comments
 (0)