Permalink
Browse files

add tracking on transaction-level statistics (not just statement-level)

  • Loading branch information...
1 parent 67b480f commit 45c3f2e24ae67d81354c10a4f638ac43bfa18d19 @tvondra committed Oct 30, 2016
Showing with 17 additions and 1 deletion.
  1. +17 −1 sql/query_histogram--1.1.sql
@@ -3,6 +3,12 @@ CREATE OR REPLACE FUNCTION query_histogram( IN scale BOOLEAN DEFAULT TRUE, OUT b
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'query_histogram'
LANGUAGE C IMMUTABLE;
+
+CREATE OR REPLACE FUNCTION xact_histogram( IN scale BOOLEAN DEFAULT TRUE, OUT bin_from INT, OUT bin_to INT, OUT bin_count BIGINT, OUT bin_count_pct REAL,
+ OUT bin_time DOUBLE PRECISION, OUT bin_time_pct REAL)
+ RETURNS SETOF record
+ AS 'MODULE_PATHNAME', 'xact_histogram'
+ LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION query_histogram_reset()
RETURNS void
@@ -14,4 +20,14 @@ CREATE OR REPLACE FUNCTION query_histogram_get_reset()
AS 'MODULE_PATHNAME', 'query_histogram_get_reset'
LANGUAGE C IMMUTABLE;
-CREATE OR REPLACE VIEW query_histogram AS SELECT histogram.*, round(1000000*bin_time/(CASE WHEN bin_count > 0 THEN bin_count ELSE 1 END))/1000 AS bin_time_avg FROM query_histogram(true) histogram;
+CREATE OR REPLACE VIEW query_histogram AS
+ SELECT
+ histogram.*,
+ round(1000000 * bin_time / (CASE WHEN bin_count > 0 THEN bin_count ELSE 1 END)) / 1000 AS bin_time_avg
+ FROM query_histogram(true) histogram;
+
+CREATE OR REPLACE VIEW xact_histogram AS
+ SELECT
+ histogram.*,
+ round(1000000 * bin_time / (CASE WHEN bin_count > 0 THEN bin_count ELSE 1 END)) / 1000 AS bin_time_avg
+ FROM xact_histogram(true) histogram;

0 comments on commit 45c3f2e

Please sign in to comment.