Difference between revisions of "Zabbix slow queries"
Jump to navigation
Jump to search
(Created page with "``` SELECT pid, user, pg_stat_activity.query_start, now() - pg_stat_activity.query_start AS query_time, query, state, wait_event_type, wait_event FROM pg_stat_...") |
|||
Line 11: | Line 11: | ||
FROM pg_stat_activity | FROM pg_stat_activity | ||
WHERE (now() - pg_stat_activity.query_start) > interval '2 minutes' and state != 'idle' order by backend_start limit 10; | WHERE (now() - pg_stat_activity.query_start) > interval '2 minutes' and state != 'idle' order by backend_start limit 10; | ||
+ | ``` | ||
+ | |||
+ | # Find & terminate slow queries | ||
+ | ``` | ||
+ | SELECT | ||
+ | pid, | ||
+ | now() - pg_stat_activity.query_start AS duration, | ||
+ | query, | ||
+ | state | ||
+ | FROM pg_stat_activity | ||
+ | WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes'; | ||
``` | ``` |
Revision as of 17:49, 7 May 2022
SELECT pid, user, pg_stat_activity.query_start, now() - pg_stat_activity.query_start AS query_time, query, state, wait_event_type, wait_event FROM pg_stat_activity WHERE (now() - pg_stat_activity.query_start) > interval '2 minutes' and state != 'idle' order by backend_start limit 10;
Find & terminate slow queries
SELECT pid, now() - pg_stat_activity.query_start AS duration, query, state FROM pg_stat_activity WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes';