From 5bb81699688144e38c8848b5810a445f4eef5223 Mon Sep 17 00:00:00 2001 From: Volodymyr Pavlenko Date: Wed, 24 Feb 2021 18:11:21 +0100 Subject: [PATCH] Make `sec-since-oldest-xact-start` metric database-specific --- postgresql_metrics/postgres_queries.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/postgresql_metrics/postgres_queries.py b/postgresql_metrics/postgres_queries.py index 6491114..38c1f5d 100644 --- a/postgresql_metrics/postgres_queries.py +++ b/postgresql_metrics/postgres_queries.py @@ -184,7 +184,8 @@ def get_lock_statistics(conn): def get_oldest_transaction_timestamp(conn): - sql = ("SELECT datname, now(), xact_start FROM pg_stat_activity WHERE xact_start IS NOT NULL " + sql = ("SELECT datname, now(), xact_start FROM pg_stat_activity " + "WHERE xact_start IS NOT NULL AND datname=current_database() " "ORDER BY xact_start ASC LIMIT 1") results = query(conn, sql) if results: