From ec1ff594b443698df67cefd8b51f80847fb17033 Mon Sep 17 00:00:00 2001 From: Ibrar Ahmed Date: Mon, 12 Oct 2020 22:39:44 +0000 Subject: [PATCH] Issue - (#54): Planning counters require renaming. PG-144 : Changing planing counter name to sync with pg_stat_statment. --- pg_stat_monitor--1.0.sql | 13 ++++++------- pg_stat_monitor.c | 4 ++-- pg_stat_monitor.h | 2 ++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pg_stat_monitor--1.0.sql b/pg_stat_monitor--1.0.sql index 84b554624f5b..39334606cb66 100644 --- a/pg_stat_monitor--1.0.sql +++ b/pg_stat_monitor--1.0.sql @@ -24,7 +24,7 @@ CREATE FUNCTION pg_stat_monitor(IN showtext boolean, OUT query text, OUT bucket_start_time timestamptz, - OUT plan_calls int8, + OUT plans int8, OUT plan_total_time float8, OUT plan_min_time float8, OUT plan_max_time float8, @@ -32,13 +32,13 @@ CREATE FUNCTION pg_stat_monitor(IN showtext boolean, OUT plan_stddev_time float8, OUT plan_rows int8, - OUT total_calls int8, + OUT calls int8, OUT total_time float8, OUT min_time float8, OUT max_time float8, OUT mean_time float8, OUT stddev_time float8, - OUT affected_rows int8, + OUT rows int8, OUT shared_blks_hit int8, OUT shared_blks_read int8, @@ -103,20 +103,19 @@ CREATE VIEW pg_stat_monitor AS SELECT '0.0.0.0'::inet + client_ip AS client_ip, queryid, query, - plan_calls, + plans, round( CAST(plan_total_time as numeric), 2)::float8 as plan_total_time, round( CAST(plan_min_time as numeric), 2)::float8 as plan_min_timei, round( CAST(plan_max_time as numeric), 2)::float8 as plan_max_time, round( CAST(plan_mean_time as numeric), 2)::float8 as plan_mean_time, round( CAST(plan_stddev_time as numeric), 2)::float8 as plan_stddev_time, - plan_rows, - total_calls, + calls, round( CAST(total_time as numeric), 2)::float8 as total_time, round( CAST(min_time as numeric), 2)::float8 as min_time, round( CAST(max_time as numeric), 2)::float8 as max_time, round( CAST(mean_time as numeric), 2)::float8 as mean_time, round( CAST(stddev_time as numeric), 2)::float8 as stddev_time, - affected_rows, + rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index 69b705e17172..0667a6b01f2d 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -89,7 +89,7 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString, static uint64 pgss_hash_string(const char *str, int len); static void pgss_store(const char *query, uint64 queryId, int query_location, int query_len, - bool kind, + pgssStoreKind kind, double total_time, uint64 rows, const BufferUsage *bufusage, #if PG_VERSION_NUM >= 130000 @@ -656,7 +656,7 @@ pg_get_client_addr(void) */ static void pgss_store(const char *query, uint64 queryId, int query_location, int query_len, - bool kind, + pgssStoreKind kind, double total_time, uint64 rows, const BufferUsage *bufusage, #if PG_VERSION_NUM >= 130000 diff --git a/pg_stat_monitor.h b/pg_stat_monitor.h index 699ec8fdaa50..73fb43d7e939 100644 --- a/pg_stat_monitor.h +++ b/pg_stat_monitor.h @@ -71,6 +71,7 @@ typedef struct GucVariables int guc_max; bool guc_restart; } GucVariable; + typedef enum pgssStoreKind { PGSS_INVALID = -1, @@ -195,6 +196,7 @@ typedef struct Counters CallTime time[PGSS_NUMKIND]; Blocks blocks; SysInfo sysinfo; + int plans; int resp_calls[MAX_RESPONSE_BUCKET]; /* execution time's in msec */ } Counters;