File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,35 @@ SELECT count(pg_stat_activity.pid) AS number_of_queries,
51
51
ORDER BY max_wait_time DESC ;
52
52
```
53
53
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
+
54
83
### query_stats
55
84
``` sql
56
85
PREPARE query_stats AS
You can’t perform that action at this time.
0 commit comments