PG-543: pg_stat_monitor: PostgreSQL's pg_stat_statements compatible view. (#352)
* PG-543: pg_stat_monitor: PostgreSQL's pg_stat_statements compatible view. The view now carries all the columns as pg_stat_statements. This required fixing data types of some of the columns, renaming a few, as well inclusion of new columns to make the view fully compatible with pg_stat_statements. * PG-543: pg_stat_monitor: PostgreSQL's pg_stat_statements compatible view. Updating the upgrade sql file from 1.0 to 2.0 version linked with this issue changes. * PG-543: pg_stat_monitor: PostgreSQL's pg_stat_statements compatible view. Updating datum calls to use UInt64 rather than Int64.pull/358/head
parent
7dece7cf1d
commit
1286427445
|
@ -10,7 +10,6 @@ DROP FUNCTION pgsm_create_14_view CASCADE;
|
||||||
DROP FUNCTION pgsm_create_view CASCADE;
|
DROP FUNCTION pgsm_create_view CASCADE;
|
||||||
DROP FUNCTION pg_stat_monitor_settings CASCADE;
|
DROP FUNCTION pg_stat_monitor_settings CASCADE;
|
||||||
|
|
||||||
-- pg_stat_monitor internal function, must not call outside from this file.
|
|
||||||
CREATE FUNCTION pg_stat_monitor_internal(
|
CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
IN showtext boolean,
|
IN showtext boolean,
|
||||||
OUT bucket int8, -- 0
|
OUT bucket int8, -- 0
|
||||||
|
@ -18,12 +17,12 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT dbid oid,
|
OUT dbid oid,
|
||||||
OUT client_ip int8,
|
OUT client_ip int8,
|
||||||
|
|
||||||
OUT queryid text, -- 4
|
OUT queryid int8, -- 4
|
||||||
OUT planid text,
|
OUT planid int8,
|
||||||
OUT query text,
|
OUT query text,
|
||||||
OUT query_plan text,
|
OUT query_plan text,
|
||||||
OUT pgsm_query_id int8,
|
OUT pgsm_query_id int8,
|
||||||
OUT top_queryid text,
|
OUT top_queryid int8,
|
||||||
OUT top_query text,
|
OUT top_query text,
|
||||||
OUT application_name text,
|
OUT application_name text,
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT elevel int,
|
OUT elevel int,
|
||||||
OUT sqlcode TEXT,
|
OUT sqlcode TEXT,
|
||||||
OUT message text,
|
OUT message text,
|
||||||
OUT bucket_start_time timestamp,
|
OUT bucket_start_time timestamptz,
|
||||||
|
|
||||||
OUT calls int8, -- 16
|
OUT calls int8, -- 16
|
||||||
|
|
||||||
|
@ -42,9 +41,9 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT mean_exec_time float8,
|
OUT mean_exec_time float8,
|
||||||
OUT stddev_exec_time float8,
|
OUT stddev_exec_time float8,
|
||||||
|
|
||||||
OUT rows_retrieved int8,
|
OUT rows int8,
|
||||||
|
|
||||||
OUT plans_calls int8, -- 23
|
OUT plans int8, -- 23
|
||||||
|
|
||||||
OUT total_plan_time float8,
|
OUT total_plan_time float8,
|
||||||
OUT min_plan_time float8,
|
OUT min_plan_time float8,
|
||||||
|
@ -64,6 +63,7 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT temp_blks_written int8,
|
OUT temp_blks_written int8,
|
||||||
OUT blk_read_time float8,
|
OUT blk_read_time float8,
|
||||||
OUT blk_write_time float8,
|
OUT blk_write_time float8,
|
||||||
|
|
||||||
OUT temp_blk_read_time float8,
|
OUT temp_blk_read_time float8,
|
||||||
OUT temp_blk_write_time float8,
|
OUT temp_blk_write_time float8,
|
||||||
|
|
||||||
|
@ -98,12 +98,13 @@ BEGIN
|
||||||
CREATE VIEW pg_stat_monitor AS SELECT
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
bucket,
|
bucket,
|
||||||
bucket_start_time AS bucket_start_time,
|
bucket_start_time AS bucket_start_time,
|
||||||
userid::regrole,
|
userid,
|
||||||
|
userid::regrole AS user,
|
||||||
|
dbid,
|
||||||
datname,
|
datname,
|
||||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
pgsm_query_id,
|
pgsm_query_id,
|
||||||
queryid,
|
queryid,
|
||||||
toplevel,
|
|
||||||
top_queryid,
|
top_queryid,
|
||||||
query,
|
query,
|
||||||
comments,
|
comments,
|
||||||
|
@ -118,12 +119,12 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
sqlcode,
|
sqlcode,
|
||||||
message,
|
message,
|
||||||
calls,
|
calls,
|
||||||
total_exec_time,
|
total_exec_time AS total_time,
|
||||||
min_exec_time,
|
min_exec_time AS min_time,
|
||||||
max_exec_time,
|
max_exec_time AS max_time,
|
||||||
mean_exec_time,
|
mean_exec_time AS mean_time,
|
||||||
stddev_exec_time,
|
stddev_exec_time AS stddev_time,
|
||||||
rows_retrieved,
|
rows,
|
||||||
shared_blks_hit,
|
shared_blks_hit,
|
||||||
shared_blks_read,
|
shared_blks_read,
|
||||||
shared_blks_dirtied,
|
shared_blks_dirtied,
|
||||||
|
@ -153,7 +154,9 @@ BEGIN
|
||||||
CREATE VIEW pg_stat_monitor AS SELECT
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
bucket,
|
bucket,
|
||||||
bucket_start_time AS bucket_start_time,
|
bucket_start_time AS bucket_start_time,
|
||||||
userid::regrole,
|
userid,
|
||||||
|
userid::regrole AS user,
|
||||||
|
dbid,
|
||||||
datname,
|
datname,
|
||||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
pgsm_query_id,
|
pgsm_query_id,
|
||||||
|
@ -178,7 +181,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
max_exec_time,
|
max_exec_time,
|
||||||
mean_exec_time,
|
mean_exec_time,
|
||||||
stddev_exec_time,
|
stddev_exec_time,
|
||||||
rows_retrieved,
|
rows,
|
||||||
shared_blks_hit,
|
shared_blks_hit,
|
||||||
shared_blks_read,
|
shared_blks_read,
|
||||||
shared_blks_dirtied,
|
shared_blks_dirtied,
|
||||||
|
@ -197,7 +200,9 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_records,
|
wal_records,
|
||||||
wal_fpi,
|
wal_fpi,
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
plans_calls,
|
bucket_done,
|
||||||
|
-- PostgreSQL-13 Specific Coulumns
|
||||||
|
plans,
|
||||||
total_plan_time,
|
total_plan_time,
|
||||||
min_plan_time,
|
min_plan_time,
|
||||||
max_plan_time,
|
max_plan_time,
|
||||||
|
@ -215,7 +220,9 @@ BEGIN
|
||||||
CREATE VIEW pg_stat_monitor AS SELECT
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
bucket,
|
bucket,
|
||||||
bucket_start_time AS bucket_start_time,
|
bucket_start_time AS bucket_start_time,
|
||||||
userid::regrole,
|
userid,
|
||||||
|
userid::regrole AS user,
|
||||||
|
dbid,
|
||||||
datname,
|
datname,
|
||||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
pgsm_query_id,
|
pgsm_query_id,
|
||||||
|
@ -240,7 +247,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
max_exec_time,
|
max_exec_time,
|
||||||
mean_exec_time,
|
mean_exec_time,
|
||||||
stddev_exec_time,
|
stddev_exec_time,
|
||||||
rows_retrieved,
|
rows,
|
||||||
shared_blks_hit,
|
shared_blks_hit,
|
||||||
shared_blks_read,
|
shared_blks_read,
|
||||||
shared_blks_dirtied,
|
shared_blks_dirtied,
|
||||||
|
@ -261,7 +268,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
bucket_done,
|
bucket_done,
|
||||||
|
|
||||||
plans_calls,
|
plans,
|
||||||
total_plan_time,
|
total_plan_time,
|
||||||
min_plan_time,
|
min_plan_time,
|
||||||
max_plan_time,
|
max_plan_time,
|
||||||
|
@ -279,9 +286,12 @@ BEGIN
|
||||||
CREATE VIEW pg_stat_monitor AS SELECT
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
bucket,
|
bucket,
|
||||||
bucket_start_time AS bucket_start_time,
|
bucket_start_time AS bucket_start_time,
|
||||||
userid::regrole,
|
userid,
|
||||||
|
userid::regrole AS user,
|
||||||
|
dbid,
|
||||||
datname,
|
datname,
|
||||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
|
pgsm_query_id,
|
||||||
queryid,
|
queryid,
|
||||||
toplevel,
|
toplevel,
|
||||||
top_queryid,
|
top_queryid,
|
||||||
|
@ -303,7 +313,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
max_exec_time,
|
max_exec_time,
|
||||||
mean_exec_time,
|
mean_exec_time,
|
||||||
stddev_exec_time,
|
stddev_exec_time,
|
||||||
rows_retrieved,
|
rows,
|
||||||
shared_blks_hit,
|
shared_blks_hit,
|
||||||
shared_blks_read,
|
shared_blks_read,
|
||||||
shared_blks_dirtied,
|
shared_blks_dirtied,
|
||||||
|
@ -327,7 +337,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
bucket_done,
|
bucket_done,
|
||||||
|
|
||||||
plans_calls,
|
plans,
|
||||||
total_plan_time,
|
total_plan_time,
|
||||||
min_plan_time,
|
min_plan_time,
|
||||||
max_plan_time,
|
max_plan_time,
|
||||||
|
@ -371,7 +381,6 @@ $$
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
SELECT pgsm_create_view();
|
SELECT pgsm_create_view();
|
||||||
|
|
||||||
REVOKE ALL ON FUNCTION range FROM PUBLIC;
|
REVOKE ALL ON FUNCTION range FROM PUBLIC;
|
||||||
REVOKE ALL ON FUNCTION get_cmd_type FROM PUBLIC;
|
REVOKE ALL ON FUNCTION get_cmd_type FROM PUBLIC;
|
||||||
REVOKE ALL ON FUNCTION decode_error_level FROM PUBLIC;
|
REVOKE ALL ON FUNCTION decode_error_level FROM PUBLIC;
|
||||||
|
@ -384,4 +393,3 @@ REVOKE ALL ON FUNCTION pgsm_create_14_view FROM PUBLIC;
|
||||||
REVOKE ALL ON FUNCTION pgsm_create_15_view FROM PUBLIC;
|
REVOKE ALL ON FUNCTION pgsm_create_15_view FROM PUBLIC;
|
||||||
|
|
||||||
GRANT SELECT ON pg_stat_monitor TO PUBLIC;
|
GRANT SELECT ON pg_stat_monitor TO PUBLIC;
|
||||||
|
|
||||||
|
|
|
@ -87,12 +87,12 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT dbid oid,
|
OUT dbid oid,
|
||||||
OUT client_ip int8,
|
OUT client_ip int8,
|
||||||
|
|
||||||
OUT queryid text, -- 4
|
OUT queryid int8, -- 4
|
||||||
OUT planid text,
|
OUT planid int8,
|
||||||
OUT query text,
|
OUT query text,
|
||||||
OUT query_plan text,
|
OUT query_plan text,
|
||||||
OUT pgsm_query_id int8,
|
OUT pgsm_query_id int8,
|
||||||
OUT top_queryid text,
|
OUT top_queryid int8,
|
||||||
OUT top_query text,
|
OUT top_query text,
|
||||||
OUT application_name text,
|
OUT application_name text,
|
||||||
|
|
||||||
|
@ -111,9 +111,9 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT mean_exec_time float8,
|
OUT mean_exec_time float8,
|
||||||
OUT stddev_exec_time float8,
|
OUT stddev_exec_time float8,
|
||||||
|
|
||||||
OUT rows_retrieved int8,
|
OUT rows int8,
|
||||||
|
|
||||||
OUT plans_calls int8, -- 23
|
OUT plans int8, -- 23
|
||||||
|
|
||||||
OUT total_plan_time float8,
|
OUT total_plan_time float8,
|
||||||
OUT min_plan_time float8,
|
OUT min_plan_time float8,
|
||||||
|
@ -168,7 +168,9 @@ BEGIN
|
||||||
CREATE VIEW pg_stat_monitor AS SELECT
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
bucket,
|
bucket,
|
||||||
bucket_start_time AS bucket_start_time,
|
bucket_start_time AS bucket_start_time,
|
||||||
userid::regrole,
|
userid,
|
||||||
|
userid::regrole AS user,
|
||||||
|
dbid,
|
||||||
datname,
|
datname,
|
||||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
pgsm_query_id,
|
pgsm_query_id,
|
||||||
|
@ -192,7 +194,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
max_exec_time AS max_time,
|
max_exec_time AS max_time,
|
||||||
mean_exec_time AS mean_time,
|
mean_exec_time AS mean_time,
|
||||||
stddev_exec_time AS stddev_time,
|
stddev_exec_time AS stddev_time,
|
||||||
rows_retrieved,
|
rows,
|
||||||
shared_blks_hit,
|
shared_blks_hit,
|
||||||
shared_blks_read,
|
shared_blks_read,
|
||||||
shared_blks_dirtied,
|
shared_blks_dirtied,
|
||||||
|
@ -222,7 +224,9 @@ BEGIN
|
||||||
CREATE VIEW pg_stat_monitor AS SELECT
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
bucket,
|
bucket,
|
||||||
bucket_start_time AS bucket_start_time,
|
bucket_start_time AS bucket_start_time,
|
||||||
userid::regrole,
|
userid,
|
||||||
|
userid::regrole AS user,
|
||||||
|
dbid,
|
||||||
datname,
|
datname,
|
||||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
pgsm_query_id,
|
pgsm_query_id,
|
||||||
|
@ -247,7 +251,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
max_exec_time,
|
max_exec_time,
|
||||||
mean_exec_time,
|
mean_exec_time,
|
||||||
stddev_exec_time,
|
stddev_exec_time,
|
||||||
rows_retrieved,
|
rows,
|
||||||
shared_blks_hit,
|
shared_blks_hit,
|
||||||
shared_blks_read,
|
shared_blks_read,
|
||||||
shared_blks_dirtied,
|
shared_blks_dirtied,
|
||||||
|
@ -268,7 +272,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
bucket_done,
|
bucket_done,
|
||||||
-- PostgreSQL-13 Specific Coulumns
|
-- PostgreSQL-13 Specific Coulumns
|
||||||
plans_calls,
|
plans,
|
||||||
total_plan_time,
|
total_plan_time,
|
||||||
min_plan_time,
|
min_plan_time,
|
||||||
max_plan_time,
|
max_plan_time,
|
||||||
|
@ -286,7 +290,9 @@ BEGIN
|
||||||
CREATE VIEW pg_stat_monitor AS SELECT
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
bucket,
|
bucket,
|
||||||
bucket_start_time AS bucket_start_time,
|
bucket_start_time AS bucket_start_time,
|
||||||
userid::regrole,
|
userid,
|
||||||
|
userid::regrole AS user,
|
||||||
|
dbid,
|
||||||
datname,
|
datname,
|
||||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
pgsm_query_id,
|
pgsm_query_id,
|
||||||
|
@ -311,7 +317,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
max_exec_time,
|
max_exec_time,
|
||||||
mean_exec_time,
|
mean_exec_time,
|
||||||
stddev_exec_time,
|
stddev_exec_time,
|
||||||
rows_retrieved,
|
rows,
|
||||||
shared_blks_hit,
|
shared_blks_hit,
|
||||||
shared_blks_read,
|
shared_blks_read,
|
||||||
shared_blks_dirtied,
|
shared_blks_dirtied,
|
||||||
|
@ -332,7 +338,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
bucket_done,
|
bucket_done,
|
||||||
|
|
||||||
plans_calls,
|
plans,
|
||||||
total_plan_time,
|
total_plan_time,
|
||||||
min_plan_time,
|
min_plan_time,
|
||||||
max_plan_time,
|
max_plan_time,
|
||||||
|
@ -350,7 +356,9 @@ BEGIN
|
||||||
CREATE VIEW pg_stat_monitor AS SELECT
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
bucket,
|
bucket,
|
||||||
bucket_start_time AS bucket_start_time,
|
bucket_start_time AS bucket_start_time,
|
||||||
userid::regrole,
|
userid,
|
||||||
|
userid::regrole AS user,
|
||||||
|
dbid,
|
||||||
datname,
|
datname,
|
||||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
pgsm_query_id,
|
pgsm_query_id,
|
||||||
|
@ -375,7 +383,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
max_exec_time,
|
max_exec_time,
|
||||||
mean_exec_time,
|
mean_exec_time,
|
||||||
stddev_exec_time,
|
stddev_exec_time,
|
||||||
rows_retrieved,
|
rows,
|
||||||
shared_blks_hit,
|
shared_blks_hit,
|
||||||
shared_blks_read,
|
shared_blks_read,
|
||||||
shared_blks_dirtied,
|
shared_blks_dirtied,
|
||||||
|
@ -399,7 +407,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
bucket_done,
|
bucket_done,
|
||||||
|
|
||||||
plans_calls,
|
plans,
|
||||||
total_plan_time,
|
total_plan_time,
|
||||||
min_plan_time,
|
min_plan_time,
|
||||||
max_plan_time,
|
max_plan_time,
|
||||||
|
|
|
@ -1722,7 +1722,6 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
MemoryContext oldcontext;
|
MemoryContext oldcontext;
|
||||||
PGSM_HASH_SEQ_STATUS hstat;
|
PGSM_HASH_SEQ_STATUS hstat;
|
||||||
pgssEntry *entry;
|
pgssEntry *entry;
|
||||||
char parentid_txt[32];
|
|
||||||
pgssSharedState *pgss;
|
pgssSharedState *pgss;
|
||||||
char *query_txt = NULL;
|
char *query_txt = NULL;
|
||||||
char *parent_query_txt = NULL;
|
char *parent_query_txt = NULL;
|
||||||
|
@ -1776,8 +1775,6 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Counters tmp;
|
Counters tmp;
|
||||||
double stddev;
|
double stddev;
|
||||||
char queryid_text[32] = {0};
|
|
||||||
char planid_text[32] = {0};
|
|
||||||
uint64 queryid = entry->key.queryid;
|
uint64 queryid = entry->key.queryid;
|
||||||
int64 bucketid = entry->key.bucket_id;
|
int64 bucketid = entry->key.bucket_id;
|
||||||
uint64 dbid = entry->key.dbid;
|
uint64 dbid = entry->key.dbid;
|
||||||
|
@ -1861,14 +1858,12 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
|
|
||||||
/* queryid at column number 4 */
|
/* queryid at column number 4 */
|
||||||
snprintf(queryid_text, 32, "%08lX", queryid);
|
values[i++] = UInt64GetDatum(queryid);
|
||||||
values[i++] = CStringGetTextDatum(queryid_text);
|
|
||||||
|
|
||||||
/* planid at column number 5 */
|
/* planid at column number 5 */
|
||||||
if (planid)
|
if (planid)
|
||||||
{
|
{
|
||||||
snprintf(planid_text, 32, "%08lX", planid);
|
values[i++] = UInt64GetDatum(planid);
|
||||||
values[i++] = CStringGetTextDatum(planid_text);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1906,7 +1901,7 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
values[i++] = CStringGetTextDatum("<insufficient privilege>");
|
values[i++] = CStringGetTextDatum("<insufficient privilege>");
|
||||||
}
|
}
|
||||||
|
|
||||||
values[i++] = Int64GetDatumFast(pgsm_query_id);
|
values[i++] = UInt64GetDatum(pgsm_query_id);
|
||||||
|
|
||||||
/* state at column number 8 for V1.0 API*/
|
/* state at column number 8 for V1.0 API*/
|
||||||
if (api_version <= PGSM_V1_0)
|
if (api_version <= PGSM_V1_0)
|
||||||
|
@ -1915,8 +1910,7 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
/* parentid at column number 9 */
|
/* parentid at column number 9 */
|
||||||
if (tmp.info.parentid != UINT64CONST(0))
|
if (tmp.info.parentid != UINT64CONST(0))
|
||||||
{
|
{
|
||||||
snprintf(parentid_txt, 32, "%08lX", tmp.info.parentid);
|
values[i++] = UInt64GetDatum(tmp.info.parentid);
|
||||||
values[i++] = CStringGetTextDatum(parentid_txt);
|
|
||||||
values[i++] = CStringGetTextDatum(parent_query_txt);
|
values[i++] = CStringGetTextDatum(parent_query_txt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -8540,9 +8540,9 @@ SELECt * FROM t2 WHERE b % 2 = 0;
|
||||||
5000
|
5000
|
||||||
(2500 rows)
|
(2500 rows)
|
||||||
|
|
||||||
SELECT query, rows_retrieved FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
SELECT query, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
query | rows_retrieved
|
query | rows
|
||||||
-----------------------------------+----------------
|
-----------------------------------+------
|
||||||
SELECT * FROM t1 | 1000
|
SELECT * FROM t1 | 1000
|
||||||
SELECT * FROM t1 LIMIT 10 | 10
|
SELECT * FROM t1 LIMIT 10 | 10
|
||||||
SELECT * FROM t2 | 5000
|
SELECT * FROM t2 | 5000
|
||||||
|
|
|
@ -12,7 +12,7 @@ SELECT * FROM t2;
|
||||||
SELECT * FROM t1 LIMIT 10;
|
SELECT * FROM t1 LIMIT 10;
|
||||||
SELECt * FROM t2 WHERE b % 2 = 0;
|
SELECt * FROM t2 WHERE b % 2 = 0;
|
||||||
|
|
||||||
SELECT query, rows_retrieved FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
SELECT query, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
|
@ -63,7 +63,7 @@ PGSM::append_to_file($stdout);
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT planid FROM pg_stat_monitor WHERE calls = 2;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT planid FROM pg_stat_monitor WHERE calls = 2;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
isnt($stdout,'',"Test: planid should not be empty");
|
isnt($stdout,'',"Test: planid should not be empty");
|
||||||
ok(length($stdout) == 16, 'Length of planid is 16');
|
ok(length($stdout) > 0, 'Length of planid is > 0');
|
||||||
|
|
||||||
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_enable_query_plan = 'no'\n");
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_enable_query_plan = 'no'\n");
|
||||||
$node->restart();
|
$node->restart();
|
||||||
|
|
|
@ -26,48 +26,48 @@ close $conf;
|
||||||
my %pg_versions_pgsm_columns = ( 15 => "application_name,blk_read_time," .
|
my %pg_versions_pgsm_columns = ( 15 => "application_name,blk_read_time," .
|
||||||
"blk_write_time,bucket,bucket_done,bucket_start_time,calls," .
|
"blk_write_time,bucket,bucket_done,bucket_start_time,calls," .
|
||||||
"client_ip,cmd_type,cmd_type_text,comments,cpu_sys_time,cpu_user_time," .
|
"client_ip,cmd_type,cmd_type_text,comments,cpu_sys_time,cpu_user_time," .
|
||||||
"datname,elevel,jit_emission_count,jit_emission_time,jit_functions," .
|
"datname,dbid,elevel,jit_emission_count,jit_emission_time,jit_functions," .
|
||||||
"jit_generation_time,jit_inlining_count,jit_inlining_time," .
|
"jit_generation_time,jit_inlining_count,jit_inlining_time," .
|
||||||
"jit_optimization_count,jit_optimization_time," .
|
"jit_optimization_count,jit_optimization_time," .
|
||||||
"local_blks_dirtied,local_blks_hit,local_blks_read," .
|
"local_blks_dirtied,local_blks_hit,local_blks_read," .
|
||||||
"local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
|
"local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
|
||||||
"mean_plan_time,message,min_exec_time,min_plan_time,pgsm_query_id,planid," .
|
"mean_plan_time,message,min_exec_time,min_plan_time,pgsm_query_id,planid," .
|
||||||
"plans_calls,query,query_plan,queryid,relations,resp_calls," .
|
"plans,query,query_plan,queryid,relations,resp_calls," .
|
||||||
"rows_retrieved,shared_blks_dirtied,shared_blks_hit,shared_blks_read," .
|
"rows,shared_blks_dirtied,shared_blks_hit,shared_blks_read," .
|
||||||
"shared_blks_written,sqlcode,stddev_exec_time,stddev_plan_time," .
|
"shared_blks_written,sqlcode,stddev_exec_time,stddev_plan_time," .
|
||||||
"temp_blk_read_time,temp_blk_write_time,temp_blks_read,temp_blks_written," .
|
"temp_blk_read_time,temp_blk_write_time,temp_blks_read,temp_blks_written," .
|
||||||
"top_query,top_queryid,toplevel,total_exec_time,total_plan_time," .
|
"top_query,top_queryid,toplevel,total_exec_time,total_plan_time," .
|
||||||
"userid,wal_bytes,wal_fpi,wal_records",
|
"user,userid,wal_bytes,wal_fpi,wal_records",
|
||||||
14 => "application_name,blk_read_time," .
|
14 => "application_name,blk_read_time," .
|
||||||
"blk_write_time,bucket,bucket_done,bucket_start_time,calls," .
|
"blk_write_time,bucket,bucket_done,bucket_start_time,calls," .
|
||||||
"client_ip,cmd_type,cmd_type_text,comments,cpu_sys_time,cpu_user_time," .
|
"client_ip,cmd_type,cmd_type_text,comments,cpu_sys_time,cpu_user_time," .
|
||||||
"datname,elevel,local_blks_dirtied,local_blks_hit,local_blks_read," .
|
"datname,dbid,elevel,local_blks_dirtied,local_blks_hit,local_blks_read," .
|
||||||
"local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
|
"local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
|
||||||
"mean_plan_time,message,min_exec_time,min_plan_time,pgsm_query_id,planid," .
|
"mean_plan_time,message,min_exec_time,min_plan_time,pgsm_query_id,planid," .
|
||||||
"plans_calls,query,query_plan,queryid,relations,resp_calls," .
|
"plans,query,query_plan,queryid,relations,resp_calls," .
|
||||||
"rows_retrieved,shared_blks_dirtied,shared_blks_hit,shared_blks_read," .
|
"rows,shared_blks_dirtied,shared_blks_hit,shared_blks_read," .
|
||||||
"shared_blks_written,sqlcode,stddev_exec_time,stddev_plan_time," .
|
"shared_blks_written,sqlcode,stddev_exec_time,stddev_plan_time," .
|
||||||
"temp_blks_read,temp_blks_written,top_query,top_queryid,toplevel," .
|
"temp_blks_read,temp_blks_written,top_query,top_queryid,toplevel," .
|
||||||
"total_exec_time,total_plan_time,userid,wal_bytes,wal_fpi,wal_records",
|
"total_exec_time,total_plan_time,user,userid,wal_bytes,wal_fpi,wal_records",
|
||||||
13 => "application_name,blk_read_time," .
|
13 => "application_name,blk_read_time," .
|
||||||
"blk_write_time,bucket,bucket_done,bucket_start_time,calls," .
|
"blk_write_time,bucket,bucket_done,bucket_start_time,calls," .
|
||||||
"client_ip,cmd_type,cmd_type_text,comments,cpu_sys_time,cpu_user_time," .
|
"client_ip,cmd_type,cmd_type_text,comments,cpu_sys_time,cpu_user_time," .
|
||||||
"datname,elevel,local_blks_dirtied,local_blks_hit,local_blks_read," .
|
"datname,dbid,elevel,local_blks_dirtied,local_blks_hit,local_blks_read," .
|
||||||
"local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
|
"local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
|
||||||
"mean_plan_time,message,min_exec_time,min_plan_time,pgsm_query_id,planid," .
|
"mean_plan_time,message,min_exec_time,min_plan_time,pgsm_query_id,planid," .
|
||||||
"plans_calls,query,query_plan,queryid,relations,resp_calls," .
|
"plans,query,query_plan,queryid,relations,resp_calls," .
|
||||||
"rows_retrieved,shared_blks_dirtied,shared_blks_hit,shared_blks_read," .
|
"rows,shared_blks_dirtied,shared_blks_hit,shared_blks_read," .
|
||||||
"shared_blks_written,sqlcode,stddev_exec_time,stddev_plan_time," .
|
"shared_blks_written,sqlcode,stddev_exec_time,stddev_plan_time," .
|
||||||
"temp_blks_read,temp_blks_written,top_query,top_queryid,toplevel," .
|
"temp_blks_read,temp_blks_written,top_query,top_queryid,toplevel," .
|
||||||
"total_exec_time,total_plan_time,userid,wal_bytes,wal_fpi,wal_records",
|
"total_exec_time,total_plan_time,user,userid,wal_bytes,wal_fpi,wal_records",
|
||||||
12 => "application_name,blk_read_time,blk_write_time,bucket,bucket_done," .
|
12 => "application_name,blk_read_time,blk_write_time,bucket,bucket_done," .
|
||||||
"bucket_start_time,calls,client_ip,cmd_type,cmd_type_text,comments," .
|
"bucket_start_time,calls,client_ip,cmd_type,cmd_type_text,comments," .
|
||||||
"cpu_sys_time,cpu_user_time,datname,elevel,local_blks_dirtied," .
|
"cpu_sys_time,cpu_user_time,datname,dbid,elevel,local_blks_dirtied," .
|
||||||
"local_blks_hit,local_blks_read,local_blks_written,max_time,mean_time," .
|
"local_blks_hit,local_blks_read,local_blks_written,max_time,mean_time," .
|
||||||
"message,min_time,pgsm_query_id,planid,query,query_plan,queryid,relations,resp_calls," .
|
"message,min_time,pgsm_query_id,planid,query,query_plan,queryid,relations,resp_calls," .
|
||||||
"rows_retrieved,shared_blks_dirtied,shared_blks_hit,shared_blks_read," .
|
"rows,shared_blks_dirtied,shared_blks_hit,shared_blks_read," .
|
||||||
"shared_blks_written,sqlcode,stddev_time,temp_blks_read,temp_blks_written," .
|
"shared_blks_written,sqlcode,stddev_time,temp_blks_read,temp_blks_written," .
|
||||||
"top_query,top_queryid,total_time,userid"
|
"top_query,top_queryid,total_time,user,userid"
|
||||||
);
|
);
|
||||||
|
|
||||||
# Start server
|
# Start server
|
||||||
|
|
Loading…
Reference in New Issue