From bc47a0074b4e49b2136621ba58570418bc687f94 Mon Sep 17 00:00:00 2001 From: Ibrar Ahmed Date: Mon, 12 Oct 2020 22:53:37 +0000 Subject: [PATCH] Issue - (#53): Fix a bug where the query response time histogram does show proper counters. PG-143 : PostgreSQL-13 has a different issue so, special handling for PostgreSQL-13 done. --- pg_stat_monitor.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index 0667a6b..50d9f3d 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -826,16 +826,20 @@ static void pgss_store(const char *query, uint64 queryId, e->counters.time[kind].max_time = total_time; } - for (i = 0; i < MAX_RESPONSE_BUCKET - 1; i++) + /* increment only in case of PGSS_EXEC */ + if (kind == PGSS_EXEC) { - if (total_time < PGSM_RESPOSE_TIME_LOWER_BOUND + (PGSM_RESPOSE_TIME_STEP * i)) + for (i = 0; i < MAX_RESPONSE_BUCKET - 1; i++) { - e->counters.resp_calls[i]++; - break; + if (total_time < PGSM_RESPOSE_TIME_LOWER_BOUND + (PGSM_RESPOSE_TIME_STEP * i)) + { + e->counters.resp_calls[i]++; + break; + } } - } - if (total_time > PGSM_RESPOSE_TIME_LOWER_BOUND + (PGSM_RESPOSE_TIME_STEP * MAX_RESPONSE_BUCKET)) + if (total_time > PGSM_RESPOSE_TIME_LOWER_BOUND + (PGSM_RESPOSE_TIME_STEP * MAX_RESPONSE_BUCKET)) e->counters.resp_calls[MAX_RESPONSE_BUCKET - 1]++; + } e->counters.calls[kind].rows += rows; e->counters.blocks.shared_blks_hit += bufusage->shared_blks_hit;