Skip to content

Commit dc04eaf

Browse files
authored
Merge pull request #24 from volodymyrpavlenko/get_oldest_transaction_timestamp_per_database
Make `sec-since-oldest-xact-start` metric database-specific
2 parents 31471d1 + 5bb8169 commit dc04eaf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

postgresql_metrics/postgres_queries.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ def get_lock_statistics(conn):
184184

185185

186186
def get_oldest_transaction_timestamp(conn):
187-
sql = ("SELECT datname, now(), xact_start FROM pg_stat_activity WHERE xact_start IS NOT NULL "
187+
sql = ("SELECT datname, now(), xact_start FROM pg_stat_activity "
188+
"WHERE xact_start IS NOT NULL AND datname=current_database() "
188189
"ORDER BY xact_start ASC LIMIT 1")
189190
results = query(conn, sql)
190191
if results:

0 commit comments

Comments
 (0)