From 84de947da6d95165cca95a91c9a4abc440fdd01b Mon Sep 17 00:00:00 2001 From: Ibrar Ahmed Date: Mon, 11 Jan 2021 17:57:27 +0000 Subject: [PATCH] PG-160: Integration with PGXN. --- META.json | 46 ++++++++++++++++++++++++++++++++++++++++++++++ pg_stat_monitor.c | 2 ++ 2 files changed, 48 insertions(+) create mode 100644 META.json diff --git a/META.json b/META.json new file mode 100644 index 0000000..fcb66e0 --- /dev/null +++ b/META.json @@ -0,0 +1,46 @@ +{ + "name": "pg_stat_monitor", + "abstract": "PostgreSQL Query Performance Monitoring Tool", + "description": "The pg_stat_monitor is a PostgreSQL Query Performance Monitoring tool, based on PostgreSQL's contrib module pg_stat_statements. PostgreSQL’s pg_stat_statements provides the basic statistics, which is sometimes not enough. The major shortcoming in pg_stat_statements is that it accumulates all the queries and their statistics and does not provide aggregated statistics nor histogram information. In this case, a user needs to calculate the aggregate which is quite expensive.", + "version": "0.7.1", + "maintainer": [ + "ibrar.ahmed@percona.com" + ], + "license": "postgresql", + "provides": { + "pg_stat_monitor": { + "abstract": "PostgreSQL Query Performance Monitoring Tool", + "file": "pg_stat_monitor--1.0.sql", + "docfile": "README.md", + "version": "0.7.1" + } + }, + "prereqs": { + "runtime": { + "requires": { + "PostgreSQL": "11.0.0" + } + } + }, + "resources": { + "bugtracker": { + "web": "https://jira.percona.com/projects/PG/issues" + }, + "repository": { + "url": "https://github.com/percona/pg_stat_monitor.git", + "web": "https://github.com/percona/pg_stat_monitor", + "type": "git" + } + }, + "generated_by": "ibrar.ahmed@percona.com", + "meta-spec": { + "version": "1.0.0", + "url": "http://pgxn.org/meta/spec.txt" + }, + "tags": [ + "monitoring", + "statistics-collector", + "statistics" + ] +} + diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index 5a15608..0ea8ebb 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -1196,6 +1196,8 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo, values[i++] = CStringGetTextDatum(pgss->bucket_start_time[entry->key.bucket_id]); for (kind = 0; kind < PGSS_NUMKIND; kind++) { + if (tmp.calls[kind].calls == 0) + tmp.calls[kind].calls++; values[i++] = Int64GetDatumFast(tmp.calls[kind].calls); values[i++] = Float8GetDatumFast(tmp.time[kind].total_time); values[i++] = Float8GetDatumFast(tmp.time[kind].min_time);