Rename I/O timing statistics columns to shared_blk_{read|write}_time
parent
3c68a6043c
commit
9d8b072421
2
Makefile
2
Makefile
|
@ -4,7 +4,7 @@ MODULE_big = pg_stat_monitor
|
||||||
OBJS = hash_query.o guc.o pg_stat_monitor.o $(WIN32RES)
|
OBJS = hash_query.o guc.o pg_stat_monitor.o $(WIN32RES)
|
||||||
|
|
||||||
EXTENSION = pg_stat_monitor
|
EXTENSION = pg_stat_monitor
|
||||||
DATA = pg_stat_monitor--2.0.sql pg_stat_monitor--1.0--2.0.sql
|
DATA = pg_stat_monitor--2.0.sql pg_stat_monitor--1.0--2.0.sql pg_stat_monitor--2.0--2.1.sql
|
||||||
|
|
||||||
PGFILEDESC = "pg_stat_monitor - execution statistics of SQL statements"
|
PGFILEDESC = "pg_stat_monitor - execution statistics of SQL statements"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,212 @@
|
||||||
|
/* contrib/pg_stat_monitor/pg_stat_monitor--1.0--2.0.sql */
|
||||||
|
|
||||||
|
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION pg_stat_monitor" to load this file. \quit
|
||||||
|
|
||||||
|
DROP FUNCTION pg_stat_monitor_internal CASCADE;
|
||||||
|
DROP FUNCTION pgsm_create_view CASCADE;
|
||||||
|
|
||||||
|
CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
|
IN showtext boolean,
|
||||||
|
OUT bucket int8, -- 0
|
||||||
|
OUT userid oid,
|
||||||
|
OUT username text,
|
||||||
|
OUT dbid oid,
|
||||||
|
OUT datname text,
|
||||||
|
OUT client_ip int8,
|
||||||
|
|
||||||
|
OUT queryid int8, -- 4
|
||||||
|
OUT planid int8,
|
||||||
|
OUT query text,
|
||||||
|
OUT query_plan text,
|
||||||
|
OUT pgsm_query_id int8,
|
||||||
|
OUT top_queryid int8,
|
||||||
|
OUT top_query text,
|
||||||
|
OUT application_name text,
|
||||||
|
|
||||||
|
OUT relations text, -- 11
|
||||||
|
OUT cmd_type int,
|
||||||
|
OUT elevel int,
|
||||||
|
OUT sqlcode TEXT,
|
||||||
|
OUT message text,
|
||||||
|
OUT bucket_start_time timestamptz,
|
||||||
|
|
||||||
|
OUT calls int8, -- 16
|
||||||
|
|
||||||
|
OUT total_exec_time float8,
|
||||||
|
OUT min_exec_time float8,
|
||||||
|
OUT max_exec_time float8,
|
||||||
|
OUT mean_exec_time float8,
|
||||||
|
OUT stddev_exec_time float8,
|
||||||
|
|
||||||
|
OUT rows int8,
|
||||||
|
|
||||||
|
OUT plans int8, -- 23
|
||||||
|
|
||||||
|
OUT total_plan_time float8,
|
||||||
|
OUT min_plan_time float8,
|
||||||
|
OUT max_plan_time float8,
|
||||||
|
OUT mean_plan_time float8,
|
||||||
|
OUT stddev_plan_time float8,
|
||||||
|
|
||||||
|
OUT shared_blks_hit int8, -- 29
|
||||||
|
OUT shared_blks_read int8,
|
||||||
|
OUT shared_blks_dirtied int8,
|
||||||
|
OUT shared_blks_written int8,
|
||||||
|
OUT local_blks_hit int8,
|
||||||
|
OUT local_blks_read int8,
|
||||||
|
OUT local_blks_dirtied int8,
|
||||||
|
OUT local_blks_written int8,
|
||||||
|
OUT temp_blks_read int8,
|
||||||
|
OUT temp_blks_written int8,
|
||||||
|
OUT shared_blk_read_time float8,
|
||||||
|
OUT shared_blk_write_time float8,
|
||||||
|
|
||||||
|
OUT temp_blk_read_time float8,
|
||||||
|
OUT temp_blk_write_time float8,
|
||||||
|
|
||||||
|
OUT resp_calls text, -- 41
|
||||||
|
OUT cpu_user_time float8,
|
||||||
|
OUT cpu_sys_time float8,
|
||||||
|
OUT wal_records int8,
|
||||||
|
OUT wal_fpi int8,
|
||||||
|
OUT wal_bytes numeric,
|
||||||
|
OUT comments TEXT,
|
||||||
|
|
||||||
|
OUT jit_functions int8,
|
||||||
|
OUT jit_generation_time float8,
|
||||||
|
OUT jit_inlining_count int8,
|
||||||
|
OUT jit_inlining_time float8,
|
||||||
|
OUT jit_optimization_count int8,
|
||||||
|
OUT jit_optimization_time float8,
|
||||||
|
OUT jit_emission_count int8,
|
||||||
|
OUT jit_emission_time float8,
|
||||||
|
|
||||||
|
OUT toplevel BOOLEAN,
|
||||||
|
OUT bucket_done BOOLEAN
|
||||||
|
)
|
||||||
|
RETURNS SETOF record
|
||||||
|
AS 'MODULE_PATHNAME', 'pg_stat_monitor_2_1'
|
||||||
|
LANGUAGE C STRICT VOLATILE PARALLEL SAFE;
|
||||||
|
|
||||||
|
CREATE FUNCTION pgsm_create_17_view() RETURNS INT AS
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
|
bucket,
|
||||||
|
bucket_start_time AS bucket_start_time,
|
||||||
|
userid,
|
||||||
|
username,
|
||||||
|
dbid,
|
||||||
|
datname,
|
||||||
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
|
pgsm_query_id,
|
||||||
|
queryid,
|
||||||
|
toplevel,
|
||||||
|
top_queryid,
|
||||||
|
query,
|
||||||
|
comments,
|
||||||
|
planid,
|
||||||
|
query_plan,
|
||||||
|
top_query,
|
||||||
|
application_name,
|
||||||
|
string_to_array(relations, ',') AS relations,
|
||||||
|
cmd_type,
|
||||||
|
get_cmd_type(cmd_type) AS cmd_type_text,
|
||||||
|
elevel,
|
||||||
|
sqlcode,
|
||||||
|
message,
|
||||||
|
calls,
|
||||||
|
total_exec_time,
|
||||||
|
min_exec_time,
|
||||||
|
max_exec_time,
|
||||||
|
mean_exec_time,
|
||||||
|
stddev_exec_time,
|
||||||
|
rows,
|
||||||
|
shared_blks_hit,
|
||||||
|
shared_blks_read,
|
||||||
|
shared_blks_dirtied,
|
||||||
|
shared_blks_written,
|
||||||
|
local_blks_hit,
|
||||||
|
local_blks_read,
|
||||||
|
local_blks_dirtied,
|
||||||
|
local_blks_written,
|
||||||
|
temp_blks_read,
|
||||||
|
temp_blks_written,
|
||||||
|
shared_blk_read_time,
|
||||||
|
shared_blk_write_time,
|
||||||
|
temp_blk_read_time,
|
||||||
|
temp_blk_write_time,
|
||||||
|
|
||||||
|
(string_to_array(resp_calls, ',')) resp_calls,
|
||||||
|
cpu_user_time,
|
||||||
|
cpu_sys_time,
|
||||||
|
wal_records,
|
||||||
|
wal_fpi,
|
||||||
|
wal_bytes,
|
||||||
|
bucket_done,
|
||||||
|
|
||||||
|
plans,
|
||||||
|
total_plan_time,
|
||||||
|
min_plan_time,
|
||||||
|
max_plan_time,
|
||||||
|
mean_plan_time,
|
||||||
|
stddev_plan_time,
|
||||||
|
|
||||||
|
jit_functions,
|
||||||
|
jit_generation_time,
|
||||||
|
jit_inlining_count,
|
||||||
|
jit_inlining_time,
|
||||||
|
jit_optimization_count,
|
||||||
|
jit_optimization_time,
|
||||||
|
jit_emission_count,
|
||||||
|
jit_emission_time
|
||||||
|
|
||||||
|
FROM pg_stat_monitor_internal(TRUE)
|
||||||
|
ORDER BY bucket_start_time;
|
||||||
|
RETURN 0;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
CREATE FUNCTION pgsm_create_view() RETURNS INT AS
|
||||||
|
$$
|
||||||
|
DECLARE ver integer;
|
||||||
|
BEGIN
|
||||||
|
SELECT current_setting('server_version_num') INTO ver;
|
||||||
|
IF (ver >= 170000) THEN
|
||||||
|
return pgsm_create_17_view();
|
||||||
|
END IF;
|
||||||
|
IF (ver >= 150000) THEN
|
||||||
|
return pgsm_create_15_view();
|
||||||
|
END IF;
|
||||||
|
IF (ver >= 140000) THEN
|
||||||
|
return pgsm_create_14_view();
|
||||||
|
END IF;
|
||||||
|
IF (ver >= 130000) THEN
|
||||||
|
return pgsm_create_13_view();
|
||||||
|
END IF;
|
||||||
|
IF (ver >= 110000) THEN
|
||||||
|
return pgsm_create_11_view();
|
||||||
|
END IF;
|
||||||
|
RETURN 0;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
SELECT pgsm_create_view();
|
||||||
|
REVOKE ALL ON FUNCTION pgsm_create_view FROM PUBLIC;
|
||||||
|
REVOKE ALL ON FUNCTION pgsm_create_11_view FROM PUBLIC;
|
||||||
|
REVOKE ALL ON FUNCTION pgsm_create_13_view FROM PUBLIC;
|
||||||
|
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_17_view FROM PUBLIC;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION range TO PUBLIC;
|
||||||
|
GRANT EXECUTE ON FUNCTION decode_error_level TO PUBLIC;
|
||||||
|
GRANT EXECUTE ON FUNCTION get_histogram_timings TO PUBLIC;
|
||||||
|
GRANT EXECUTE ON FUNCTION get_cmd_type TO PUBLIC;
|
||||||
|
GRANT EXECUTE ON FUNCTION pg_stat_monitor_internal TO PUBLIC;
|
||||||
|
|
||||||
|
GRANT SELECT ON pg_stat_monitor TO PUBLIC;
|
||||||
|
|
||||||
|
-- Reset is only available to super user
|
||||||
|
REVOKE ALL ON FUNCTION pg_stat_monitor_reset FROM PUBLIC;
|
|
@ -31,16 +31,18 @@
|
||||||
typedef enum pgsmVersion
|
typedef enum pgsmVersion
|
||||||
{
|
{
|
||||||
PGSM_V1_0 = 0,
|
PGSM_V1_0 = 0,
|
||||||
PGSM_V2_0
|
PGSM_V2_0,
|
||||||
|
PGSM_V2_1
|
||||||
} pgsmVersion;
|
} pgsmVersion;
|
||||||
|
|
||||||
PG_MODULE_MAGIC;
|
PG_MODULE_MAGIC;
|
||||||
|
|
||||||
#define BUILD_VERSION "2.0.4"
|
#define BUILD_VERSION "2.1.0"
|
||||||
|
|
||||||
/* Number of output arguments (columns) for various API versions */
|
/* Number of output arguments (columns) for various API versions */
|
||||||
#define PG_STAT_MONITOR_COLS_V1_0 52
|
#define PG_STAT_MONITOR_COLS_V1_0 52
|
||||||
#define PG_STAT_MONITOR_COLS_V2_0 64
|
#define PG_STAT_MONITOR_COLS_V2_0 64
|
||||||
|
#define PG_STAT_MONITOR_COLS_V2_1 64 //TODO !!!!!!!
|
||||||
#define PG_STAT_MONITOR_COLS PG_STAT_MONITOR_COLS_V2_0 /* maximum of above */
|
#define PG_STAT_MONITOR_COLS PG_STAT_MONITOR_COLS_V2_0 /* maximum of above */
|
||||||
|
|
||||||
#define PGSM_TEXT_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat_monitor_query"
|
#define PGSM_TEXT_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat_monitor_query"
|
||||||
|
@ -145,6 +147,7 @@ PG_FUNCTION_INFO_V1(pg_stat_monitor_version);
|
||||||
PG_FUNCTION_INFO_V1(pg_stat_monitor_reset);
|
PG_FUNCTION_INFO_V1(pg_stat_monitor_reset);
|
||||||
PG_FUNCTION_INFO_V1(pg_stat_monitor_1_0);
|
PG_FUNCTION_INFO_V1(pg_stat_monitor_1_0);
|
||||||
PG_FUNCTION_INFO_V1(pg_stat_monitor_2_0);
|
PG_FUNCTION_INFO_V1(pg_stat_monitor_2_0);
|
||||||
|
PG_FUNCTION_INFO_V1(pg_stat_monitor_2_1);
|
||||||
PG_FUNCTION_INFO_V1(pg_stat_monitor);
|
PG_FUNCTION_INFO_V1(pg_stat_monitor);
|
||||||
PG_FUNCTION_INFO_V1(get_histogram_timings);
|
PG_FUNCTION_INFO_V1(get_histogram_timings);
|
||||||
PG_FUNCTION_INFO_V1(pg_stat_monitor_hook_stats);
|
PG_FUNCTION_INFO_V1(pg_stat_monitor_hook_stats);
|
||||||
|
@ -1236,10 +1239,10 @@ BufferUsageAccumDiff(BufferUsage *bufusage, BufferUsage *pgBufferUsage, BufferUs
|
||||||
bufusage->local_blks_written = pgBufferUsage->local_blks_written - bufusage_start->local_blks_written;
|
bufusage->local_blks_written = pgBufferUsage->local_blks_written - bufusage_start->local_blks_written;
|
||||||
bufusage->temp_blks_read = pgBufferUsage->temp_blks_read - bufusage_start->temp_blks_read;
|
bufusage->temp_blks_read = pgBufferUsage->temp_blks_read - bufusage_start->temp_blks_read;
|
||||||
bufusage->temp_blks_written = pgBufferUsage->temp_blks_written - bufusage_start->temp_blks_written;
|
bufusage->temp_blks_written = pgBufferUsage->temp_blks_written - bufusage_start->temp_blks_written;
|
||||||
bufusage->blk_read_time = pgBufferUsage->blk_read_time;
|
bufusage->shared_blk_read_time = pgBufferUsage->shared_blk_read_time;
|
||||||
INSTR_TIME_SUBTRACT(bufusage->blk_read_time, bufusage_start->blk_read_time);
|
INSTR_TIME_SUBTRACT(bufusage->shared_blk_read_time, bufusage_start->shared_blk_read_time);
|
||||||
bufusage->blk_write_time = pgBufferUsage->blk_write_time;
|
bufusage->shared_blk_write_time = pgBufferUsage->shared_blk_write_time;
|
||||||
INSTR_TIME_SUBTRACT(bufusage->blk_write_time, bufusage_start->blk_write_time);
|
INSTR_TIME_SUBTRACT(bufusage->shared_blk_write_time, bufusage_start->shared_blk_write_time);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1520,11 +1523,11 @@ pgsm_update_entry(pgsmEntry * entry,
|
||||||
e->counters.blocks.temp_blks_written += bufusage->temp_blks_written;
|
e->counters.blocks.temp_blks_written += bufusage->temp_blks_written;
|
||||||
|
|
||||||
#if PG_VERSION_NUM < 170000
|
#if PG_VERSION_NUM < 170000
|
||||||
e->counters.blocks.blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->blk_read_time);
|
e->counters.blocks.shared_blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->shared_blk_read_time);
|
||||||
e->counters.blocks.blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->blk_write_time);
|
e->counters.blocks.shared_blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->shared_blk_write_time);
|
||||||
#else
|
#else
|
||||||
e->counters.blocks.blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->shared_blk_read_time);
|
e->counters.blocks.shared_blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->shared_blk_read_time);
|
||||||
e->counters.blocks.blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->shared_blk_write_time);
|
e->counters.blocks.shared_blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->shared_blk_write_time);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= 150000
|
#if PG_VERSION_NUM >= 150000
|
||||||
|
@ -1533,8 +1536,8 @@ pgsm_update_entry(pgsmEntry * entry,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PG_VERSION_NUM < 170000
|
#if PG_VERSION_NUM < 170000
|
||||||
memcpy((void *) &e->counters.blocks.instr_blk_read_time, &bufusage->blk_read_time, sizeof(instr_time));
|
memcpy((void *) &e->counters.blocks.instr_blk_read_time, &bufusage->shared_blk_read_time, sizeof(instr_time));
|
||||||
memcpy((void *) &e->counters.blocks.instr_blk_write_time, &bufusage->blk_write_time, sizeof(instr_time));
|
memcpy((void *) &e->counters.blocks.instr_blk_write_time, &bufusage->shared_blk_write_time, sizeof(instr_time));
|
||||||
#else
|
#else
|
||||||
memcpy((void *) &e->counters.blocks.instr_blk_read_time, &bufusage->shared_blk_read_time, sizeof(instr_time));
|
memcpy((void *) &e->counters.blocks.instr_blk_read_time, &bufusage->shared_blk_read_time, sizeof(instr_time));
|
||||||
memcpy((void *) &e->counters.blocks.instr_blk_write_time, &bufusage->shared_blk_write_time, sizeof(instr_time));
|
memcpy((void *) &e->counters.blocks.instr_blk_write_time, &bufusage->shared_blk_write_time, sizeof(instr_time));
|
||||||
|
@ -1816,8 +1819,8 @@ pgsm_store(pgsmEntry * entry)
|
||||||
bufusage.temp_blks_written = entry->counters.blocks.temp_blks_written;
|
bufusage.temp_blks_written = entry->counters.blocks.temp_blks_written;
|
||||||
|
|
||||||
#if PG_VERSION_NUM < 170000
|
#if PG_VERSION_NUM < 170000
|
||||||
memcpy(&bufusage.blk_read_time, &entry->counters.blocks.instr_blk_read_time, sizeof(instr_time));
|
memcpy(&bufusage.shared_blk_read_time, &entry->counters.blocks.instr_blk_read_time, sizeof(instr_time));
|
||||||
memcpy(&bufusage.blk_write_time, &entry->counters.blocks.instr_blk_write_time, sizeof(instr_time));
|
memcpy(&bufusage.shared_blk_write_time, &entry->counters.blocks.instr_blk_write_time, sizeof(instr_time));
|
||||||
#else
|
#else
|
||||||
memcpy(&bufusage.shared_blk_read_time, &entry->counters.blocks.instr_blk_read_time, sizeof(instr_time));
|
memcpy(&bufusage.shared_blk_read_time, &entry->counters.blocks.instr_blk_read_time, sizeof(instr_time));
|
||||||
memcpy(&bufusage.shared_blk_write_time, &entry->counters.blocks.instr_blk_write_time, sizeof(instr_time));
|
memcpy(&bufusage.shared_blk_write_time, &entry->counters.blocks.instr_blk_write_time, sizeof(instr_time));
|
||||||
|
@ -1997,6 +2000,13 @@ pg_stat_monitor_2_0(PG_FUNCTION_ARGS)
|
||||||
return (Datum) 0;
|
return (Datum) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Datum
|
||||||
|
pg_stat_monitor_2_1(PG_FUNCTION_ARGS)
|
||||||
|
{
|
||||||
|
pg_stat_monitor_internal(fcinfo, PGSM_V2_1, true);
|
||||||
|
return (Datum) 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Legacy entry point for pg_stat_monitor() API versions 1.0
|
* Legacy entry point for pg_stat_monitor() API versions 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -2036,7 +2046,22 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
PGSM_HASH_SEQ_STATUS hstat;
|
PGSM_HASH_SEQ_STATUS hstat;
|
||||||
pgsmEntry *entry;
|
pgsmEntry *entry;
|
||||||
pgsmSharedState *pgsm;
|
pgsmSharedState *pgsm;
|
||||||
int expected_columns = (api_version >= PGSM_V2_0) ? PG_STAT_MONITOR_COLS_V2_0 : PG_STAT_MONITOR_COLS_V1_0;
|
|
||||||
|
int expected_columns;
|
||||||
|
switch (api_version) {
|
||||||
|
case PGSM_V1_0:
|
||||||
|
expected_columns = PG_STAT_MONITOR_COLS_V1_0;
|
||||||
|
break;
|
||||||
|
case PGSM_V2_0:
|
||||||
|
expected_columns = PG_STAT_MONITOR_COLS_V2_0;
|
||||||
|
break;
|
||||||
|
case PGSM_V2_1:
|
||||||
|
expected_columns = PG_STAT_MONITOR_COLS_V2_1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// TODO error?
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Disallow old api usage */
|
/* Disallow old api usage */
|
||||||
if (api_version < PGSM_V2_0)
|
if (api_version < PGSM_V2_0)
|
||||||
|
@ -2376,8 +2401,8 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
values[i++] = Int64GetDatumFast(tmp.blocks.local_blks_written);
|
values[i++] = Int64GetDatumFast(tmp.blocks.local_blks_written);
|
||||||
values[i++] = Int64GetDatumFast(tmp.blocks.temp_blks_read);
|
values[i++] = Int64GetDatumFast(tmp.blocks.temp_blks_read);
|
||||||
values[i++] = Int64GetDatumFast(tmp.blocks.temp_blks_written);
|
values[i++] = Int64GetDatumFast(tmp.blocks.temp_blks_written);
|
||||||
values[i++] = Float8GetDatumFast(tmp.blocks.blk_read_time);
|
values[i++] = Float8GetDatumFast(tmp.blocks.shared_blk_read_time);
|
||||||
values[i++] = Float8GetDatumFast(tmp.blocks.blk_write_time);
|
values[i++] = Float8GetDatumFast(tmp.blocks.shared_blk_write_time);
|
||||||
values[i++] = Float8GetDatumFast(tmp.blocks.temp_blk_read_time);
|
values[i++] = Float8GetDatumFast(tmp.blocks.temp_blk_read_time);
|
||||||
values[i++] = Float8GetDatumFast(tmp.blocks.temp_blk_write_time);
|
values[i++] = Float8GetDatumFast(tmp.blocks.temp_blk_write_time);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# pg_stat_monitor extension
|
# pg_stat_monitor extension
|
||||||
comment = 'The pg_stat_monitor is a PostgreSQL Query Performance Monitoring tool, based on PostgreSQL contrib module pg_stat_statements. pg_stat_monitor provides aggregated statistics, client information, plan details including plan, and histogram information.'
|
comment = 'The pg_stat_monitor is a PostgreSQL Query Performance Monitoring tool, based on PostgreSQL contrib module pg_stat_statements. pg_stat_monitor provides aggregated statistics, client information, plan details including plan, and histogram information.'
|
||||||
default_version = '2.0'
|
default_version = '2.1'
|
||||||
module_pathname = '$libdir/pg_stat_monitor'
|
module_pathname = '$libdir/pg_stat_monitor'
|
||||||
relocatable = true
|
relocatable = true
|
||||||
|
|
|
@ -284,8 +284,8 @@ typedef struct Blocks
|
||||||
int64 local_blks_written; /* # of local disk blocks written */
|
int64 local_blks_written; /* # of local disk blocks written */
|
||||||
int64 temp_blks_read; /* # of temp blocks read */
|
int64 temp_blks_read; /* # of temp blocks read */
|
||||||
int64 temp_blks_written; /* # of temp blocks written */
|
int64 temp_blks_written; /* # of temp blocks written */
|
||||||
double blk_read_time; /* time spent reading, in msec */
|
double shared_blk_read_time; /* time spent reading shared blocks, in msec */
|
||||||
double blk_write_time; /* time spent writing, in msec */
|
double shared_blk_write_time; /* time spent writing shared blocks, in msec */
|
||||||
|
|
||||||
double temp_blk_read_time; /* time spent reading temp blocks, in msec */
|
double temp_blk_read_time; /* time spent reading temp blocks, in msec */
|
||||||
double temp_blk_write_time; /* time spent writing temp blocks, in
|
double temp_blk_write_time; /* time spent writing temp blocks, in
|
||||||
|
|
|
@ -24,9 +24,10 @@ SELECT routine_schema, routine_name, routine_type, data_type FROM information_sc
|
||||||
public | pgsm_create_13_view | FUNCTION | integer
|
public | pgsm_create_13_view | FUNCTION | integer
|
||||||
public | pgsm_create_14_view | FUNCTION | integer
|
public | pgsm_create_14_view | FUNCTION | integer
|
||||||
public | pgsm_create_15_view | FUNCTION | integer
|
public | pgsm_create_15_view | FUNCTION | integer
|
||||||
|
public | pgsm_create_17_view | FUNCTION | integer
|
||||||
public | pgsm_create_view | FUNCTION | integer
|
public | pgsm_create_view | FUNCTION | integer
|
||||||
public | range | FUNCTION | ARRAY
|
public | range | FUNCTION | ARRAY
|
||||||
(13 rows)
|
(14 rows)
|
||||||
|
|
||||||
SET ROLE u1;
|
SET ROLE u1;
|
||||||
SELECT routine_schema, routine_name, routine_type, data_type FROM information_schema.routines WHERE routine_schema = 'public' ORDER BY routine_name COLLATE "C";
|
SELECT routine_schema, routine_name, routine_type, data_type FROM information_schema.routines WHERE routine_schema = 'public' ORDER BY routine_name COLLATE "C";
|
||||||
|
|
|
@ -24,9 +24,10 @@ SELECT routine_schema, routine_name, routine_type, data_type FROM information_sc
|
||||||
public | pgsm_create_13_view | FUNCTION | integer
|
public | pgsm_create_13_view | FUNCTION | integer
|
||||||
public | pgsm_create_14_view | FUNCTION | integer
|
public | pgsm_create_14_view | FUNCTION | integer
|
||||||
public | pgsm_create_15_view | FUNCTION | integer
|
public | pgsm_create_15_view | FUNCTION | integer
|
||||||
|
public | pgsm_create_17_view | FUNCTION | integer
|
||||||
public | pgsm_create_view | FUNCTION | integer
|
public | pgsm_create_view | FUNCTION | integer
|
||||||
public | range | FUNCTION | ARRAY
|
public | range | FUNCTION | ARRAY
|
||||||
(13 rows)
|
(14 rows)
|
||||||
|
|
||||||
SET ROLE u1;
|
SET ROLE u1;
|
||||||
SELECT routine_schema, routine_name, routine_type, data_type FROM information_schema.routines WHERE routine_schema = 'public' ORDER BY routine_name COLLATE "C";
|
SELECT routine_schema, routine_name, routine_type, data_type FROM information_schema.routines WHERE routine_schema = 'public' ORDER BY routine_name COLLATE "C";
|
||||||
|
|
|
@ -2,7 +2,7 @@ CREATE EXTENSION pg_stat_monitor;
|
||||||
SELECT pg_stat_monitor_version();
|
SELECT pg_stat_monitor_version();
|
||||||
pg_stat_monitor_version
|
pg_stat_monitor_version
|
||||||
-------------------------
|
-------------------------
|
||||||
2.0.4
|
2.1.0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
DROP EXTENSION pg_stat_monitor;
|
||||||
|
|
|
@ -22,21 +22,21 @@ print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
close $conf;
|
close $conf;
|
||||||
|
|
||||||
# Dictionary for expected PGSM columns names on different PG server versions
|
# Dictionary for expected PGSM columns names on different PG server versions
|
||||||
my %pg_versions_pgsm_columns = ( 17 => "application_name,blk_read_time," .
|
my %pg_versions_pgsm_columns = ( 17 => "application_name,".
|
||||||
"blk_write_time,bucket,bucket_done,bucket_start_time,calls," .
|
"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,dbid,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,query,query_plan,queryid,relations,resp_calls," .
|
"plans,query,query_plan,queryid,relations,resp_calls,rows," .
|
||||||
"rows,shared_blks_dirtied,shared_blks_hit,shared_blks_read," .
|
"shared_blk_read_time,shared_blk_write_time,shared_blks_dirtied," .
|
||||||
"shared_blks_written,sqlcode,stddev_exec_time,stddev_plan_time," .
|
"shared_blks_hit,shared_blks_read,shared_blks_written," .
|
||||||
"temp_blk_read_time,temp_blk_write_time,temp_blks_read,temp_blks_written," .
|
"sqlcode,stddev_exec_time,stddev_plan_time,temp_blk_read_time,temp_blk_write_time," .
|
||||||
"top_query,top_queryid,toplevel,total_exec_time,total_plan_time," .
|
"temp_blks_read,temp_blks_written,top_query,top_queryid,toplevel," .
|
||||||
"userid,username,wal_bytes,wal_fpi,wal_records",
|
"total_exec_time,total_plan_time,userid,username,wal_bytes,wal_fpi,wal_records",
|
||||||
16 => "application_name,blk_read_time," .
|
16 => "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," .
|
||||||
|
|
|
@ -87,10 +87,10 @@ ok($cmdret == 0, "Run pgbench");
|
||||||
ok($cmdret == 0, "Run pg_sleep for 2 seconds ");
|
ok($cmdret == 0, "Run pg_sleep for 2 seconds ");
|
||||||
PGSM::append_to_file($stdout);
|
PGSM::append_to_file($stdout);
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query,0,30),calls, rows, ROUND(total_exec_time::numeric,4) AS total_exec_time, ROUND(min_exec_time::numeric,4) AS min_exec_time, ROUND(max_exec_time::numeric,4) AS max_exec_time, ROUND(mean_exec_time::numeric,4) AS mean_exec_time, ROUND(stddev_exec_time::numeric,4) AS stddev_exec_time, ROUND(blk_read_time::numeric,4) AS blk_read_time, ROUND(blk_write_time::numeric,4) AS blk_write_time FROM pg_stat_statements WHERE query LIKE \'%bench%\' ORDER BY query,calls DESC;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT substr(query,0,30),calls, rows, ROUND(total_exec_time::numeric,4) AS total_exec_time, ROUND(min_exec_time::numeric,4) AS min_exec_time, ROUND(max_exec_time::numeric,4) AS max_exec_time, ROUND(mean_exec_time::numeric,4) AS mean_exec_time, ROUND(stddev_exec_time::numeric,4) AS stddev_exec_time, ROUND(${col_shared_blk_read_time}::numeric,4) AS ${col_shared_blk_read_time}, ROUND(${col_shared_blk_write_time}::numeric,4) AS ${col_shared_blk_write_time} FROM pg_stat_statements WHERE query LIKE '%bench%' ORDER BY query,calls DESC;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
PGSM::append_to_debug_file($stdout);
|
PGSM::append_to_debug_file($stdout);
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT bucket, bucket_start_time, queryid, substr(query,0,30) AS query, calls, rows, total_exec_time, min_exec_time, max_exec_time, mean_exec_time, stddev_exec_time, ROUND(blk_read_time::numeric,4) AS blk_read_time, ROUND(blk_write_time::numeric,4) AS blk_write_time, cpu_user_time, cpu_sys_time FROM pg_stat_monitor WHERE query LIKE \'%bench%\' ORDER BY query,calls DESC;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT bucket, bucket_start_time, queryid, substr(query,0,30) AS query, calls, rows, total_exec_time, min_exec_time, max_exec_time, mean_exec_time, stddev_exec_time, ROUND(${col_shared_blk_read_time}::numeric,4) AS ${col_shared_blk_read_time}, ROUND(${col_shared_blk_write_time}::numeric,4) AS ${col_shared_blk_write_time}, cpu_user_time, cpu_sys_time FROM pg_stat_monitor WHERE query LIKE '%bench%' ORDER BY query,calls DESC;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
PGSM::append_to_debug_file($stdout);
|
PGSM::append_to_debug_file($stdout);
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query,0,30) AS query,calls,rows,wal_records,wal_fpi,wal_bytes FROM pg_stat_statements WHERE query LIKE \'%bench%\' ORDER BY query,calls;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query,0,30) AS query,calls,rows,wal_records,wal_fpi,wal_bytes FROM pg_stat_statements WHERE query LIKE \'%bench%\' ORDER BY query,calls;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
@ -169,13 +169,13 @@ is($stdout,'t',"Compare: mean_exec_time is equal.");
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Compare: stddev_exec_time is equal.");
|
is($stdout,'t',"Compare: stddev_exec_time is equal.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.blk_read_time::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_read_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_read_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_read_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Compare: blk_read_time is equal.");
|
is($stdout,'t',"Compare: ${col_shared_blk_read_time} is equal.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.blk_write_time::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_write_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_write_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_write_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Compare: blk_write_time is equal.");
|
is($stdout,'t',"Compare: ${col_shared_blk_write_time} is equal.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_records) = SUM(PGSS.wal_records) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_records) = SUM(PGSS.wal_records) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
|
@ -218,13 +218,13 @@ is($stdout,'t',"Compare: mean_exec_time is equal.");
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Compare: stddev_exec_time is equal.");
|
is($stdout,'t',"Compare: stddev_exec_time is equal.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.blk_read_time::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_read_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_read_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_read_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Compare: blk_read_time is equal.");
|
is($stdout,'t',"Compare: ${col_shared_blk_read_time} is equal.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.blk_write_time::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_write_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_write_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_write_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Compare: blk_write_time is equal.");
|
is($stdout,'t',"Compare: ${col_shared_blk_write_time} is equal.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_records) = SUM(PGSS.wal_records) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_records) = SUM(PGSS.wal_records) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
|
@ -267,9 +267,9 @@ is($stdout,'t',"Compare: mean_exec_time is equal.");
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Compare: stddev_exec_time is equal.");
|
is($stdout,'t',"Compare: stddev_exec_time is equal.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.blk_write_time::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_write_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_write_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_write_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Compare: blk_write_time is equal.");
|
is($stdout,'t',"Compare: ${col_shared_blk_write_time} is equal.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_records) = SUM(PGSS.wal_records) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_records) = SUM(PGSS.wal_records) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
|
|
|
@ -35,6 +35,15 @@ $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = y
|
||||||
my $rt_value = $node->start;
|
my $rt_value = $node->start;
|
||||||
ok($rt_value == 1, "Start Server");
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
my $col_shared_blk_read_time = "shared_blk_read_time";
|
||||||
|
my $col_shared_blk_write_time = "shared_blk_write_time";
|
||||||
|
|
||||||
|
if ($PGSM::PG_MAJOR_VERSION <= 16)
|
||||||
|
{
|
||||||
|
$col_shared_blk_read_time = "blk_read_time";
|
||||||
|
$col_shared_blk_write_time = "blk_write_time";
|
||||||
|
}
|
||||||
|
|
||||||
# CREATE EXTENSION and change out file permissions
|
# CREATE EXTENSION and change out file permissions
|
||||||
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_statements;', extra_params => ['-a']);
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_statements;', extra_params => ['-a']);
|
||||||
ok($cmdret == 0, "CREATE PGSS EXTENSION");
|
ok($cmdret == 0, "CREATE PGSS EXTENSION");
|
||||||
|
@ -86,7 +95,7 @@ PGSM::append_to_debug_file($stdout);
|
||||||
PGSM::append_to_debug_file($stdout);
|
PGSM::append_to_debug_file($stdout);
|
||||||
PGSM::append_to_debug_file("--------");
|
PGSM::append_to_debug_file("--------");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query,0,130) AS query, calls, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, blk_read_time, blk_write_time FROM pg_stat_monitor WHERE query LIKE \'%bench%\' ORDER BY query,calls DESC;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT substr(query,0,130) AS query, calls, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, ${col_shared_blk_read_time}, ${col_shared_blk_write_time} FROM pg_stat_monitor WHERE query LIKE '%bench%' ORDER BY query,calls DESC;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
PGSM::append_to_debug_file($stdout);
|
PGSM::append_to_debug_file($stdout);
|
||||||
|
|
||||||
# Compare values for query 'DELETE FROM pgbench_accounts WHERE $1 = $2'
|
# Compare values for query 'DELETE FROM pgbench_accounts WHERE $1 = $2'
|
||||||
|
@ -106,13 +115,13 @@ is($stdout,'t',"Check: shared_blks_dirtied should not be 0.");
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Check: shared_blks_written should not be 0.");
|
is($stdout,'t',"Check: shared_blks_written should not be 0.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_read_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%DELETE FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres',"SELECT SUM(PGSM.${col_shared_blk_read_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%DELETE FROM pgbench_accounts%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Check: blk_read_time should not be 0.");
|
is($stdout,'t',"Check: ${col_shared_blk_read_time} should not be 0.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_write_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%DELETE FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres',"SELECT SUM(PGSM.${col_shared_blk_write_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%DELETE FROM pgbench_accounts%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Check: blk_write_time should not be 0.");
|
is($stdout,'t',"Check: ${col_shared_blk_write_time} should not be 0.");
|
||||||
|
|
||||||
# Compare values for query 'INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP)'
|
# Compare values for query 'INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP)'
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.shared_blks_hit) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.shared_blks_hit) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
@ -127,9 +136,9 @@ is($stdout,'t',"Check: shared_blks_dirtied should not be 0.");
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Check: shared_blks_written should not be 0.");
|
is($stdout,'t',"Check: shared_blks_written should not be 0.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_write_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres',"SELECT SUM(PGSM.${col_shared_blk_write_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%INSERT INTO pgbench_history%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Check: blk_write_time should not be 0.");
|
is($stdout,'t',"Check: ${col_shared_blk_write_time} should not be 0.");
|
||||||
|
|
||||||
# Compare values for query 'UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2'
|
# Compare values for query 'UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2'
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.shared_blks_hit) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts SET abalance%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.shared_blks_hit) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts SET abalance%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
@ -148,13 +157,13 @@ is($stdout,'t',"Check: shared_blks_dirtied should not be 0.");
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Check: shared_blks_written should not be 0.");
|
is($stdout,'t',"Check: shared_blks_written should not be 0.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_read_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts SET abalance%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(PGSM.${col_shared_blk_read_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%UPDATE pgbench_accounts SET abalance%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Check: blk_read_time should not be 0.");
|
is($stdout,'t',"Check: ${col_shared_blk_read_time} should not be 0.");
|
||||||
|
|
||||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_write_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts SET abalance%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
($cmdret, $stdout, $stderr) = $node->psql('postgres',"SELECT SUM(PGSM.${col_shared_blk_write_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%UPDATE pgbench_accounts SET abalance%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
trim($stdout);
|
trim($stdout);
|
||||||
is($stdout,'t',"Check: blk_write_time should not be 0.");
|
is($stdout,'t',"Check: ${col_shared_blk_write_time} should not be 0.");
|
||||||
|
|
||||||
# DROP EXTENSION
|
# DROP EXTENSION
|
||||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
|
Loading…
Reference in New Issue