PG-544: Regression cleanup.
parent
7f743b142a
commit
a3830624bb
2
Makefile
2
Makefile
|
@ -12,7 +12,7 @@ LDFLAGS_SL += $(filter -lm, $(LIBS))
|
||||||
|
|
||||||
TAP_TESTS = 1
|
TAP_TESTS = 1
|
||||||
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_monitor/pg_stat_monitor.conf --inputdir=regression
|
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_monitor/pg_stat_monitor.conf --inputdir=regression
|
||||||
REGRESS = basic version guc counters relations database error_insert application_name application_name_unique top_query cmd_type error rows tags histogram
|
REGRESS = basic version guc counters relations database error_insert application_name application_name_unique top_query cmd_type error rows tags
|
||||||
|
|
||||||
# Disabled because these tests require "shared_preload_libraries=pg_stat_statements",
|
# Disabled because these tests require "shared_preload_libraries=pg_stat_statements",
|
||||||
# which typical installcheck users do not have (e.g. buildfarm clients).
|
# which typical installcheck users do not have (e.g. buildfarm clients).
|
||||||
|
|
|
@ -181,8 +181,12 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_records,
|
wal_records,
|
||||||
wal_fpi,
|
wal_fpi,
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
-- PostgreSQL-13 Specific Coulumns
|
plans_calls,
|
||||||
plans_calls
|
total_plan_time,
|
||||||
|
min_plan_time,
|
||||||
|
max_plan_time,
|
||||||
|
mean_plan_time,
|
||||||
|
stddev_plan_time
|
||||||
FROM pg_stat_monitor_internal(TRUE) p, pg_database d WHERE dbid = oid
|
FROM pg_stat_monitor_internal(TRUE) p, pg_database d WHERE dbid = oid
|
||||||
ORDER BY bucket_start_time;
|
ORDER BY bucket_start_time;
|
||||||
RETURN 0;
|
RETURN 0;
|
||||||
|
@ -239,7 +243,6 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_fpi,
|
wal_fpi,
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
|
|
||||||
-- PostgreSQL-14 Specific Columns
|
|
||||||
plans_calls,
|
plans_calls,
|
||||||
total_plan_time,
|
total_plan_time,
|
||||||
min_plan_time,
|
min_plan_time,
|
||||||
|
|
|
@ -294,8 +294,12 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
state_code,
|
state_code,
|
||||||
get_state(state_code) as state,
|
get_state(state_code) as state,
|
||||||
|
|
||||||
-- PostgreSQL-13 Specific Coulumns
|
plans_calls,
|
||||||
plans_calls
|
total_plan_time,
|
||||||
|
min_plan_time,
|
||||||
|
max_plan_time,
|
||||||
|
mean_plan_time,
|
||||||
|
stddev_plan_time
|
||||||
FROM pg_stat_monitor_internal(TRUE) p, pg_database d WHERE dbid = oid
|
FROM pg_stat_monitor_internal(TRUE) p, pg_database d WHERE dbid = oid
|
||||||
ORDER BY bucket_start_time;
|
ORDER BY bucket_start_time;
|
||||||
RETURN 0;
|
RETURN 0;
|
||||||
|
@ -354,7 +358,6 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
state_code,
|
state_code,
|
||||||
get_state(state_code) as state,
|
get_state(state_code) as state,
|
||||||
|
|
||||||
-- PostgreSQL-14 Specific Columns
|
|
||||||
plans_calls,
|
plans_calls,
|
||||||
total_plan_time,
|
total_plan_time,
|
||||||
min_plan_time,
|
min_plan_time,
|
||||||
|
|
|
@ -196,11 +196,11 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
sqlcode,
|
sqlcode,
|
||||||
message,
|
message,
|
||||||
calls,
|
calls,
|
||||||
total_exec_time,
|
total_exec_time AS total_time,
|
||||||
min_time,
|
min_exec_time AS min_time,
|
||||||
max_time,
|
max_exec_time AS max_time,
|
||||||
mean_time,
|
mean_exec_time AS mean_time,
|
||||||
stddev_time,
|
stddev_exec_time AS stddev_time,
|
||||||
rows_retrieved,
|
rows_retrieved,
|
||||||
shared_blks_hit,
|
shared_blks_hit,
|
||||||
shared_blks_read,
|
shared_blks_read,
|
||||||
|
@ -277,7 +277,12 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_fpi,
|
wal_fpi,
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
-- PostgreSQL-13 Specific Coulumns
|
-- PostgreSQL-13 Specific Coulumns
|
||||||
plans_calls
|
plans_calls,
|
||||||
|
total_plan_time,
|
||||||
|
min_plan_time,
|
||||||
|
max_plan_time,
|
||||||
|
mean_plan_time,
|
||||||
|
stddev_plan_time
|
||||||
FROM pg_stat_monitor_internal(TRUE) p, pg_database d WHERE dbid = oid
|
FROM pg_stat_monitor_internal(TRUE) p, pg_database d WHERE dbid = oid
|
||||||
ORDER BY bucket_start_time;
|
ORDER BY bucket_start_time;
|
||||||
RETURN 0;
|
RETURN 0;
|
||||||
|
@ -334,7 +339,6 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
wal_fpi,
|
wal_fpi,
|
||||||
wal_bytes,
|
wal_bytes,
|
||||||
|
|
||||||
-- PostgreSQL-14 Specific Columns
|
|
||||||
plans_calls,
|
plans_calls,
|
||||||
total_plan_time,
|
total_plan_time,
|
||||||
min_plan_time,
|
min_plan_time,
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
select pg_sleep(.5);
|
|
||||||
pg_sleep
|
|
||||||
----------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 1;
|
|
||||||
?column?
|
|
||||||
----------
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query
|
|
||||||
--------------------------------------------------------------
|
|
||||||
SELECT $1
|
|
||||||
SELECT pg_stat_monitor_reset()
|
|
||||||
SELECT query FROM pg_stat_monitor ORDER BY query COLLATE "C"
|
|
||||||
select pg_sleep($1)
|
|
||||||
(4 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
|
@ -64,7 +64,6 @@ SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
---------------------------------------------------------------------------------------------------+-------
|
---------------------------------------------------------------------------------------------------+-------
|
||||||
SELECT a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a | 1000
|
SELECT a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a | 1000
|
||||||
SELECT pg_stat_monitor_reset() | 1
|
SELECT pg_stat_monitor_reset() | 1
|
||||||
SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1
|
|
||||||
do $$ +| 1
|
do $$ +| 1
|
||||||
declare +|
|
declare +|
|
||||||
n integer:= 1; +|
|
n integer:= 1; +|
|
||||||
|
|
|
@ -61,20 +61,10 @@ begin
|
||||||
end $$;
|
end $$;
|
||||||
SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
query | calls
|
query | calls
|
||||||
---------------------------------------------------------------------------------------------------+-------
|
---------------------------------------------------------------------------------+-------
|
||||||
SELECT a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a | 1000
|
SELECT a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a | 1000
|
||||||
SELECT pg_stat_monitor_reset() | 1
|
SELECT pg_stat_monitor_reset() | 1
|
||||||
do $$ +| 1
|
(2 rows)
|
||||||
declare +|
|
|
||||||
n integer:= 1; +|
|
|
||||||
begin +|
|
|
||||||
loop +|
|
|
||||||
PERFORM a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a;+|
|
|
||||||
exit when n = 1000; +|
|
|
||||||
n := n + 1; +|
|
|
||||||
end loop; +|
|
|
||||||
end $$ |
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
DROP TABLE t2;
|
DROP TABLE t2;
|
||||||
|
|
|
@ -32,7 +32,6 @@ SELECT datname, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
--------------------+---------------------------------------
|
--------------------+---------------------------------------
|
||||||
db1 | SELECT * FROM t1,t2 WHERE t1.a = t2.b
|
db1 | SELECT * FROM t1,t2 WHERE t1.a = t2.b
|
||||||
db2 | SELECT * FROM t3,t4 WHERE t3.c = t4.d
|
db2 | SELECT * FROM t3,t4 WHERE t3.c = t4.d
|
||||||
contrib_regression | SELECT datname, query FROM pg_stat_monitor ORDER BY query COLLATE "C"
|
|
||||||
contrib_regression | SELECT pg_stat_monitor_reset()
|
contrib_regression | SELECT pg_stat_monitor_reset()
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
CREATE DATABASE db1;
|
|
||||||
CREATE DATABASE db2;
|
|
||||||
\c db1
|
|
||||||
CREATE TABLE t1 (a int);
|
|
||||||
CREATE TABLE t2 (b int);
|
|
||||||
\c db2
|
|
||||||
CREATE TABLE t3 (c int);
|
|
||||||
CREATE TABLE t4 (d int);
|
|
||||||
\c contrib_regression
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
\c db1
|
|
||||||
SELECT * FROM t1,t2 WHERE t1.a = t2.b;
|
|
||||||
a | b
|
|
||||||
---+---
|
|
||||||
(0 rows)
|
|
||||||
|
|
||||||
\c db2
|
|
||||||
SELECT * FROM t3,t4 WHERE t3.c = t4.d;
|
|
||||||
c | d
|
|
||||||
---+---
|
|
||||||
(0 rows)
|
|
||||||
|
|
||||||
\c contrib_regression
|
|
||||||
SELECT datname, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
datname | query
|
|
||||||
--------------------+---------------------------------------
|
|
||||||
db1 | SELECT * FROM t1,t2 WHERE t1.a = t2.b
|
|
||||||
db2 | SELECT * FROM t3,t4 WHERE t3.c = t4.d
|
|
||||||
contrib_regression | SELECT pg_stat_monitor_reset()
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
\c db1
|
|
||||||
DROP TABLE t1;
|
|
||||||
DROP TABLE t2;
|
|
||||||
\c db2
|
|
||||||
DROP TABLE t3;
|
|
||||||
DROP TABLE t4;
|
|
||||||
\c contrib_regression
|
|
||||||
DROP DATABASE db1;
|
|
||||||
DROP DATABASE db2;
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
|
@ -22,21 +22,16 @@ END $$;
|
||||||
WARNING: warning message
|
WARNING: warning message
|
||||||
SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel;
|
SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel;
|
||||||
query | elevel | sqlcode | message
|
query | elevel | sqlcode | message
|
||||||
-----------------------------------------------------------------------------------------------+--------+---------+-----------------------------------
|
----------------------------------+--------+---------+-----------------------------------
|
||||||
ELECET * FROM unknown; | 20 | 42601 | syntax error at or near "ELECET"
|
ELECET * FROM unknown; | 21 | 42601 | syntax error at or near "ELECET"
|
||||||
SELECT * FROM unknown; | 20 | 42P01 | relation "unknown" does not exist
|
SELECT * FROM unknown; | 21 | 42P01 | relation "unknown" does not exist
|
||||||
SELECT 1/0; | 20 | 22012 | division by zero
|
SELECT 1/0; | 21 | 22012 | division by zero
|
||||||
SELECT pg_stat_monitor_reset() | 0 | |
|
SELECT pg_stat_monitor_reset() | 0 | |
|
||||||
SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel | 0 | |
|
|
||||||
do $$ +| 0 | |
|
|
||||||
BEGIN +| | |
|
|
||||||
RAISE WARNING 'warning message'; +| | |
|
|
||||||
END $$ | | |
|
|
||||||
do $$ +| 19 | 01000 | warning message
|
do $$ +| 19 | 01000 | warning message
|
||||||
BEGIN +| | |
|
BEGIN +| | |
|
||||||
RAISE WARNING 'warning message';+| | |
|
RAISE WARNING 'warning message';+| | |
|
||||||
END $$; | | |
|
END $$; | | |
|
||||||
(7 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
|
|
|
@ -18,13 +18,11 @@ DETAIL: Key (id)=(1) already exists.
|
||||||
Drop Table if exists Company;
|
Drop Table if exists Company;
|
||||||
SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel;
|
SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel;
|
||||||
query | elevel | sqlcode | message
|
query | elevel | sqlcode | message
|
||||||
-----------------------------------------------------------------------------------------------+--------+---------+---------------------------------------------------------------
|
-------------------------------------------------------+--------+---------+---------------------------------------------------------------
|
||||||
Drop Table if exists Company | 0 | |
|
|
||||||
INSERT INTO Company(ID, Name) VALUES (1, 'Percona') | 0 | |
|
INSERT INTO Company(ID, Name) VALUES (1, 'Percona') | 0 | |
|
||||||
INSERT INTO Company(ID, Name) VALUES (1, 'Percona'); | 20 | 23505 | duplicate key value violates unique constraint "company_pkey"
|
INSERT INTO Company(ID, Name) VALUES (1, 'Percona'); | 21 | 23505 | duplicate key value violates unique constraint "company_pkey"
|
||||||
SELECT pg_stat_monitor_reset() | 0 | |
|
SELECT pg_stat_monitor_reset() | 0 | |
|
||||||
SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel | 0 | |
|
(3 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
|
|
|
@ -11,7 +11,7 @@ select pg_sleep(.5);
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C";
|
SELECT * FROM pg_stat_monitor_settings WHERE name NOT LIKE 'pg_stat_monitor.pgsm_track_planning' ORDER BY name COLLATE "C";
|
||||||
name | value | default_value | description | minimum | maximum | options | restart
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
@ -27,9 +27,8 @@ SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C";
|
||||||
pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
||||||
pg_stat_monitor.pgsm_track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
pg_stat_monitor.pgsm_track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
(15 rows)
|
(14 rows)
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
select pg_sleep(.5);
|
|
||||||
pg_sleep
|
|
||||||
----------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C";
|
|
||||||
name | value | default_value | description | minimum | maximum | options | restart
|
|
||||||
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
|
||||||
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
|
||||||
pg_stat_monitor.pgsm_normalized_query | no | no | Selects whether save query in normalized format. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
|
||||||
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
|
||||||
(14 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
|
@ -46,17 +46,16 @@ INFO: Sleep 5 seconds
|
||||||
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
query | calls | resp_calls
|
query | calls | resp_calls
|
||||||
---------------------------------------------------+-------+-----------------------
|
--------------------------------------+-------+-----------------------
|
||||||
SELECT pg_sleep(i) | 5 | {0,0,0,0,0,0,3,2,0,0}
|
SELECT pg_sleep(i) | 5 | {0,0,0,0,0,0,3,2,0,0}
|
||||||
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_ | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
Set pg_stat_monitor.pgsm_track='all' | 1 | {1,0,0,0,0,0,0,0,0,0}
|
Set pg_stat_monitor.pgsm_track='all' | 1 | {1,0,0,0,0,0,0,0,0,0}
|
||||||
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
select * from generate_histogram();
|
select * from generate_histogram();
|
||||||
range | freq | bar
|
range | freq | bar
|
||||||
--------------------+------+--------------------------------------------------------------------------------------------
|
--------------------+------+--------------------------------
|
||||||
(0 - 3)} | 0 |
|
(0 - 3)} | 0 |
|
||||||
(3 - 10)} | 0 |
|
(3 - 10)} | 0 |
|
||||||
(10 - 31)} | 0 |
|
(10 - 31)} | 0 |
|
||||||
|
|
|
@ -47,11 +47,12 @@ INFO: Sleep 5 seconds
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
query | calls | resp_calls
|
query | calls | resp_calls
|
||||||
--------------------------------------+-------+-----------------------
|
--------------------------------------+-------+-----------------------
|
||||||
SELECT pg_sleep(i) | 5 | {0,0,0,0,0,0,3,2,0,0}
|
SELECT pg_sleep(i) | 2 | {0,0,0,0,0,0,2,0,0,0}
|
||||||
|
SELECT pg_sleep(i) | 3 | {0,0,0,0,0,0,1,2,0,0}
|
||||||
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
||||||
Set pg_stat_monitor.pgsm_track='all' | 1 | {1,0,0,0,0,0,0,0,0,0}
|
Set pg_stat_monitor.pgsm_track='all' | 1 | {1,0,0,0,0,0,0,0,0,0}
|
||||||
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
||||||
(4 rows)
|
(5 rows)
|
||||||
|
|
||||||
select * from generate_histogram();
|
select * from generate_histogram();
|
||||||
range | freq | bar
|
range | freq | bar
|
||||||
|
@ -62,8 +63,8 @@ select * from generate_histogram();
|
||||||
(31 - 100)} | 0 |
|
(31 - 100)} | 0 |
|
||||||
(100 - 316)} | 0 |
|
(100 - 316)} | 0 |
|
||||||
(316 - 1000)} | 0 |
|
(316 - 1000)} | 0 |
|
||||||
(1000 - 3162)} | 3 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
(1000 - 3162)} | 1 | ■■■■■■■■■■■■■■■
|
||||||
(3162 - 10000)} | 2 | ■■■■■■■■■■■■■■■■■■■■
|
(3162 - 10000)} | 2 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
||||||
(10000 - 31622)} | 0 |
|
(10000 - 31622)} | 0 |
|
||||||
(31622 - 100000)} | 0 |
|
(31622 - 100000)} | 0 |
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
|
@ -46,14 +46,11 @@ INFO: Sleep 5 seconds
|
||||||
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
query | calls | resp_calls
|
query | calls | resp_calls
|
||||||
---------------------------------------------------+-------+-----------------------
|
--------------------------------+-------+-----------------------
|
||||||
SELECT pg_sleep(i) | 4 | {0,0,0,0,0,0,3,1,0,0}
|
SELECT pg_sleep(i) | 5 | {0,0,0,0,0,0,3,2,0,0}
|
||||||
SELECT pg_sleep(i) | 1 | {0,0,0,0,0,0,0,1,0,0}
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_ | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
Set pg_stat_monitor.pgsm_track='all' | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
||||||
(6 rows)
|
(3 rows)
|
||||||
|
|
||||||
select * from generate_histogram();
|
select * from generate_histogram();
|
||||||
range | freq | bar
|
range | freq | bar
|
||||||
|
@ -65,7 +62,7 @@ select * from generate_histogram();
|
||||||
(100 - 316)} | 0 |
|
(100 - 316)} | 0 |
|
||||||
(316 - 1000)} | 0 |
|
(316 - 1000)} | 0 |
|
||||||
(1000 - 3162)} | 3 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
(1000 - 3162)} | 3 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
||||||
(3162 - 10000)} | 1 | ■■■■■■■■■■
|
(3162 - 10000)} | 2 | ■■■■■■■■■■■■■■■■■■■■
|
||||||
(10000 - 31622)} | 0 |
|
(10000 - 31622)} | 0 |
|
||||||
(31622 - 100000)} | 0 |
|
(31622 - 100000)} | 0 |
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
CREATE OR REPLACE FUNCTION generate_histogram()
|
|
||||||
RETURNS TABLE (
|
|
||||||
range TEXT, freq INT, bar TEXT
|
|
||||||
) AS $$
|
|
||||||
Declare
|
|
||||||
bucket_id integer;
|
|
||||||
query_id text;
|
|
||||||
BEGIN
|
|
||||||
select bucket into bucket_id from pg_stat_monitor order by calls desc limit 1;
|
|
||||||
select queryid into query_id from pg_stat_monitor order by calls desc limit 1;
|
|
||||||
--RAISE INFO 'bucket_id %', bucket_id;
|
|
||||||
--RAISE INFO 'query_id %', query_id;
|
|
||||||
return query
|
|
||||||
SELECT * FROM histogram(bucket_id, query_id) AS a(range TEXT, freq INT, bar TEXT);
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
CREATE OR REPLACE FUNCTION run_pg_sleep(INTEGER) RETURNS VOID AS $$
|
|
||||||
DECLARE
|
|
||||||
loops ALIAS FOR $1;
|
|
||||||
BEGIN
|
|
||||||
FOR i IN 1..loops LOOP
|
|
||||||
--RAISE INFO 'Current timestamp: %', timeofday()::TIMESTAMP;
|
|
||||||
RAISE INFO 'Sleep % seconds', i;
|
|
||||||
PERFORM pg_sleep(i);
|
|
||||||
END LOOP;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' STRICT;
|
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
Set pg_stat_monitor.pgsm_track='all';
|
|
||||||
select run_pg_sleep(5);
|
|
||||||
INFO: Sleep 1 seconds
|
|
||||||
INFO: Sleep 2 seconds
|
|
||||||
INFO: Sleep 3 seconds
|
|
||||||
INFO: Sleep 4 seconds
|
|
||||||
INFO: Sleep 5 seconds
|
|
||||||
run_pg_sleep
|
|
||||||
--------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | resp_calls
|
|
||||||
---------------------------------------------------+-------+-----------------------
|
|
||||||
SELECT pg_sleep(i) | 3 | {0,0,0,0,0,0,3,0,0,0}
|
|
||||||
SELECT pg_sleep(i) | 2 | {0,0,0,0,0,0,0,2,0,0}
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_ | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
Set pg_stat_monitor.pgsm_track='all' | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
|
||||||
(6 rows)
|
|
||||||
|
|
||||||
select * from generate_histogram();
|
|
||||||
range | freq | bar
|
|
||||||
--------------------+------+--------------------------------------------------------------------------------------------
|
|
||||||
(0 - 3)} | 0 |
|
|
||||||
(3 - 10)} | 0 |
|
|
||||||
(10 - 31)} | 0 |
|
|
||||||
(31 - 100)} | 0 |
|
|
||||||
(100 - 316)} | 0 |
|
|
||||||
(316 - 1000)} | 0 |
|
|
||||||
(1000 - 3162)} | 3 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
|
||||||
(3162 - 10000)} | 0 |
|
|
||||||
(10000 - 31622)} | 0 |
|
|
||||||
(31622 - 100000)} | 0 |
|
|
||||||
(10 rows)
|
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
|
@ -1,73 +0,0 @@
|
||||||
CREATE OR REPLACE FUNCTION generate_histogram()
|
|
||||||
RETURNS TABLE (
|
|
||||||
range TEXT, freq INT, bar TEXT
|
|
||||||
) AS $$
|
|
||||||
Declare
|
|
||||||
bucket_id integer;
|
|
||||||
query_id text;
|
|
||||||
BEGIN
|
|
||||||
select bucket into bucket_id from pg_stat_monitor order by calls desc limit 1;
|
|
||||||
select queryid into query_id from pg_stat_monitor order by calls desc limit 1;
|
|
||||||
--RAISE INFO 'bucket_id %', bucket_id;
|
|
||||||
--RAISE INFO 'query_id %', query_id;
|
|
||||||
return query
|
|
||||||
SELECT * FROM histogram(bucket_id, query_id) AS a(range TEXT, freq INT, bar TEXT);
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
CREATE OR REPLACE FUNCTION run_pg_sleep(INTEGER) RETURNS VOID AS $$
|
|
||||||
DECLARE
|
|
||||||
loops ALIAS FOR $1;
|
|
||||||
BEGIN
|
|
||||||
FOR i IN 1..loops LOOP
|
|
||||||
--RAISE INFO 'Current timestamp: %', timeofday()::TIMESTAMP;
|
|
||||||
RAISE INFO 'Sleep % seconds', i;
|
|
||||||
PERFORM pg_sleep(i);
|
|
||||||
END LOOP;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' STRICT;
|
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
Set pg_stat_monitor.pgsm_track='all';
|
|
||||||
select run_pg_sleep(5);
|
|
||||||
INFO: Sleep 1 seconds
|
|
||||||
INFO: Sleep 2 seconds
|
|
||||||
INFO: Sleep 3 seconds
|
|
||||||
INFO: Sleep 4 seconds
|
|
||||||
INFO: Sleep 5 seconds
|
|
||||||
run_pg_sleep
|
|
||||||
--------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | resp_calls
|
|
||||||
---------------------------------------------------+-------+-----------------------
|
|
||||||
SELECT pg_sleep(i) | 3 | {0,0,0,0,0,0,3,0,0,0}
|
|
||||||
SELECT pg_sleep(i) | 2 | {0,0,0,0,0,0,0,2,0,0}
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_ | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
Set pg_stat_monitor.pgsm_track='all' | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
|
||||||
(6 rows)
|
|
||||||
|
|
||||||
select * from generate_histogram();
|
|
||||||
range | freq | bar
|
|
||||||
--------------------+------+--------------------------------
|
|
||||||
(0 - 3)} | 0 |
|
|
||||||
(3 - 10)} | 0 |
|
|
||||||
(10 - 31)} | 0 |
|
|
||||||
(31 - 100)} | 0 |
|
|
||||||
(100 - 316)} | 0 |
|
|
||||||
(316 - 1000)} | 0 |
|
|
||||||
(1000 - 3162)} | 3 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
|
||||||
(3162 - 10000)} | 0 |
|
|
||||||
(10000 - 31622)} | 0 |
|
|
||||||
(31622 - 100000)} | 0 |
|
|
||||||
(10 rows)
|
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
|
@ -1,72 +0,0 @@
|
||||||
CREATE OR REPLACE FUNCTION generate_histogram()
|
|
||||||
RETURNS TABLE (
|
|
||||||
range TEXT, freq INT, bar TEXT
|
|
||||||
) AS $$
|
|
||||||
Declare
|
|
||||||
bucket_id integer;
|
|
||||||
query_id text;
|
|
||||||
BEGIN
|
|
||||||
select bucket into bucket_id from pg_stat_monitor order by calls desc limit 1;
|
|
||||||
select queryid into query_id from pg_stat_monitor order by calls desc limit 1;
|
|
||||||
--RAISE INFO 'bucket_id %', bucket_id;
|
|
||||||
--RAISE INFO 'query_id %', query_id;
|
|
||||||
return query
|
|
||||||
SELECT * FROM histogram(bucket_id, query_id) AS a(range TEXT, freq INT, bar TEXT);
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
CREATE OR REPLACE FUNCTION run_pg_sleep(INTEGER) RETURNS VOID AS $$
|
|
||||||
DECLARE
|
|
||||||
loops ALIAS FOR $1;
|
|
||||||
BEGIN
|
|
||||||
FOR i IN 1..loops LOOP
|
|
||||||
--RAISE INFO 'Current timestamp: %', timeofday()::TIMESTAMP;
|
|
||||||
RAISE INFO 'Sleep % seconds', i;
|
|
||||||
PERFORM pg_sleep(i);
|
|
||||||
END LOOP;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' STRICT;
|
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
Set pg_stat_monitor.pgsm_track='all';
|
|
||||||
select run_pg_sleep(5);
|
|
||||||
INFO: Sleep 1 seconds
|
|
||||||
INFO: Sleep 2 seconds
|
|
||||||
INFO: Sleep 3 seconds
|
|
||||||
INFO: Sleep 4 seconds
|
|
||||||
INFO: Sleep 5 seconds
|
|
||||||
run_pg_sleep
|
|
||||||
--------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | resp_calls
|
|
||||||
---------------------------------------------------+-------+-----------------------
|
|
||||||
SELECT pg_sleep(i) | 4 | {0,0,0,0,0,0,2,2,0,0}
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_ | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
Set pg_stat_monitor.pgsm_track='all' | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
select * from generate_histogram();
|
|
||||||
range | freq | bar
|
|
||||||
--------------------+------+--------------------------------
|
|
||||||
(0 - 3)} | 0 |
|
|
||||||
(3 - 10)} | 0 |
|
|
||||||
(10 - 31)} | 0 |
|
|
||||||
(31 - 100)} | 0 |
|
|
||||||
(100 - 316)} | 0 |
|
|
||||||
(316 - 1000)} | 0 |
|
|
||||||
(1000 - 3162)} | 2 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
|
||||||
(3162 - 10000)} | 2 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
|
||||||
(10000 - 31622)} | 0 |
|
|
||||||
(31622 - 100000)} | 0 |
|
|
||||||
(10 rows)
|
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
|
@ -1,73 +0,0 @@
|
||||||
CREATE OR REPLACE FUNCTION generate_histogram()
|
|
||||||
RETURNS TABLE (
|
|
||||||
range TEXT, freq INT, bar TEXT
|
|
||||||
) AS $$
|
|
||||||
Declare
|
|
||||||
bucket_id integer;
|
|
||||||
query_id text;
|
|
||||||
BEGIN
|
|
||||||
select bucket into bucket_id from pg_stat_monitor order by calls desc limit 1;
|
|
||||||
select queryid into query_id from pg_stat_monitor order by calls desc limit 1;
|
|
||||||
--RAISE INFO 'bucket_id %', bucket_id;
|
|
||||||
--RAISE INFO 'query_id %', query_id;
|
|
||||||
return query
|
|
||||||
SELECT * FROM histogram(bucket_id, query_id) AS a(range TEXT, freq INT, bar TEXT);
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
CREATE OR REPLACE FUNCTION run_pg_sleep(INTEGER) RETURNS VOID AS $$
|
|
||||||
DECLARE
|
|
||||||
loops ALIAS FOR $1;
|
|
||||||
BEGIN
|
|
||||||
FOR i IN 1..loops LOOP
|
|
||||||
--RAISE INFO 'Current timestamp: %', timeofday()::TIMESTAMP;
|
|
||||||
RAISE INFO 'Sleep % seconds', i;
|
|
||||||
PERFORM pg_sleep(i);
|
|
||||||
END LOOP;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' STRICT;
|
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
Set pg_stat_monitor.pgsm_track='all';
|
|
||||||
select run_pg_sleep(5);
|
|
||||||
INFO: Sleep 1 seconds
|
|
||||||
INFO: Sleep 2 seconds
|
|
||||||
INFO: Sleep 3 seconds
|
|
||||||
INFO: Sleep 4 seconds
|
|
||||||
INFO: Sleep 5 seconds
|
|
||||||
run_pg_sleep
|
|
||||||
--------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | resp_calls
|
|
||||||
---------------------------------------------------+-------+-----------------------
|
|
||||||
SELECT pg_sleep(i) | 2 | {0,0,0,0,0,0,2,0,0,0}
|
|
||||||
SELECT pg_sleep(i) | 3 | {0,0,0,0,0,0,1,2,0,0}
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
SELECT substr(query, 0,50) as query, calls, resp_ | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
Set pg_stat_monitor.pgsm_track='all' | 1 | {1,0,0,0,0,0,0,0,0,0}
|
|
||||||
select run_pg_sleep(5) | 1 | {0,0,0,0,0,0,0,0,1,0}
|
|
||||||
(6 rows)
|
|
||||||
|
|
||||||
select * from generate_histogram();
|
|
||||||
range | freq | bar
|
|
||||||
--------------------+------+--------------------------------
|
|
||||||
(0 - 3)} | 0 |
|
|
||||||
(3 - 10)} | 0 |
|
|
||||||
(10 - 31)} | 0 |
|
|
||||||
(31 - 100)} | 0 |
|
|
||||||
(100 - 316)} | 0 |
|
|
||||||
(316 - 1000)} | 0 |
|
|
||||||
(1000 - 3162)} | 1 | ■■■■■■■■■■■■■■■
|
|
||||||
(3162 - 10000)} | 2 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
|
||||||
(10000 - 31622)} | 0 |
|
|
||||||
(31622 - 100000)} | 0 |
|
|
||||||
(10 rows)
|
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
|
@ -1,442 +0,0 @@
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
--
|
|
||||||
-- simple and compound statements
|
|
||||||
--
|
|
||||||
SET pg_stat_monitor.track_utility = FALSE;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 1 AS "int";
|
|
||||||
int
|
|
||||||
-----
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 'hello'
|
|
||||||
-- multiline
|
|
||||||
AS "text";
|
|
||||||
text
|
|
||||||
-------
|
|
||||||
hello
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 'world' AS "text";
|
|
||||||
text
|
|
||||||
-------
|
|
||||||
world
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- transaction
|
|
||||||
BEGIN;
|
|
||||||
SELECT 1 AS "int";
|
|
||||||
int
|
|
||||||
-----
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 'hello' AS "text";
|
|
||||||
text
|
|
||||||
-------
|
|
||||||
hello
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
COMMIT;
|
|
||||||
-- compound transaction
|
|
||||||
BEGIN \;
|
|
||||||
SELECT 2.0 AS "float" \;
|
|
||||||
SELECT 'world' AS "text" \;
|
|
||||||
COMMIT;
|
|
||||||
-- compound with empty statements and spurious leading spacing
|
|
||||||
\;\; SELECT 3 + 3 \;\;\; SELECT ' ' || ' !' \;\; SELECT 1 + 4 \;;
|
|
||||||
?column?
|
|
||||||
----------
|
|
||||||
5
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- non ;-terminated statements
|
|
||||||
SELECT 1 + 1 + 1 AS "add" \gset
|
|
||||||
SELECT :add + 1 + 1 AS "add" \;
|
|
||||||
SELECT :add + 1 + 1 AS "add" \gset
|
|
||||||
-- set operator
|
|
||||||
SELECT 1 AS i UNION SELECT 2 ORDER BY i;
|
|
||||||
i
|
|
||||||
---
|
|
||||||
1
|
|
||||||
2
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- ? operator
|
|
||||||
select '{"a":1, "b":2}'::jsonb ? 'b';
|
|
||||||
?column?
|
|
||||||
----------
|
|
||||||
t
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- cte
|
|
||||||
WITH t(f) AS (
|
|
||||||
VALUES (1.0), (2.0)
|
|
||||||
)
|
|
||||||
SELECT f FROM t ORDER BY f;
|
|
||||||
f
|
|
||||||
-----
|
|
||||||
1.0
|
|
||||||
2.0
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- prepared statement with parameter
|
|
||||||
PREPARE pgss_test (int) AS SELECT $1, 'test' LIMIT 1;
|
|
||||||
EXECUTE pgss_test(1);
|
|
||||||
?column? | ?column?
|
|
||||||
----------+----------
|
|
||||||
1 | test
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DEALLOCATE pgss_test;
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | rows
|
|
||||||
---------------------------------------------------------------------------+-------+------
|
|
||||||
BEGIN | 2 | 0
|
|
||||||
COMMIT | 2 | 0
|
|
||||||
PREPARE pgss_test (int) AS SELECT $1, $2 LIMIT $3 | 1 | 1
|
|
||||||
SELECT $1 | 2 | 2
|
|
||||||
SELECT $1 +| 4 | 4
|
|
||||||
+| |
|
|
||||||
AS "text" | |
|
|
||||||
SELECT $1 + $2 | 2 | 2
|
|
||||||
SELECT $1 + $2 + $3 AS "add" | 3 | 3
|
|
||||||
SELECT $1 AS "float" | 1 | 1
|
|
||||||
SELECT $1 AS i UNION SELECT $2 ORDER BY i | 1 | 2
|
|
||||||
SELECT $1 || $2 | 1 | 1
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
|
||||||
WITH t(f) AS ( +| 1 | 2
|
|
||||||
VALUES ($1), ($2) +| |
|
|
||||||
) +| |
|
|
||||||
SELECT f FROM t ORDER BY f | |
|
|
||||||
select $1::jsonb ? $2 | 1 | 1
|
|
||||||
(14 rows)
|
|
||||||
|
|
||||||
--
|
|
||||||
-- CRUD: INSERT SELECT UPDATE DELETE on test table
|
|
||||||
--
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- utility "create table" should not be shown
|
|
||||||
CREATE TEMP TABLE test (a int, b char(20));
|
|
||||||
INSERT INTO test VALUES(generate_series(1, 10), 'aaa');
|
|
||||||
UPDATE test SET b = 'bbb' WHERE a > 7;
|
|
||||||
DELETE FROM test WHERE a > 9;
|
|
||||||
-- explicit transaction
|
|
||||||
BEGIN;
|
|
||||||
UPDATE test SET b = '111' WHERE a = 1 ;
|
|
||||||
COMMIT;
|
|
||||||
BEGIN \;
|
|
||||||
UPDATE test SET b = '222' WHERE a = 2 \;
|
|
||||||
COMMIT ;
|
|
||||||
UPDATE test SET b = '333' WHERE a = 3 \;
|
|
||||||
UPDATE test SET b = '444' WHERE a = 4 ;
|
|
||||||
BEGIN \;
|
|
||||||
UPDATE test SET b = '555' WHERE a = 5 \;
|
|
||||||
UPDATE test SET b = '666' WHERE a = 6 \;
|
|
||||||
COMMIT ;
|
|
||||||
-- many INSERT values
|
|
||||||
INSERT INTO test (a, b) VALUES (1, 'a'), (2, 'b'), (3, 'c');
|
|
||||||
-- SELECT with constants
|
|
||||||
SELECT * FROM test WHERE a > 5 ORDER BY a ;
|
|
||||||
a | b
|
|
||||||
---+----------------------
|
|
||||||
6 | 666
|
|
||||||
7 | aaa
|
|
||||||
8 | bbb
|
|
||||||
9 | bbb
|
|
||||||
(4 rows)
|
|
||||||
|
|
||||||
SELECT *
|
|
||||||
FROM test
|
|
||||||
WHERE a > 9
|
|
||||||
ORDER BY a ;
|
|
||||||
a | b
|
|
||||||
---+---
|
|
||||||
(0 rows)
|
|
||||||
|
|
||||||
-- SELECT without constants
|
|
||||||
SELECT * FROM test ORDER BY a;
|
|
||||||
a | b
|
|
||||||
---+----------------------
|
|
||||||
1 | a
|
|
||||||
1 | 111
|
|
||||||
2 | b
|
|
||||||
2 | 222
|
|
||||||
3 | c
|
|
||||||
3 | 333
|
|
||||||
4 | 444
|
|
||||||
5 | 555
|
|
||||||
6 | 666
|
|
||||||
7 | aaa
|
|
||||||
8 | bbb
|
|
||||||
9 | bbb
|
|
||||||
(12 rows)
|
|
||||||
|
|
||||||
-- SELECT with IN clause
|
|
||||||
SELECT * FROM test WHERE a IN (1, 2, 3, 4, 5);
|
|
||||||
a | b
|
|
||||||
---+----------------------
|
|
||||||
1 | 111
|
|
||||||
2 | 222
|
|
||||||
3 | 333
|
|
||||||
4 | 444
|
|
||||||
5 | 555
|
|
||||||
1 | a
|
|
||||||
2 | b
|
|
||||||
3 | c
|
|
||||||
(8 rows)
|
|
||||||
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | rows
|
|
||||||
---------------------------------------------------------------------------+-------+------
|
|
||||||
BEGIN | 3 | 0
|
|
||||||
COMMIT | 3 | 0
|
|
||||||
CREATE TEMP TABLE test (a int, b char(20)) | 1 | 0
|
|
||||||
DELETE FROM test WHERE a > $1 | 1 | 1
|
|
||||||
INSERT INTO test (a, b) VALUES ($1, $2), ($3, $4), ($5, $6) | 1 | 3
|
|
||||||
INSERT INTO test VALUES(generate_series($1, $2), $3) | 1 | 10
|
|
||||||
SELECT * FROM test ORDER BY a | 1 | 12
|
|
||||||
SELECT * FROM test WHERE a > $1 ORDER BY a | 2 | 4
|
|
||||||
SELECT * FROM test WHERE a IN ($1, $2, $3, $4, $5) | 1 | 8
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
|
||||||
UPDATE test SET b = $1 WHERE a = $2 | 6 | 6
|
|
||||||
UPDATE test SET b = $1 WHERE a > $2 | 1 | 3
|
|
||||||
(13 rows)
|
|
||||||
|
|
||||||
--
|
|
||||||
-- pg_stat_monitor.track = none
|
|
||||||
--
|
|
||||||
SET pg_stat_monitor.track = 'none';
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 1 AS "one";
|
|
||||||
one
|
|
||||||
-----
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 1 + 1 AS "two";
|
|
||||||
two
|
|
||||||
-----
|
|
||||||
2
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | rows
|
|
||||||
---------------------------------------------------------------------------+-------+------
|
|
||||||
SELECT $1 | 1 | 1
|
|
||||||
SELECT $1 + $2 | 1 | 1
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
|
||||||
(4 rows)
|
|
||||||
|
|
||||||
--
|
|
||||||
-- pg_stat_monitor.track = top
|
|
||||||
--
|
|
||||||
SET pg_stat_monitor.track = 'top';
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DO LANGUAGE plpgsql $$
|
|
||||||
BEGIN
|
|
||||||
-- this is a SELECT
|
|
||||||
PERFORM 'hello world'::TEXT;
|
|
||||||
END;
|
|
||||||
$$;
|
|
||||||
-- PL/pgSQL function
|
|
||||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$
|
|
||||||
DECLARE
|
|
||||||
r INTEGER;
|
|
||||||
BEGIN
|
|
||||||
SELECT (i + 1 + 1.0)::INTEGER INTO r;
|
|
||||||
RETURN r;
|
|
||||||
END; $$ LANGUAGE plpgsql;
|
|
||||||
SELECT PLUS_TWO(3);
|
|
||||||
plus_two
|
|
||||||
----------
|
|
||||||
5
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT PLUS_TWO(7);
|
|
||||||
plus_two
|
|
||||||
----------
|
|
||||||
9
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- SQL function --- use LIMIT to keep it from being inlined
|
|
||||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS
|
|
||||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
|
|
||||||
SELECT PLUS_ONE(8);
|
|
||||||
plus_one
|
|
||||||
----------
|
|
||||||
9
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT PLUS_ONE(10);
|
|
||||||
plus_one
|
|
||||||
----------
|
|
||||||
11
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | rows
|
|
||||||
---------------------------------------------------------------------------+-------+------
|
|
||||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS +| 1 | 0
|
|
||||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL | |
|
|
||||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$ +| 1 | 0
|
|
||||||
DECLARE +| |
|
|
||||||
r INTEGER; +| |
|
|
||||||
BEGIN +| |
|
|
||||||
SELECT (i + 1 + 1.0)::INTEGER INTO r; +| |
|
|
||||||
RETURN r; +| |
|
|
||||||
END; $$ LANGUAGE plpgsql | |
|
|
||||||
DO LANGUAGE plpgsql $$ +| 1 | 0
|
|
||||||
BEGIN +| |
|
|
||||||
-- this is a SELECT +| |
|
|
||||||
PERFORM 'hello world'::TEXT; +| |
|
|
||||||
END; +| |
|
|
||||||
$$ | |
|
|
||||||
SELECT $1 +| 1 | 1
|
|
||||||
+| |
|
|
||||||
AS "text" | |
|
|
||||||
SELECT (i + $2 + $3)::INTEGER | 2 | 2
|
|
||||||
SELECT (i + $2)::INTEGER LIMIT $3 | 2 | 2
|
|
||||||
SELECT PLUS_ONE($1) | 2 | 2
|
|
||||||
SELECT PLUS_TWO($1) | 2 | 2
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
|
||||||
(10 rows)
|
|
||||||
|
|
||||||
--
|
|
||||||
-- pg_stat_monitor.track = all
|
|
||||||
--
|
|
||||||
SET pg_stat_monitor.track = 'all';
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- we drop and recreate the functions to avoid any caching funnies
|
|
||||||
DROP FUNCTION PLUS_ONE(INTEGER);
|
|
||||||
DROP FUNCTION PLUS_TWO(INTEGER);
|
|
||||||
-- PL/pgSQL function
|
|
||||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$
|
|
||||||
DECLARE
|
|
||||||
r INTEGER;
|
|
||||||
BEGIN
|
|
||||||
SELECT (i + 1 + 1.0)::INTEGER INTO r;
|
|
||||||
RETURN r;
|
|
||||||
END; $$ LANGUAGE plpgsql;
|
|
||||||
SELECT PLUS_TWO(-1);
|
|
||||||
plus_two
|
|
||||||
----------
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT PLUS_TWO(2);
|
|
||||||
plus_two
|
|
||||||
----------
|
|
||||||
4
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- SQL function --- use LIMIT to keep it from being inlined
|
|
||||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS
|
|
||||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
|
|
||||||
SELECT PLUS_ONE(3);
|
|
||||||
plus_one
|
|
||||||
----------
|
|
||||||
4
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT PLUS_ONE(1);
|
|
||||||
plus_one
|
|
||||||
----------
|
|
||||||
2
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | rows
|
|
||||||
---------------------------------------------------------------------------+-------+------
|
|
||||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS +| 1 | 0
|
|
||||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL | |
|
|
||||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$ +| 1 | 0
|
|
||||||
DECLARE +| |
|
|
||||||
r INTEGER; +| |
|
|
||||||
BEGIN +| |
|
|
||||||
SELECT (i + 1 + 1.0)::INTEGER INTO r; +| |
|
|
||||||
RETURN r; +| |
|
|
||||||
END; $$ LANGUAGE plpgsql | |
|
|
||||||
DROP FUNCTION PLUS_ONE(INTEGER) | 1 | 0
|
|
||||||
DROP FUNCTION PLUS_TWO(INTEGER) | 1 | 0
|
|
||||||
SELECT (i + $2 + $3)::INTEGER | 2 | 2
|
|
||||||
SELECT (i + $2)::INTEGER LIMIT $3 | 2 | 2
|
|
||||||
SELECT PLUS_ONE($1) | 2 | 2
|
|
||||||
SELECT PLUS_TWO($1) | 2 | 2
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
|
||||||
(10 rows)
|
|
||||||
|
|
||||||
--
|
|
||||||
-- utility commands
|
|
||||||
--
|
|
||||||
SET pg_stat_monitor.track_utility = TRUE;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 1;
|
|
||||||
?column?
|
|
||||||
----------
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE INDEX test_b ON test(b);
|
|
||||||
DROP TABLE test \;
|
|
||||||
DROP TABLE IF EXISTS test \;
|
|
||||||
DROP FUNCTION PLUS_ONE(INTEGER);
|
|
||||||
NOTICE: table "test" does not exist, skipping
|
|
||||||
DROP TABLE IF EXISTS test \;
|
|
||||||
DROP TABLE IF EXISTS test \;
|
|
||||||
DROP FUNCTION IF EXISTS PLUS_ONE(INTEGER);
|
|
||||||
NOTICE: table "test" does not exist, skipping
|
|
||||||
NOTICE: table "test" does not exist, skipping
|
|
||||||
NOTICE: function plus_one(pg_catalog.int4) does not exist, skipping
|
|
||||||
DROP FUNCTION PLUS_TWO(INTEGER);
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | calls | rows
|
|
||||||
---------------------------------------------------------------------------+-------+------
|
|
||||||
CREATE INDEX test_b ON test(b) | 1 | 0
|
|
||||||
DROP FUNCTION IF EXISTS PLUS_ONE(INTEGER) | 1 | 0
|
|
||||||
DROP FUNCTION PLUS_ONE(INTEGER) | 1 | 0
|
|
||||||
DROP FUNCTION PLUS_TWO(INTEGER) | 1 | 0
|
|
||||||
DROP TABLE IF EXISTS test | 3 | 0
|
|
||||||
DROP TABLE test | 1 | 0
|
|
||||||
SELECT $1 | 1 | 1
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
|
||||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
|
||||||
(9 rows)
|
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,31 +0,0 @@
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 1;
|
|
||||||
?column?
|
|
||||||
----------
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 1/0; -- divide by zero
|
|
||||||
ERROR: division by zero
|
|
||||||
SELECT query, state_code, state FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
query | state_code | state
|
|
||||||
---------------------------------------------------------------------------------+------------+---------------------
|
|
||||||
SELECT $1 | 3 | FINISHED
|
|
||||||
SELECT 1/0; | 4 | FINISHED WITH ERROR
|
|
||||||
SELECT pg_stat_monitor_reset() | 3 | FINISHED
|
|
||||||
SELECT query, state_code, state FROM pg_stat_monitor ORDER BY query COLLATE "C" | 2 | ACTIVE
|
|
||||||
(4 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
|
@ -25,23 +25,11 @@ SELECT add2(1,2);
|
||||||
|
|
||||||
SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
query | top_query
|
query | top_query
|
||||||
-------------------------------------------------------------------------+------------------
|
--------------------------------+------------------
|
||||||
CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS +|
|
(select $1 + $2) | SELECT add2(1,2)
|
||||||
$$ +|
|
|
||||||
BEGIN +|
|
|
||||||
return (select $1 + $2); +|
|
|
||||||
END; $$ language plpgsql |
|
|
||||||
CREATE OR REPLACE function add2(int, int) RETURNS int as +|
|
|
||||||
$$ +|
|
|
||||||
BEGIN +|
|
|
||||||
return add($1,$2); +|
|
|
||||||
END; +|
|
|
||||||
$$ language plpgsql |
|
|
||||||
SELECT (select $1 + $2) | SELECT add2(1,2)
|
|
||||||
SELECT add2(1,2) |
|
SELECT add2(1,2) |
|
||||||
SELECT pg_stat_monitor_reset() |
|
SELECT pg_stat_monitor_reset() |
|
||||||
SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C" |
|
(3 rows)
|
||||||
(6 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
CREATE USER su WITH SUPERUSER;
|
|
||||||
ERROR: role "su" already exists
|
|
||||||
SET ROLE su;
|
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
CREATE USER u1;
|
|
||||||
CREATE USER u2;
|
|
||||||
SET ROLE su;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SET ROLE u1;
|
|
||||||
CREATE TABLE t1 (a int);
|
|
||||||
SELECT * FROM t1;
|
|
||||||
a
|
|
||||||
---
|
|
||||||
(0 rows)
|
|
||||||
|
|
||||||
SET ROLE u2;
|
|
||||||
CREATE TABLE t2 (a int);
|
|
||||||
SELECT * FROM t2;
|
|
||||||
a
|
|
||||||
---
|
|
||||||
(0 rows)
|
|
||||||
|
|
||||||
SET ROLE su;
|
|
||||||
SELECT userid, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|
||||||
userid | query
|
|
||||||
--------+---------------------------------
|
|
||||||
u1 | CREATE TABLE t1 (a int);
|
|
||||||
u2 | CREATE TABLE t2 (a int);
|
|
||||||
u1 | SELECT * FROM t1;
|
|
||||||
u2 | SELECT * FROM t2;
|
|
||||||
su | SELECT pg_stat_monitor_reset();
|
|
||||||
su | SET ROLE su;
|
|
||||||
u1 | SET ROLE u1;
|
|
||||||
u2 | SET ROLE u2;
|
|
||||||
(8 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DROP TABLE t1;
|
|
||||||
DROP TABLE t2;
|
|
||||||
DROP USER u1;
|
|
||||||
DROP USER u2;
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
|
@ -1,6 +1,6 @@
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
select pg_sleep(.5);
|
select pg_sleep(.5);
|
||||||
SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C";
|
SELECT * FROM pg_stat_monitor_settings WHERE name NOT LIKE 'pg_stat_monitor.pgsm_track_planning' ORDER BY name COLLATE "C";
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
DROP EXTENSION pg_stat_monitor;
|
DROP EXTENSION pg_stat_monitor;
|
||||||
|
|
|
@ -5,128 +5,40 @@ SELECT pg_stat_monitor_reset();
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT * from pg_stat_monitor_settings;
|
SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_track_planning';
|
||||||
name | value | default_value | description | minimum | maximum | options | restart
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
-------------------------------------+-------+---------------+--------------------------------------------------+---------+---------+---------+---------
|
||||||
pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_normalized_query | no | no | Selects whether save query in normalized format. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
|
||||||
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
|
||||||
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
|
||||||
pg_stat_monitor.pgsm_extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_track_planning | yes | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
pg_stat_monitor.pgsm_track_planning | yes | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
(15 rows)
|
(1 row)
|
||||||
|
|
||||||
SELECT * from pg_stat_monitor_settings;
|
SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_track_planning';
|
||||||
name | value | default_value | description | minimum | maximum | options | restart
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
-------------------------------------+-------+---------------+--------------------------------------------------+---------+---------+---------+---------
|
||||||
pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_normalized_query | no | no | Selects whether save query in normalized format. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
|
||||||
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
|
||||||
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
|
||||||
pg_stat_monitor.pgsm_extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_track_planning | yes | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
pg_stat_monitor.pgsm_track_planning | yes | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
(15 rows)
|
(1 row)
|
||||||
|
|
||||||
SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor;
|
SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor;
|
||||||
query | calls | total_plan_time | min_plan_time | max_plan_time | mean_plan_time | stddev_plan_time
|
select substr(query, 0,100) as query, calls, total_plan_time, min_plan_time,max_plan_time,mean_plan_time,stddev_plan_time from pg_stat_monitor order by query;
|
||||||
---------------------------------------------------------------------------------------------------------------------------+-------+-----------------+---------------+---------------+----------------+------------------
|
|
||||||
SELECT * from pg_stat_monitor_settings | 2 | 0.2432 | 0.1214 | 0.1219 | 0.1216 | 0.0002
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor | 1 | 1.4538 | 1.4538 | 1.4538 | 1.4538 | 0
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT * from pg_stat_monitor_settings;
|
SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_track_planning';
|
||||||
name | value | default_value | description | minimum | maximum | options | restart
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
-------------------------------------+-------+---------------+--------------------------------------------------+---------+---------+---------+---------
|
||||||
pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_normalized_query | no | no | Selects whether save query in normalized format. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
|
||||||
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
|
||||||
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
|
||||||
pg_stat_monitor.pgsm_extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
(15 rows)
|
(1 row)
|
||||||
|
|
||||||
SELECT * from pg_stat_monitor_settings;
|
SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_track_planning';
|
||||||
name | value | default_value | description | minimum | maximum | options | restart
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
-------------------------------------+-------+---------------+--------------------------------------------------+---------+---------+---------+---------
|
||||||
pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_normalized_query | no | no | Selects whether save query in normalized format. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
|
||||||
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
|
||||||
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes
|
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
|
||||||
pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
|
||||||
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
|
||||||
pg_stat_monitor.pgsm_extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
|
||||||
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
(15 rows)
|
(1 row)
|
||||||
|
|
||||||
SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor;
|
SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor;
|
||||||
query | calls | total_plan_time | min_plan_time | max_plan_time | mean_plan_time | stddev_plan_time
|
|
||||||
---------------------------------------------------------------------------------------------------------------------------+-------+-----------------+---------------+---------------+----------------+------------------
|
|
||||||
<<<<<<< HEAD
|
|
||||||
SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
SELECT * from pg_stat_monitor_settings | 2 | 0 | 0 | 0 | 0 | 0
|
|
||||||
=======
|
|
||||||
SELECT * from pg_stat_monitor_settings | 2 | 0 | 0 | 0 | 0 | 0
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
>>>>>>> origin/REL_1_STABLE
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
select substr(query, 0,100) as query, calls, total_plan_time, min_plan_time,max_plan_time,mean_plan_time,stddev_plan_time from pg_stat_monitor order by query;
|
select substr(query, 0,100) as query, calls, total_plan_time, min_plan_time,max_plan_time,mean_plan_time,stddev_plan_time from pg_stat_monitor order by query;
|
||||||
query | calls | total_plan_time | min_plan_time | max_plan_time | mean_plan_time | stddev_plan_time
|
|
||||||
-----------------------------------------------------------------------------------------------------+-------+-----------------+---------------+---------------+----------------+------------------
|
|
||||||
SELECT * from pg_stat_monitor_settings | 2 | 0 | 0 | 0 | 0 | 0
|
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_tim | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
select (max_plan_time = 0) from pg_stat_monitor where calls = 2 | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
select (mean_plan_time = 0) from pg_stat_monitor where calls = 2 | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
select (min_plan_time = 0) from pg_stat_monitor where calls = 2 | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
select (stddev_plan_time = 0) from pg_stat_monitor where calls = 2 | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
select (total_plan_time = 0) from pg_stat_monitor where calls = 2 | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
select substr(query, 0,100) as query, calls, total_plan_time, min_plan_time,max_plan_time,mean_plan | 1 | 0 | 0 | 0 | 0 | 0
|
|
||||||
(9 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
|
@ -23,8 +23,7 @@ SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_extract_comments' |
|
SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_extract_comments' |
|
||||||
SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/ | /* First comment */, /* Second comment*/
|
SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/ | /* First comment */, /* Second comment*/
|
||||||
SELECT pg_stat_monitor_reset() |
|
SELECT pg_stat_monitor_reset() |
|
||||||
SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C" |
|
(3 rows)
|
||||||
(4 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
|
@ -50,7 +49,6 @@ SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_extract_comments' |
|
SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_extract_comments' |
|
||||||
SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/ |
|
SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/ |
|
||||||
SELECT pg_stat_monitor_reset() |
|
SELECT pg_stat_monitor_reset() |
|
||||||
SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C" |
|
(3 rows)
|
||||||
(4 rows)
|
|
||||||
|
|
||||||
Drop extension pg_stat_monitor;
|
Drop extension pg_stat_monitor;
|
||||||
|
|
|
@ -75,7 +75,6 @@ select substr(query, 0,50) as query, calls, query_plan from pg_stat_monitor orde
|
||||||
SELECT key, txt_0, value_0 FROM TBL_0 | 2 |
|
SELECT key, txt_0, value_0 FROM TBL_0 | 2 |
|
||||||
SELECT pg_stat_monitor_reset() | 1 |
|
SELECT pg_stat_monitor_reset() | 1 |
|
||||||
UPDATE TBL_0 SET value_0 = 1681692777 | 1 |
|
UPDATE TBL_0 SET value_0 = 1681692777 | 1 |
|
||||||
select substr(query, 0,50) as query, calls, query | 1 |
|
(6 rows)
|
||||||
(7 rows)
|
|
||||||
|
|
||||||
Drop extension pg_stat_monitor;
|
Drop extension pg_stat_monitor;
|
||||||
|
|
|
@ -1,114 +0,0 @@
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_shared_buffer';
|
|
||||||
name | value | default_value | description | minimum | maximum | options | restart
|
|
||||||
------------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+---------+---------+---------+---------
|
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 1 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE database example;
|
|
||||||
select datname, substr(query,0,150) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
|
||||||
datname | query | calls
|
|
||||||
---------+---------------------------------------------------------------------------------------------------------------+-------
|
|
||||||
example | BEGIN | 10000
|
|
||||||
example | END | 10000
|
|
||||||
example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000
|
|
||||||
example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000
|
|
||||||
example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000
|
|
||||||
example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000
|
|
||||||
example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000
|
|
||||||
example | alter table pgbench_accounts add primary key (aid) | 1
|
|
||||||
example | alter table pgbench_branches add primary key (bid) | 1
|
|
||||||
example | alter table pgbench_tellers add primary key (tid) | 1
|
|
||||||
example | begin | 1
|
|
||||||
example | commit | 1
|
|
||||||
example | copy pgbench_accounts from stdin | 1
|
|
||||||
example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1
|
|
||||||
example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1
|
|
||||||
example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1
|
|
||||||
example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1
|
|
||||||
example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1
|
|
||||||
example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 100
|
|
||||||
example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 1000
|
|
||||||
(20 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_shared_buffer';
|
|
||||||
name | value | default_value | description | minimum | maximum | options | restart
|
|
||||||
------------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+---------+---------+---------+---------
|
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 100 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
select datname, substr(query,0,150) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
|
||||||
datname | query | calls
|
|
||||||
---------+---------------------------------------------------------------------------------------------------------------+-------
|
|
||||||
example | BEGIN | 10000
|
|
||||||
example | END | 10000
|
|
||||||
example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000
|
|
||||||
example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000
|
|
||||||
example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000
|
|
||||||
example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000
|
|
||||||
example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000
|
|
||||||
example | alter table pgbench_accounts add primary key (aid) | 1
|
|
||||||
example | alter table pgbench_branches add primary key (bid) | 1
|
|
||||||
example | alter table pgbench_tellers add primary key (tid) | 1
|
|
||||||
example | begin | 1
|
|
||||||
example | commit | 1
|
|
||||||
example | copy pgbench_accounts from stdin | 1
|
|
||||||
example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1
|
|
||||||
example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1
|
|
||||||
example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1
|
|
||||||
example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1
|
|
||||||
example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1
|
|
||||||
example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 100
|
|
||||||
example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 1000
|
|
||||||
(20 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_shared_buffer';
|
|
||||||
name | value | default_value | description | minimum | maximum | options | restart
|
|
||||||
------------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+---------+---------+---------+---------
|
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
select datname, substr(query,0,150) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
|
||||||
datname | query | calls
|
|
||||||
---------+---------------------------------------------------------------------------------------------------------------+-------
|
|
||||||
example | BEGIN | 10000
|
|
||||||
example | END | 10000
|
|
||||||
example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000
|
|
||||||
example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000
|
|
||||||
example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000
|
|
||||||
example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000
|
|
||||||
example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000
|
|
||||||
example | alter table pgbench_accounts add primary key (aid) | 1
|
|
||||||
example | alter table pgbench_branches add primary key (bid) | 1
|
|
||||||
example | alter table pgbench_tellers add primary key (tid) | 1
|
|
||||||
example | begin | 1
|
|
||||||
example | commit | 1
|
|
||||||
example | copy pgbench_accounts from stdin | 1
|
|
||||||
example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1
|
|
||||||
example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1
|
|
||||||
example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1
|
|
||||||
example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1
|
|
||||||
example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1
|
|
||||||
example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 100
|
|
||||||
example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 1000
|
|
||||||
(20 rows)
|
|
||||||
|
|
||||||
Drop extension pg_stat_monitor;
|
|
|
@ -28,15 +28,14 @@ SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
UPDATE TBL_0 SET value_0 = 1681692777;
|
UPDATE TBL_0 SET value_0 = 1681692777;
|
||||||
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
||||||
datname | query | calls
|
datname | query | calls
|
||||||
----------+-----------------------------------------------------------------------------------------------------+-------
|
----------+-------------------------------------------------------------------------------------------+-------
|
||||||
postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1
|
postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1
|
||||||
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383) | 1
|
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383) | 1
|
||||||
postgres | SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_normalized_query' | 1
|
postgres | SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_normalized_query' | 1
|
||||||
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
||||||
postgres | SELECT pg_stat_monitor_reset() | 1
|
postgres | SELECT pg_stat_monitor_reset() | 1
|
||||||
postgres | UPDATE TBL_0 SET value_0 = 1681692777 | 1
|
postgres | UPDATE TBL_0 SET value_0 = 1681692777 | 1
|
||||||
postgres | select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, c | 1
|
(6 rows)
|
||||||
(7 rows)
|
|
||||||
|
|
||||||
Drop TABLE TBL_0;
|
Drop TABLE TBL_0;
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
|
@ -68,14 +67,13 @@ SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
UPDATE TBL_0 SET value_0 = 1681692777;
|
UPDATE TBL_0 SET value_0 = 1681692777;
|
||||||
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
||||||
datname | query | calls
|
datname | query | calls
|
||||||
----------+-----------------------------------------------------------------------------------------------------+-------
|
----------+-------------------------------------------------------------------------------------------+-------
|
||||||
postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1
|
postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1
|
||||||
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES($1, $2, $3) | 1
|
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383) | 1
|
||||||
postgres | SELECT * from pg_stat_monitor_settings where name=$1 | 1
|
postgres | SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_normalized_query' | 1
|
||||||
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
||||||
postgres | SELECT pg_stat_monitor_reset() | 1
|
postgres | SELECT pg_stat_monitor_reset() | 1
|
||||||
postgres | UPDATE TBL_0 SET value_0 = $1 | 1
|
postgres | UPDATE TBL_0 SET value_0 = 1681692777 | 1
|
||||||
postgres | select datname, substr(query,$1,$2) as query, calls from pg_stat_monitor order by datname, query, c | 1
|
(6 rows)
|
||||||
(7 rows)
|
|
||||||
|
|
||||||
Drop extension pg_stat_monitor;
|
Drop extension pg_stat_monitor;
|
||||||
|
|
|
@ -30,14 +30,13 @@ Analyze TBL_0;
|
||||||
DROP TABLE TBL_0;
|
DROP TABLE TBL_0;
|
||||||
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
||||||
datname | query | calls
|
datname | query | calls
|
||||||
----------+-----------------------------------------------------------------------------------------------------+-------
|
----------+----------------------------------------------------------------------------------------+-------
|
||||||
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383) | 1
|
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383) | 1
|
||||||
postgres | SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track_utility' | 1
|
postgres | SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track_utility' | 1
|
||||||
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
||||||
postgres | SELECT pg_stat_monitor_reset() | 1
|
postgres | SELECT pg_stat_monitor_reset() | 1
|
||||||
postgres | UPDATE TBL_0 SET value_0 = 1681692777 | 1
|
postgres | UPDATE TBL_0 SET value_0 = 1681692777 | 1
|
||||||
postgres | select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, c | 1
|
(5 rows)
|
||||||
(6 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
|
@ -70,7 +69,7 @@ Analyze TBL_0;
|
||||||
DROP TABLE TBL_0;
|
DROP TABLE TBL_0;
|
||||||
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
||||||
datname | query | calls
|
datname | query | calls
|
||||||
----------+-----------------------------------------------------------------------------------------------------+-------
|
----------+----------------------------------------------------------------------------------------+-------
|
||||||
postgres | Analyze TBL_0 | 1
|
postgres | Analyze TBL_0 | 1
|
||||||
postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1
|
postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1
|
||||||
postgres | DROP TABLE TBL_0 | 1
|
postgres | DROP TABLE TBL_0 | 1
|
||||||
|
@ -79,7 +78,6 @@ select datname, substr(query,0,100) as query, calls from pg_stat_monitor order b
|
||||||
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
||||||
postgres | SELECT pg_stat_monitor_reset() | 1
|
postgres | SELECT pg_stat_monitor_reset() | 1
|
||||||
postgres | UPDATE TBL_0 SET value_0 = 1681692777 | 1
|
postgres | UPDATE TBL_0 SET value_0 = 1681692777 | 1
|
||||||
postgres | select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, c | 1
|
(8 rows)
|
||||||
(9 rows)
|
|
||||||
|
|
||||||
Drop extension pg_stat_monitor;
|
Drop extension pg_stat_monitor;
|
||||||
|
|
Loading…
Reference in New Issue