Skip to content

Commit 4b0722c

Browse files
committed
updated postgres_idle_sessions_current_db_kill_pre92.sql
1 parent ba1d84b commit 4b0722c

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

postgres_idle_sessions_current_db_kill_pre92.sql

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,29 @@
2020
-- Tested on PostgreSQL 8.4, 9.0, 9.1
2121

2222
SELECT
23-
pg_terminate_backend(procpid)
23+
pg_terminate_backend(procpid)
2424
FROM
25-
pg_stat_activity
25+
pg_stat_activity
2626
WHERE
27-
-- don't kill yourself
28-
procpid <> pg_backend_pid()
29-
-- AND
30-
-- don't kill your admin tools
31-
--application_name !~ '(?:psql)|(?:pgAdmin.+)'
32-
-- AND
33-
--usename not in ('postgres')
34-
AND
35-
datname = current_database()
36-
AND
37-
current_query in ('')
38-
AND
39-
waiting
40-
--state in ('idle', 'idle in transaction', 'idle in transaction (aborted)', 'disabled')
41-
AND
42-
--state_change < current_timestamp - INTERVAL '15' MINUTE;
43-
(
44-
(current_timestamp - query_start) > interval '15 minutes'
45-
OR
46-
(query_start IS NULL AND (current_timestamp - backend_start) > interval '15 minutes')
47-
)
27+
-- don't kill yourself
28+
procpid <> pg_backend_pid()
29+
-- AND
30+
-- don't kill your admin tools
31+
--application_name !~ '(?:psql)|(?:pgAdmin.+)'
32+
-- AND
33+
--usename not in ('postgres')
34+
AND
35+
datname = current_database()
36+
AND
37+
current_query in ('')
38+
AND
39+
waiting
40+
--state in ('idle', 'idle in transaction', 'idle in transaction (aborted)', 'disabled')
41+
AND
42+
--state_change < current_timestamp - INTERVAL '15' MINUTE;
43+
(
44+
(current_timestamp - query_start) > interval '15 minutes'
45+
OR
46+
(query_start IS NULL AND (current_timestamp - backend_start) > interval '15 minutes')
47+
)
4848
;

0 commit comments

Comments
 (0)