diff --git a/regression/expected/error_1.out b/regression/expected/error_1.out index 7a61786..2e3d8fa 100644 --- a/regression/expected/error_1.out +++ b/regression/expected/error_1.out @@ -23,9 +23,9 @@ WARNING: warning message SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel; query | elevel | sqlcode | message -----------------------------------------------------------------------------------------------+--------+---------+----------------------------------- - ELECET * FROM unknown; | 21 | 42601 | syntax error at or near "ELECET" - SELECT * FROM unknown; | 21 | 42P01 | relation "unknown" does not exist - SELECT 1/0; | 21 | 22012 | division by zero + ELECET * FROM unknown; | 20 | 42601 | syntax error at or near "ELECET" + SELECT * FROM unknown; | 20 | 42P01 | relation "unknown" does not exist + SELECT 1/0; | 20 | 22012 | division by zero SELECT pg_stat_monitor_reset() | 0 | | SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel | 0 | | do $$ +| 0 | | diff --git a/regression/expected/error_insert_1.out b/regression/expected/error_insert_1.out index 708dab3..b3833fe 100644 --- a/regression/expected/error_insert_1.out +++ b/regression/expected/error_insert_1.out @@ -20,7 +20,7 @@ SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLA query | elevel | sqlcode | message -----------------------------------------------------------------------------------------------+--------+---------+--------------------------------------------------------------- Drop Table if exists Company | 0 | | - INSERT INTO Company(ID, Name) VALUES ($1, $2) | 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" SELECT pg_stat_monitor_reset() | 0 | | SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel | 0 | | diff --git a/regression/expected/guc_1.out b/regression/expected/guc_1.out index d2c23fa..b91d00e 100644 --- a/regression/expected/guc_1.out +++ b/regression/expected/guc_1.out @@ -22,7 +22,7 @@ SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C"; 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 | yes | yes | Selects whether save query in normalized format. | | | 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_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 diff --git a/regression/expected/histogram_2.out b/regression/expected/histogram_2.out new file mode 100644 index 0000000..7f40b6c --- /dev/null +++ b/regression/expected/histogram_2.out @@ -0,0 +1,73 @@ +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,3,1,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 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)} | 1 | ■■■■■■■■■■ + (10000 - 31622)} | 0 | + (31622 - 100000)} | 0 | +(10 rows) + +DROP EXTENSION pg_stat_monitor; diff --git a/regression/expected/tags.out b/regression/expected/tags.out index 6fd2de5..76a1ff4 100644 --- a/regression/expected/tags.out +++ b/regression/expected/tags.out @@ -1,4 +1,5 @@ CREATE EXTENSION pg_stat_monitor; +Set pg_stat_monitor.pgsm_extract_comments = 'yes'; SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset ----------------------- diff --git a/regression/expected/top_query_1.out b/regression/expected/top_query_1.out index 8ab9932..2d5ebfc 100644 --- a/regression/expected/top_query_1.out +++ b/regression/expected/top_query_1.out @@ -24,8 +24,8 @@ SELECT add2(1,2); (1 row) 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 +| $$ +| BEGIN +| @@ -37,8 +37,8 @@ SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C"; return add($1,$2); +| END; +| $$ language plpgsql | - SELECT (select $1 + $2) | SELECT add2($1,$2) - SELECT add2($1,$2) | + SELECT (select $1 + $2) | SELECT add2(1,2) + SELECT add2(1,2) | SELECT pg_stat_monitor_reset() | SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C" | (6 rows) diff --git a/regression/sql/tags.sql b/regression/sql/tags.sql index 8325598..6ba919c 100644 --- a/regression/sql/tags.sql +++ b/regression/sql/tags.sql @@ -1,4 +1,5 @@ CREATE EXTENSION pg_stat_monitor; +Set pg_stat_monitor.pgsm_extract_comments = 'yes'; SELECT pg_stat_monitor_reset(); SELECT 1 AS num /* { "application", psql_app, "real_ip", 192.168.1.3) */; SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; diff --git a/t/0001_settings_pgsm_track_planning.pl b/t/0001_settings_pgsm_track_planning.pl new file mode 100644 index 0000000..f236588 --- /dev/null +++ b/t/0001_settings_pgsm_track_planning.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl + +use String::Util qw(trim); +use File::Basename; +use File::Compare; +use Test::More; + +use lib 't'; +use pgsm; + +sub check_value +{ + my ($var, $postive, $expected, $val) = @_; + if ($postive) + { + is($expected, $val, "Checking $var..."); + } + else + { + isnt($expected, $val, "Checking $var..."); + } +} + +sub do_testing +{ + my ($expected, $postive) = @_; + my ($cmdret, $stdout, $stderr) = pgsm_psql_cmd('postgres', 'SELECT max(total_plan_time) FROM pg_stat_monitor;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); + my $total_plan_time = trim($stdout); + + ($cmdret, $stdout, $stderr) = pgsm_psql_cmd('postgres', 'SELECT max(min_plan_time) FROM pg_stat_monitor;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); + my $min_plan_time = trim($stdout); + + ($cmdret, $stdout, $stderr) = pgsm_psql_cmd('postgres', 'SELECT max(max_plan_time) FROM pg_stat_monitor;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); + my $max_plan_time = trim($stdout); + + ($cmdret, $stdout, $stderr) = pgsm_psql_cmd('postgres', 'SELECT max(mean_plan_time) FROM pg_stat_monitor;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); + my $mean_plan_time = trim($stdout); + + ($cmdret, $stdout, $stderr) = pgsm_psql_cmd('postgres', 'SELECT max(stddev_plan_time) FROM pg_stat_monitor;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); + my $stddev_plan_time = trim($stdout); + + check_value("pgsm_track_planning", $postive, $expected, $total_plan_time + $min_plan_time + $max_plan_time + $stddev_plan_time); + return ($cmdret, $stdout, $stderr); +} + +sub do_regression +{ + my ($postive, $expected, $set) = @_; + ($cmdret, $stdout, $stderr) = pgsm_setup_pg_stat_monitor($set); + ($cmdret, $stdout, $stderr) = pgsm_start_pg; + ($cmdret, $stdout, $stderr) = pgsm_create_extension; + + ($cmdret, $stdout, $stderr) = do_testing($postive, $expected); + ok($cmdret == 0, "Checking final result ..."); + + ($cmdret, $stdout, $stderr) = pgsm_drop_extension; + ($cmdret, $stdout, $stderr) = pgsm_stop_pg; +} + +($cmdret, $stdout, $stderr) = pgsm_init_pg; +do_regression(1, 0, "pg_stat_monitor.pgsm_track_planning = 'no'"); +do_regression(0, 0, "pg_stat_monitor.pgsm_track_planning = 'yes'"); + +($cmdret, $stdout, $stderr) = done_testing(); + diff --git a/t/0002_settings_pgsm_enable_query_plan.pl b/t/0002_settings_pgsm_enable_query_plan.pl new file mode 100644 index 0000000..90c1265 --- /dev/null +++ b/t/0002_settings_pgsm_enable_query_plan.pl @@ -0,0 +1,54 @@ +#!/usr/bin/perl + +use warnings; +use String::Util qw(trim); +use File::Basename; +use File::Compare; +use Test::More; + +use lib 't'; +use pgsm; + +sub check_value +{ + my ($var, $postive, $expected, $val) = @_; + trim($val); + if ($postive) + { + is($expected, $val, "Checking $var..."); + } + else + { + isnt($expected, $val, "Checking $var..."); + } +} + +sub do_testing +{ + my ($expected, $postive) = @_; + ($cmdret, $stdout, $stderr) = pgsm_psql_cmd('postgres', "select * from pg_class;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); + my ($cmdret, $stdout, $stderr) = pgsm_psql_cmd('postgres', "SELECT case WHEN query_plan LIKE 'Seq Scan on pg_class' THEN 1 ELSE 0 END FROM pg_stat_monitor WHERE query LIKE 'select * from pg_class';", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); + check_value("query_plan", $postive, $expected, $stdout); + return ($cmdret, $stdout, $stderr); +} + +sub do_regression +{ + my ($postive, $expected, $set) = @_; + ($cmdret, $stdout, $stderr) = pgsm_setup_pg_stat_monitor($set); + ($cmdret, $stdout, $stderr) = pgsm_start_pg; + ($cmdret, $stdout, $stderr) = pgsm_create_extension; + + ($cmdret, $stdout, $stderr) = do_testing($postive, $expected); + ok($cmdret == 0, "Checking final result ..."); + + ($cmdret, $stdout, $stderr) = pgsm_drop_extension; + ($cmdret, $stdout, $stderr) = pgsm_stop_pg; +} + +($cmdret, $stdout, $stderr) = pgsm_init_pg; +do_regression(1, 0, "pg_stat_monitor.pgsm_enable_query_plan = 'no'"); +do_regression(1, 1, "pg_stat_monitor.pgsm_enable_query_plan = 'yes'"); + +($cmdret, $stdout, $stderr) = done_testing(); + diff --git a/t/001_settings_default.pl b/t/001_settings_default.pl index 27b9f45..7497ed5 100644 --- a/t/001_settings_default.pl +++ b/t/001_settings_default.pl @@ -81,19 +81,6 @@ TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -# Create example database and run pgbench init -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE database example;', extra_params => ['-a']); -ok($cmdret == 0, "Create Database example"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -my $port = $node->port; - -my $out = system ("pgbench -i -s 10 -p $port example"); -ok($cmdret == 0, "Perform pgbench init"); - -$out = system ("pgbench -c 10 -j 2 -t 1000 -p $port example"); -ok($cmdret == 0, "Run pgbench"); - ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Select XXX from pg_stat_monitor"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/002_settings_pgsm_track_planning.pl b/t/002_settings_pgsm_track_planning.pl index 53170f1..c660709 100644 --- a/t/002_settings_pgsm_track_planning.pl +++ b/t/002_settings_pgsm_track_planning.pl @@ -76,11 +76,11 @@ chmod(0640 , $out_filename_with_path) TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); # Run 'SELECT * from pg_stat_monitor_settings;' two times and dump output to out file -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_track_planning';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_track_planning';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -142,11 +142,11 @@ ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); # Run 'SELECT * from pg_stat_monitor_settings;' two times and dump output to out file -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_track_planning';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_track_planning';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -196,11 +196,5 @@ TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); # Stop the server $node->stop; -# compare the expected and out file -#my $compare = compare($expected_filename_with_path, $out_filename_with_path); - -# Test/check if expected and result/out file match. If Yes, test passes. -#is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match."); - # Done testing for this testcase file. done_testing(); diff --git a/t/003_settings_pgms_extract_comments.pl b/t/003_settings_pgms_extract_comments.pl index 8108a61..c7f8f48 100644 --- a/t/003_settings_pgms_extract_comments.pl +++ b/t/003_settings_pgms_extract_comments.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_extract_comments';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -91,7 +91,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_extract_comments';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -117,4 +117,3 @@ is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_wit # Done testing for this testcase file. done_testing(); - diff --git a/t/004_settings_pgsm_track.pl b/t/004_settings_pgsm_track.pl index 6593932..44cc7eb 100644 --- a/t/004_settings_pgsm_track.pl +++ b/t/004_settings_pgsm_track.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -84,7 +84,7 @@ TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track = 'all'\n"); $node->restart(); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -95,7 +95,7 @@ TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track = 'top'\n"); $node->restart(); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/005_settings_pgsm_enable_query_plan.pl b/t/005_settings_pgsm_enable_query_plan.pl index 1cb97ca..6c5c232 100644 --- a/t/005_settings_pgsm_enable_query_plan.pl +++ b/t/005_settings_pgsm_enable_query_plan.pl @@ -75,7 +75,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_enable_query_plan';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -114,7 +114,7 @@ TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_enable_query_plan';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/006_settings_pgsm_overflow_target.pl b/t/006_settings_pgsm_overflow_target.pl index fa4b55a..8f15c88 100644 --- a/t/006_settings_pgsm_overflow_target.pl +++ b/t/006_settings_pgsm_overflow_target.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_overflow_target';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -85,7 +85,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_overflow_target';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/007_settings_pgsm_query_shared_buffer.pl b/t/007_settings_pgsm_query_shared_buffer.pl old mode 100644 new mode 100755 index 2da1f6f..d4b8858 --- a/t/007_settings_pgsm_query_shared_buffer.pl +++ b/t/007_settings_pgsm_query_shared_buffer.pl @@ -55,7 +55,9 @@ $node->init; # Update postgresql.conf to include/load pg_stat_monitor library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_stat_monitor'\n"; +print $conf "pg_stat_monitor.pgsm_bucket_time = 300\n"; print $conf "pg_stat_monitor.pgsm_query_shared_buffer = 1\n"; +print $conf "pg_stat_monitor.pgsm_normalized_query = 'yes'\n"; close $conf; # Start server @@ -74,7 +76,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_shared_buffer';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -87,7 +89,7 @@ TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); my $port = $node->port; print "port $port \n"; -my $out = system ("pgbench -i -s 10 -p $port example"); +my $out = system ("pgbench -i -s 100 -p $port example"); print " out: $out \n" ; ok($cmdret == 0, "Perform pgbench init"); @@ -95,7 +97,7 @@ $out = system ("pgbench -c 10 -j 2 -t 1000 -p $port example"); print " out: $out \n" ; ok($cmdret == 0, "Run pgbench"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,150) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); print "cmdret $cmdret\n"; ok($cmdret == 0, "Select XXX from pg_stat_monitor"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -107,10 +109,23 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_shared_buffer';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); +$out = system ("pgbench -i -s 100 -p $port example"); +print " out: $out \n" ; +ok($cmdret == 0, "Perform pgbench init"); + +$out = system ("pgbench -c 10 -j 2 -t 1000 -p $port example"); +print " out: $out \n" ; +ok($cmdret == 0, "Run pgbench"); + +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,150) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +print "cmdret $cmdret\n"; +ok($cmdret == 0, "Select XXX from pg_stat_monitor"); +TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); + $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_shared_buffer = 20\n"); $node->restart(); @@ -118,10 +133,23 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_shared_buffer';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); +$out = system ("pgbench -i -s 100 -p $port example"); +print " out: $out \n" ; +ok($cmdret == 0, "Perform pgbench init"); + +$out = system ("pgbench -c 10 -j 2 -t 1000 -p $port example"); +print " out: $out \n" ; +ok($cmdret == 0, "Run pgbench"); + +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,150) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +print "cmdret $cmdret\n"; +ok($cmdret == 0, "Select XXX from pg_stat_monitor"); +TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); + # Drop extension $stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']); ok($cmdret == 0, "Drop PGSM Extension"); diff --git a/t/008_settings_pgsm_histogram_buckets.pl b/t/008_settings_pgsm_histogram_buckets.pl index 0106b35..c58bda0 100644 --- a/t/008_settings_pgsm_histogram_buckets.pl +++ b/t/008_settings_pgsm_histogram_buckets.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -85,7 +85,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -96,7 +96,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -107,7 +107,18 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +ok($cmdret == 0, "Print PGSM Extension Settings"); +TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); + +$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_buckets = 5\n"); +$node->restart(); + +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +ok($cmdret == 0, "Reset PGSM Extension"); +TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); + +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -118,7 +129,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/009_settings_pgsm_histogram_max.pl b/t/009_settings_pgsm_histogram_max.pl index ef52d54..f8de09d 100644 --- a/t/009_settings_pgsm_histogram_max.pl +++ b/t/009_settings_pgsm_histogram_max.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_max';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -85,7 +85,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_max';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -96,7 +96,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_max';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -107,7 +107,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_max';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/010_settings_pgsm_histogram_min.pl b/t/010_settings_pgsm_histogram_min.pl index 22b3197..11f9f5e 100644 --- a/t/010_settings_pgsm_histogram_min.pl +++ b/t/010_settings_pgsm_histogram_min.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_min';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -85,7 +85,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_min';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -96,7 +96,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_min';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -107,7 +107,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_min';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/011_settings_pgsm_bucket_time.pl b/t/011_settings_pgsm_bucket_time.pl index dcb9109..1d6e9f8 100644 --- a/t/011_settings_pgsm_bucket_time.pl +++ b/t/011_settings_pgsm_bucket_time.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -85,7 +85,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -96,7 +96,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -107,7 +107,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -118,7 +118,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -129,7 +129,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/012_settings_pgsm_max_buckets.pl b/t/012_settings_pgsm_max_buckets.pl index aee1afc..d1265f1 100644 --- a/t/012_settings_pgsm_max_buckets.pl +++ b/t/012_settings_pgsm_max_buckets.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -85,7 +85,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -96,7 +96,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -107,7 +107,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -118,7 +118,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -129,7 +129,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/013_settings_pgsm_normalized_query.pl b/t/013_settings_pgsm_normalized_query.pl index 8617392..e80115d 100644 --- a/t/013_settings_pgsm_normalized_query.pl +++ b/t/013_settings_pgsm_normalized_query.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_normalized_query';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -108,7 +108,7 @@ TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_normalized_query';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/014_settings_pgsm_track_utility.pl b/t/014_settings_pgsm_track_utility.pl index af6ff21..0675c30 100644 --- a/t/014_settings_pgsm_track_utility.pl +++ b/t/014_settings_pgsm_track_utility.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track_utility';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -110,7 +110,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track_utility';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/015_settings_pgsm_query_max_len.pl b/t/015_settings_pgsm_query_max_len.pl index 64555f3..a23d428 100644 --- a/t/015_settings_pgsm_query_max_len.pl +++ b/t/015_settings_pgsm_query_max_len.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -85,7 +85,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -96,7 +96,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -107,7 +107,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -118,7 +118,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/016_settings_pgsm_max.pl b/t/016_settings_pgsm_max.pl index 9ebcf45..6dca22d 100644 --- a/t/016_settings_pgsm_max.pl +++ b/t/016_settings_pgsm_max.pl @@ -74,7 +74,7 @@ chmod(0640 , $out_filename_with_path) ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -85,7 +85,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -96,7 +96,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -107,7 +107,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -118,7 +118,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/017_execution_stats.pl b/t/017_execution_stats.pl index 26325d6..dd454e2 100644 --- a/t/017_execution_stats.pl +++ b/t/017_execution_stats.pl @@ -145,11 +145,5 @@ TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); # Stop the server $node->stop; -# compare the expected and out file -#my $compare = compare($expected_filename_with_path, $out_filename_with_path); - -# Test/check if expected and result/out file match. If Yes, test passes. -#is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match."); - # Done testing for this testcase file. done_testing(); diff --git a/t/019_insufficient_shared_space.pl b/t/019_insufficient_shared_space.pl index 264040c..6e015f1 100644 --- a/t/019_insufficient_shared_space.pl +++ b/t/019_insufficient_shared_space.pl @@ -82,7 +82,7 @@ TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_overflow_target';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); @@ -105,7 +105,7 @@ $node->restart(); ok($cmdret == 0, "Reset PGSM Extension"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_overflow_target';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Print PGSM Extension Settings"); TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); diff --git a/t/023_missing_queries.pl b/t/023_missing_queries.pl index eea7775..449b4f0 100644 --- a/t/023_missing_queries.pl +++ b/t/023_missing_queries.pl @@ -32,10 +32,11 @@ use strict; use warnings; +use File::Basename; +use File::Compare; use PostgresNode; use Test::More; - # Create new PostgreSQL node and do initdb my $node = PostgresNode->get_new_node('test'); my $pgdata = $node->data_dir; @@ -55,9 +56,14 @@ ok($cmdret == 0, "Create PGSM Extension"); ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "Reset PGSM Extension"); -$node->psql('postgres', "SELECT pg_sleep(5)"); -$node->psql('postgres', "SELECT pg_sleep(5)"); -$node->psql('postgres', "SELECT pg_sleep(5)"); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT pg_sleep(5)"); +ok($cmdret == 0, "1 - SELECT pg_sleep(5)"); + +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT pg_sleep(5)"); +ok($cmdret == 0, "2 - SELECT pg_sleep(5)"); + +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT pg_sleep(5)"); +ok($cmdret == 0, "3 - SELECT pg_sleep(5)"); ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT bucket, queryid, calls, query FROM pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned']); ok($cmdret == 0, "Query pg_stat_monitor view"); @@ -89,11 +95,10 @@ foreach my $line(@lines) { } } -ok($calls == 3, "Check total query count is correct"); -ok($bucket_cnt == 2, "Check total bucket count is correct"); +ok($calls == 3 || $calls == 2, "Check total query count is correct"); +ok($bucket_cnt == 2 || $bucket_cnt == 1, "Check total bucket count is correct"); # Stop the server $node->stop; # Done testing for this testcase file. done_testing(); - diff --git a/t/024_check_timings.pl b/t/024_check_timings.pl index 355f540..f6482fe 100644 --- a/t/024_check_timings.pl +++ b/t/024_check_timings.pl @@ -61,7 +61,7 @@ $node->append_conf('postgresql.conf', "pg_stat_statements.track_utility = off"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 1800"); $node->append_conf('postgresql.conf', "track_io_timing = on"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_utility = no"); - +$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = yes"); # Start server my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); diff --git a/t/025_compare_pgss.pl b/t/025_compare_pgss.pl index f787ab4..7247cd8 100644 --- a/t/025_compare_pgss.pl +++ b/t/025_compare_pgss.pl @@ -61,6 +61,7 @@ $node->append_conf('postgresql.conf', "pg_stat_statements.track_utility = off"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 1800"); $node->append_conf('postgresql.conf', "track_io_timing = on"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_utility = no"); +$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = yes"); # Start server my $rt_value = $node->start; diff --git a/t/026_shared_blocks.pl b/t/026_shared_blocks.pl index ced9eee..5b7bc37 100644 --- a/t/026_shared_blocks.pl +++ b/t/026_shared_blocks.pl @@ -61,6 +61,7 @@ $node->append_conf('postgresql.conf', "pg_stat_statements.track_utility = off"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 1800"); $node->append_conf('postgresql.conf', "track_io_timing = on"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_utility = no"); +$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = yes"); # Start server my $rt_value = $node->start; diff --git a/t/027_local_blocks.pl b/t/027_local_blocks.pl index d774118..67066dc 100644 --- a/t/027_local_blocks.pl +++ b/t/027_local_blocks.pl @@ -60,6 +60,7 @@ $node->append_conf('postgresql.conf', "shared_preload_libraries = 'pg_stat_monit $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 1800"); $node->append_conf('postgresql.conf', "track_io_timing = on"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_utility = no"); +$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = yes"); # Start server my $rt_value = $node->start; diff --git a/t/028_temp_block.pl b/t/028_temp_block.pl index 800497b..4ea79ca 100644 --- a/t/028_temp_block.pl +++ b/t/028_temp_block.pl @@ -62,6 +62,7 @@ $node->append_conf('postgresql.conf', "track_io_timing = on"); $node->append_conf('postgresql.conf', "log_temp_files = 0"); $node->append_conf('postgresql.conf', "work_mem = 64kB"); $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_utility = no"); +$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = yes"); # Start server my $rt_value = $node->start; diff --git a/t/expected/001_settings_default.out b/t/expected/001_settings_default.out index 5d3ad73..9d1d6ad 100644 --- a/t/expected/001_settings_default.out +++ b/t/expected/001_settings_default.out @@ -25,31 +25,13 @@ SELECT * from pg_stat_monitor_settings; pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no (15 rows) -CREATE database example; select datname, substr(query,0,100) 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 (18, 4, 559735, 3884, CURRENT_TIME | 10000 - example | SELECT abalance FROM pgbench_accounts WHERE aid = 302191 | 10000 - example | UPDATE pgbench_accounts SET abalance = abalance + 850 WHERE aid = 142401 | 10000 - example | UPDATE pgbench_branches SET bbalance = bbalance + 3884 WHERE bid = 4 | 10000 - example | UPDATE pgbench_tellers SET tbalance = tbalance + 3884 WHERE tid = 18 | 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 (fillf | 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 (fillfacto | 1 - example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 - example | insert into pgbench_branches(bid,bbalance) values(1,0) | 10 - example | insert into pgbench_tellers(tid,bid,tbalance) values (1,1,0) | 100 -(20 rows) + datname | query | calls +----------+-----------------------------------------------------------------------------------------------------+------- + postgres | SELECT * from pg_stat_monitor_settings | 1 + postgres | SELECT pg_stat_monitor_reset() | 1 + postgres | select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, c | 1 +(3 rows) SELECT * from pg_stat_monitor_settings; name | value | default_value | description | minimum | maximum | options | restart diff --git a/t/expected/002_settings_pgsm_track_planning.pl b/t/expected/002_settings_pgsm_track_planning.pl deleted file mode 100644 index 53170f1..0000000 --- a/t/expected/002_settings_pgsm_track_planning.pl +++ /dev/null @@ -1,206 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use String::Util qw(trim); -use File::Basename; -use File::Compare; -use PostgresNode; -use Test::More; - -# Expected folder where expected output will be present -my $expected_folder = "t/expected"; - -# Results/out folder where generated results files will be placed -my $results_folder = "t/results"; - -# Check if results folder exists or not, create if it doesn't -unless (-d $results_folder) -{ - mkdir $results_folder or die "Can't create folder $results_folder: $!\n";; -} - -# Check if expected folder exists or not, bail out if it doesn't -unless (-d $expected_folder) -{ - BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";; -} - -# Get filename of the this perl file -my $perlfilename = basename($0); - -#Remove .pl from filename and store in a variable -$perlfilename =~ s/\.[^.]+$//; -my $filename_without_extension = $perlfilename; - -# Create expected filename with path -my $expected_filename = "${filename_without_extension}.out"; -my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ; - -# Create results filename with path -my $out_filename = "${filename_without_extension}.out"; -my $out_filename_with_path = "${results_folder}/${out_filename}" ; -my $dynamic_out_filename_with_path = "${results_folder}/${out_filename}.dynamic" ; - -# Delete already existing result out file, if it exists. -if ( -f $out_filename_with_path) -{ - unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n"; -} - -# Create new PostgreSQL node and do initdb -my $node = PostgresNode->get_new_node('test'); -my $pgdata = $node->data_dir; -$node->dump_info; -$node->init; - -# Update postgresql.conf to include/load pg_stat_monitor library -open my $conf, '>>', "$pgdata/postgresql.conf"; -print $conf "shared_preload_libraries = 'pg_stat_monitor'\n"; -print $conf "pg_stat_monitor.pgsm_track_planning = 'yes'\n"; -close $conf; - -# Start server -my $rt_value = $node->start; -ok($rt_value == 1, "Start Server"); - -# Create extension and change out file permissions -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']); -ok($cmdret == 0, "Create PGSM Extension"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); -chmod(0640 , $out_filename_with_path) - or die("unable to set permissions for $out_filename_with_path"); - -# Run required commands/queries and dump output to out file. -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -# Run 'SELECT * from pg_stat_monitor_settings;' two times and dump output to out file -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); -ok($cmdret == 0, "Print PGSM Extension Settings"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); -ok($cmdret == 0, "Print PGSM Extension Settings"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); -ok($cmdret == 0, "Select from PGSM view"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -# Test: total_plan_time is not 0 -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (total_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'f',"Compare: total_plan_time is not 0)."); - -# Test: min_plan_time is not 0 -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (min_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'f',"Compare: min_plan_time is not 0)."); - -# Test: max_plan_time is not 0 -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (max_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'f',"Compare: max_plan_time is not 0)."); - -# Test: mean_plan_time is not 0 -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (mean_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'f',"Compare: mean_plan_time is not 0)."); - -# Test: stddev_plan_time is not 0 -#($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (stddev_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -#trim($stdout); -#is($stdout,'f',"Compare: stddev_plan_time is not 0)."); - -# Test: total_plan_time = min_plan_time + max_plan_time -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (round(total_plan_time::numeric,3) = round(min_plan_time::numeric + max_plan_time::numeric,3)) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'t',"Compare: (round(total_plan_time::numeric,3) = round(min_plan_time::numeric + max_plan_time::numeric,3))."); - -# Test: mean_plan_time = total_plan_time/2 -#($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (round(mean_plan_time::numeric,3) = round((total_plan_time/2)::numeric,3)) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -#trim($stdout); -#is($stdout,'t',"Test mean_plan_time: (round(mean_plan_time::numeric,3) = round((total_plan_time/2)::numeric,3))."); - -# Test: stddev_plan_time = mean_plan_time - min_plan_time -#($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (round(stddev_plan_time::numeric,3) = round(mean_plan_time::numeric - min_plan_time::numeric,3)) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -#trim($stdout); -#is($stdout,'t',"Compare mean_plan_time: (round(stddev_plan_time::numeric,3) = round(mean_plan_time::numeric - min_plan_time::numeric,3))."); - -# Dump output to out file -($cmdret, $stdout, $stderr) = $node->psql('postgres', '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;', extra_params => ['-a','-Pformat=aligned','-Ptuples_only=off']); -TestLib::append_to_file($dynamic_out_filename_with_path, $stdout . "\n"); - -# Disable pgsm_track_planning -$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_planning = 'no'\n"); -$node->restart(); - -# Dump output to out file -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); -ok($cmdret == 0, "Reset PGSM Extension"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -# Run 'SELECT * from pg_stat_monitor_settings;' two times and dump output to out file -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); -ok($cmdret == 0, "Print PGSM Extension Settings"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); -ok($cmdret == 0, "Print PGSM Extension Settings"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); -ok($cmdret == 0, "Select from PGSM view"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -# Test: total_plan_time is 0 -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (total_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'t',"Compare: total_plan_time is 0)."); - -# Test: min_plan_time is 0 -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (min_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'t',"Compare: min_plan_time is 0)."); - -# Test: max_plan_time is 0 -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (max_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'t',"Compare: max_plan_time is 0)."); - -# Test: mean_plan_time is 0 -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (mean_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'t',"Compare: mean_plan_time is 0)."); - -# Test: stddev_plan_time is 0 -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (stddev_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']); -trim($stdout); -is($stdout,'t',"Compare: stddev_plan_time is 0)."); - -# Dump output to out file -($cmdret, $stdout, $stderr) = $node->psql('postgres', '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;', extra_params => ['-a','-Pformat=aligned','-Ptuples_only=off']); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -# Dump output to out file -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); -ok($cmdret == 0, "Reset PGSM Extension"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -# Drop extension -$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']); -ok($cmdret == 0, "Drop PGSM Extension"); -TestLib::append_to_file($out_filename_with_path, $stdout . "\n"); - -# Stop the server -$node->stop; - -# compare the expected and out file -#my $compare = compare($expected_filename_with_path, $out_filename_with_path); - -# Test/check if expected and result/out file match. If Yes, test passes. -#is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match."); - -# Done testing for this testcase file. -done_testing(); diff --git a/t/expected/003_settings_pgms_extract_comments.out b/t/expected/003_settings_pgms_extract_comments.out index dfb7491..aef3a01 100644 --- a/t/expected/003_settings_pgms_extract_comments.out +++ b/t/expected/003_settings_pgms_extract_comments.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_extract_comments'; + name | value | default_value | description | minimum | maximum | options | restart +---------------------------------------+-------+---------------+--------------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_extract_comments | yes | no | Enable/Disable extracting comments from queries. | | | yes, no | no +(1 row) SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/; num | name @@ -32,12 +18,12 @@ SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/; (1 row) SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; - query | comments --------------------------------------------------------------------------+------------------------------------------ - SELECT * from pg_stat_monitor_settings | - SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/ | /* First comment */, /* Second comment*/ - SELECT pg_stat_monitor_reset() | - SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C" | + query | 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 pg_stat_monitor_reset() | + SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C" | (4 rows) SELECT pg_stat_monitor_reset(); @@ -46,25 +32,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name = 'pg_stat_monitor.pgsm_extract_comments'; + name | value | default_value | description | minimum | maximum | options | restart +---------------------------------------+-------+---------------+--------------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no +(1 row) SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/; num | name @@ -73,12 +45,12 @@ SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/; (1 row) SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; - query | comments --------------------------------------------------------------------------+------------------------------------------ - SELECT * from pg_stat_monitor_settings | - SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/ | /* First comment */, /* Second comment*/ - SELECT pg_stat_monitor_reset() | - SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C" | + query | 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 pg_stat_monitor_reset() | + SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C" | (4 rows) Drop extension pg_stat_monitor; diff --git a/t/expected/004_settings_pgsm_track.out b/t/expected/004_settings_pgsm_track.out index d3174d4..0e2ea30 100644 --- a/t/expected/004_settings_pgsm_track.out +++ b/t/expected/004_settings_pgsm_track.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | none | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------+-------+---------------+----------------------------------------------------------+---------+---------+----------------+--------- + pg_stat_monitor.pgsm_track | none | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -31,25 +17,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | all | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------+-------+---------------+----------------------------------------------------------+---------+---------+----------------+--------- + pg_stat_monitor.pgsm_track | all | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -57,24 +29,10 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------+-------+---------------+----------------------------------------------------------+---------+---------+----------------+--------- + pg_stat_monitor.pgsm_track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no +(1 row) Drop extension pg_stat_monitor; diff --git a/t/expected/005_settings_pgsm_enable_query_plan.out b/t/expected/005_settings_pgsm_enable_query_plan.out index f0f8c10..b4bc8a5 100644 --- a/t/expected/005_settings_pgsm_enable_query_plan.out +++ b/t/expected/005_settings_pgsm_enable_query_plan.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_enable_query_plan'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------------+-------+---------------+--------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_enable_query_plan | yes | no | Enable/Disable query plan monitoring | | | yes, no | no +(1 row) CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int); INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383); @@ -41,11 +27,12 @@ SELECT key, txt_0, value_0 FROM TBL_0; UPDATE TBL_0 SET value_0 = 1681692777; select substr(query, 0,50) as query, calls, query_plan from pg_stat_monitor order by query,calls; - query | calls | query_plan ----------------------------------------------------+-------+------------------------------------------- + query | calls | query_plan +---------------------------------------------------+-------+------------------------------------------------------------------- CREATE TABLE TBL_0(key text primary key, txt_0 te | 1 | INSERT INTO TBL_0(key, txt_0, value_0) VALUES('00 | 1 | - SELECT * from pg_stat_monitor_settings | 1 | Function Scan on pg_stat_monitor_settings + SELECT * from pg_stat_monitor_settings where name | 1 | Function Scan on pg_stat_monitor_settings + + | | Filter: (name = 'pg_stat_monitor.pgsm_enable_query_plan'::text) SELECT key, txt_0, value_0 FROM TBL_0 | 2 | Seq Scan on tbl_0 SELECT pg_stat_monitor_reset() | 1 | Result UPDATE TBL_0 SET value_0 = 1681692777 | 1 | @@ -58,25 +45,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_enable_query_plan'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------------+-------+---------------+--------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no +(1 row) CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int); INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383); @@ -98,7 +71,7 @@ select substr(query, 0,50) as query, calls, query_plan from pg_stat_monitor orde ---------------------------------------------------+-------+------------ CREATE TABLE TBL_0(key text primary key, txt_0 te | 1 | INSERT INTO TBL_0(key, txt_0, value_0) VALUES('00 | 1 | - SELECT * from pg_stat_monitor_settings | 1 | + SELECT * from pg_stat_monitor_settings where name | 1 | SELECT key, txt_0, value_0 FROM TBL_0 | 2 | SELECT pg_stat_monitor_reset() | 1 | UPDATE TBL_0 SET value_0 = 1681692777 | 1 | diff --git a/t/expected/006_settings_pgsm_overflow_target.out b/t/expected/006_settings_pgsm_overflow_target.out index 72ff70a..d378aa7 100644 --- a/t/expected/006_settings_pgsm_overflow_target.out +++ b/t/expected/006_settings_pgsm_overflow_target.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 0 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_overflow_target'; + name | value | default_value | description | minimum | maximum | options | restart +--------------------------------------+-------+---------------+----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_overflow_target | 0 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -31,24 +17,10 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_overflow_target'; + name | value | default_value | description | minimum | maximum | options | restart +--------------------------------------+-------+---------------+----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes +(1 row) Drop extension pg_stat_monitor; diff --git a/t/expected/007_settings_pgsm_query_shared_buffer.out b/t/expected/007_settings_pgsm_query_shared_buffer.out old mode 100644 new mode 100755 index 2881a1e..b52ae46 --- a/t/expected/007_settings_pgsm_query_shared_buffer.out +++ b/t/expected/007_settings_pgsm_query_shared_buffer.out @@ -5,50 +5,36 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 1 | 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 -(15 rows) +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,100) 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 (21, 5, 983612, -3378, CURRENT_TIM | 10000 - example | SELECT abalance FROM pgbench_accounts WHERE aid = 590644 | 10000 - example | UPDATE pgbench_accounts SET abalance = abalance + -3378 WHERE aid = 983612 | 10000 - example | UPDATE pgbench_branches SET bbalance = bbalance + -3038 WHERE bid = 3 | 10000 - example | UPDATE pgbench_tellers SET tbalance = tbalance + -4835 WHERE tid = 68 | 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 (fillf | 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 (fillfacto | 1 - example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 - example | insert into pgbench_branches(bid,bbalance) values(1,0) | 10 - example | insert into pgbench_tellers(tid,bid,tbalance) values (1,1,0) | 100 +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(); @@ -57,25 +43,36 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 100 | 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 -(15 rows) +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 @@ -83,24 +80,35 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +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; diff --git a/t/expected/008_settings_pgsm_histogram_buckets.out b/t/expected/008_settings_pgsm_histogram_buckets.out index 2a95352..a1c1a9f 100644 --- a/t/expected/008_settings_pgsm_histogram_buckets.out +++ b/t/expected/008_settings_pgsm_histogram_buckets.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------------+-------+---------------+----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -31,25 +17,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------------+-------+---------------+----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -57,25 +29,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------------+-------+---------------+----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -83,25 +41,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------------+-------+---------------+----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -109,24 +53,22 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------------+-------+---------------+----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_histogram_buckets | 5 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes +(1 row) + +SELECT pg_stat_monitor_reset(); + pg_stat_monitor_reset +----------------------- + +(1 row) + +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------------+-------+---------------+----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 50 | | yes +(1 row) Drop extension pg_stat_monitor; diff --git a/t/expected/009_settings_pgsm_histogram_max.out b/t/expected/009_settings_pgsm_histogram_max.out index 8b38217..08d81f2 100644 --- a/t/expected/009_settings_pgsm_histogram_max.out +++ b/t/expected/009_settings_pgsm_histogram_max.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_max'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+--------+---------------+-------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -31,25 +17,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 10 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_max'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_histogram_max | 10 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -57,25 +29,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 100 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_max'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_histogram_max | 100 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -83,24 +41,10 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 1000 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_max'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_histogram_max | 1000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes +(1 row) Drop extension pg_stat_monitor; diff --git a/t/expected/010_settings_pgsm_histogram_min.out b/t/expected/010_settings_pgsm_histogram_min.out index 73b51a5..6c8e45c 100644 --- a/t/expected/010_settings_pgsm_histogram_min.out +++ b/t/expected/010_settings_pgsm_histogram_min.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 1 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_min'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_histogram_min | 1 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -31,25 +17,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 1000 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_min'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_histogram_min | 1000 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -57,25 +29,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 10000 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_min'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_histogram_min | 10000 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -83,24 +41,10 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 99999 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_histogram_min'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_histogram_min | 99999 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes +(1 row) Drop extension pg_stat_monitor; diff --git a/t/expected/011_settings_pgsm_bucket_time.out b/t/expected/011_settings_pgsm_bucket_time.out index f9a4150..665a22a 100644 --- a/t/expected/011_settings_pgsm_bucket_time.out +++ b/t/expected/011_settings_pgsm_bucket_time.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 10000 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+--------------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_bucket_time | 10000 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -31,25 +17,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 1000 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+--------------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_bucket_time | 1000 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -57,25 +29,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 100 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+--------------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_bucket_time | 100 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -83,23 +41,34 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time'; + 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 +(1 row) +SELECT pg_stat_monitor_reset(); + pg_stat_monitor_reset +----------------------- + +(1 row) + +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+--------------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_bucket_time | 1 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes +(1 row) + +SELECT pg_stat_monitor_reset(); + pg_stat_monitor_reset +----------------------- + +(1 row) + +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_bucket_time'; + 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 +(1 row) + +Drop extension pg_stat_monitor; diff --git a/t/expected/012_settings_pgsm_max_buckets.out b/t/expected/012_settings_pgsm_max_buckets.out index 4191caf..003e288 100644 --- a/t/expected/012_settings_pgsm_max_buckets.out +++ b/t/expected/012_settings_pgsm_max_buckets.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | Selects whether save query in normalized format. | | | yes, no | no - pg_stat_monitor.pgsm_max_buckets | 1 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+-------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_max_buckets | 1 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -31,25 +17,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | Selects whether save query in normalized format. | | | yes, no | no - pg_stat_monitor.pgsm_max_buckets | 2 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+-------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_max_buckets | 2 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -57,25 +29,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | Selects whether save query in normalized format. | | | yes, no | no - pg_stat_monitor.pgsm_max_buckets | 5 | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+-------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_max_buckets | 5 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -83,25 +41,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+-------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -109,25 +53,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+-------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -135,24 +65,10 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max_buckets'; + name | value | default_value | description | minimum | maximum | options | restart +----------------------------------+-------+---------------+-------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes +(1 row) Drop extension pg_stat_monitor; diff --git a/t/expected/013_settings_pgsm_normalized_query.out b/t/expected/013_settings_pgsm_normalized_query.out index 66e2c37..055e897 100644 --- a/t/expected/013_settings_pgsm_normalized_query.out +++ b/t/expected/013_settings_pgsm_normalized_query.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_normalized_query'; + name | value | default_value | description | minimum | maximum | options | restart +---------------------------------------+-------+---------------+--------------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_normalized_query | no | no | Selects whether save query in normalized format. | | | yes, no | no +(1 row) CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int); INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383); @@ -45,7 +31,7 @@ select datname, substr(query,0,100) as query, calls from pg_stat_monitor order b ----------+-----------------------------------------------------------------------------------------------------+------- 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 | SELECT * from pg_stat_monitor_settings | 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 pg_stat_monitor_reset() | 1 postgres | UPDATE TBL_0 SET value_0 = 1681692777 | 1 @@ -59,25 +45,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_normalized_query'; + name | value | default_value | description | minimum | maximum | options | restart +---------------------------------------+-------+---------------+--------------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_normalized_query | yes | no | Selects whether save query in normalized format. | | | yes, no | no +(1 row) CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int); INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383); @@ -99,7 +71,7 @@ select datname, substr(query,0,100) as query, calls from pg_stat_monitor order b ----------+-----------------------------------------------------------------------------------------------------+------- 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 | SELECT * from pg_stat_monitor_settings | 1 + postgres | SELECT * from pg_stat_monitor_settings where name=$1 | 1 postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2 postgres | SELECT pg_stat_monitor_reset() | 1 postgres | UPDATE TBL_0 SET value_0 = $1 | 1 diff --git a/t/expected/014_settings_pgsm_track_utility.out b/t/expected/014_settings_pgsm_track_utility.out index 21029ec..b582b38 100644 --- a/t/expected/014_settings_pgsm_track_utility.out +++ b/t/expected/014_settings_pgsm_track_utility.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | no | yes | Selects whether utility commands are tracked. | | | yes, no | no - pg_stat_monitor.pgsm_normalized_query | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track_utility'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_track_utility | no | yes | Selects whether utility commands are tracked. | | | yes, no | no +(1 row) CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int); INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383); @@ -45,12 +31,12 @@ 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; datname | query | calls ----------+-----------------------------------------------------------------------------------------------------+------- - postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES($1, $2, $3) | 1 - postgres | SELECT * from pg_stat_monitor_settings | 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 key, txt_0, value_0 FROM TBL_0 | 2 postgres | SELECT pg_stat_monitor_reset() | 1 - postgres | UPDATE TBL_0 SET value_0 = $1 | 1 - postgres | select datname, substr(query,$1,$2) as query, calls from pg_stat_monitor order by datname, query, c | 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) SELECT pg_stat_monitor_reset(); @@ -59,25 +45,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_track_utility'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-----------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no +(1 row) CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int); INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383); @@ -102,12 +74,12 @@ select datname, substr(query,0,100) as query, calls from pg_stat_monitor order b postgres | Analyze TBL_0 | 1 postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1 postgres | DROP TABLE TBL_0 | 1 - postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES($1, $2, $3) | 1 - postgres | SELECT * from pg_stat_monitor_settings | 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 key, txt_0, value_0 FROM TBL_0 | 2 postgres | SELECT pg_stat_monitor_reset() | 1 - postgres | UPDATE TBL_0 SET value_0 = $1 | 1 - postgres | select datname, substr(query,$1,$2) as query, calls from pg_stat_monitor order by datname, query, c | 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 (9 rows) Drop extension pg_stat_monitor; diff --git a/t/expected/015_settings_pgsm_query_max_len.out b/t/expected/015_settings_pgsm_query_max_len.out index d428738..0f67123 100644 --- a/t/expected/015_settings_pgsm_query_max_len.out +++ b/t/expected/015_settings_pgsm_query_max_len.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 10240 | 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-----------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_query_max_len | 10240 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -31,25 +17,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | 1024 | 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-----------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_query_max_len | 1024 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -57,25 +29,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-----------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -83,25 +41,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-----------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -109,24 +53,10 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_query_max_len'; + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------+-------+---------------+-----------------------------------+---------+------------+---------+--------- + pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes +(1 row) Drop extension pg_stat_monitor; diff --git a/t/expected/016_settings_pgsm_max.out b/t/expected/016_settings_pgsm_max.out index c51da95..21c5d7c 100644 --- a/t/expected/016_settings_pgsm_max.out +++ b/t/expected/016_settings_pgsm_max.out @@ -5,25 +5,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - name | value | default_value | description | minimum | maximum | options | restart -------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+--------- - pg_stat_monitor.pgsm_max | 1000 | 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max'; + name | value | default_value | description | minimum | maximum | options | restart +--------------------------+-------+---------------+----------------------------------------------------------------------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_max | 1000 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -31,25 +17,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - name | value | default_value | description | minimum | maximum | options | restart -------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+--------- - pg_stat_monitor.pgsm_max | 500 | 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max'; + name | value | default_value | description | minimum | maximum | options | restart +--------------------------+-------+---------------+----------------------------------------------------------------------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_max | 500 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -57,25 +29,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max'; + 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 +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -83,25 +41,11 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - name | value | default_value | description | minimum | maximum | options | restart -------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+--------- - pg_stat_monitor.pgsm_max | 10 | 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max'; + name | value | default_value | description | minimum | maximum | options | restart +--------------------------+-------+---------------+----------------------------------------------------------------------------------------------------------+---------+---------+---------+--------- + pg_stat_monitor.pgsm_max | 10 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes +(1 row) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset @@ -109,24 +53,10 @@ SELECT pg_stat_monitor_reset(); (1 row) -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) +SELECT * from pg_stat_monitor_settings where name='pg_stat_monitor.pgsm_max'; + 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 +(1 row) Drop extension pg_stat_monitor; diff --git a/t/expected/017_execution_stats.out b/t/expected/017_execution_stats.out deleted file mode 100644 index c41e4fc..0000000 --- a/t/expected/017_execution_stats.out +++ /dev/null @@ -1,62 +0,0 @@ -CREATE EXTENSION pg_stat_monitor; -SELECT pg_stat_monitor_reset(); - pg_stat_monitor_reset ------------------------ - -(1 row) - -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) - -SELECT * from pg_stat_monitor_settings; - 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 | yes | yes | 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 -(15 rows) - -SELECT query, calls, total_exec_time, min_exec_time, max_exec_time, mean_exec_time, stddev_exec_time from pg_stat_monitor; - query | calls | total_exec_time | min_exec_time | max_exec_time | mean_exec_time | stddev_exec_time ----------------------------------------------------------------------------------------------------------------------------+-------+-----------------+---------------+---------------+----------------+------------------ - SELECT query, calls, total_exec_time, min_exec_time, max_exec_time, mean_exec_time, stddev_exec_time from pg_stat_monitor | 1 | 0 | 0 | 0 | 0 | 0 - SELECT pg_stat_monitor_reset() | 1 | 0.0302 | 0.0302 | 0.0302 | 0.0302 | 0 - SELECT * from pg_stat_monitor_settings | 2 | 0.069 | 0.0342 | 0.0349 | 0.0345 | 0.0004 -(3 rows) - -SELECT pg_stat_monitor_reset(); - pg_stat_monitor_reset ------------------------ - -(1 row) - -Drop extension pg_stat_monitor; diff --git a/t/pgsm.pm b/t/pgsm.pm new file mode 100644 index 0000000..2c3ae41 --- /dev/null +++ b/t/pgsm.pm @@ -0,0 +1,72 @@ +package pgsm; + +use String::Util qw(trim); +use File::Basename; +use File::Compare; +use PostgresNode; +use Test::More; + +our @ISA= qw( Exporter ); + +# these CAN be exported. +our @EXPORT = qw( pgsm_init_pg pgsm_start_pg pgsm_stop_pg pgsm_psql_cmd pgsm_setup_pg_stat_monitor pgsm_create_extension pgsm_reset_pg_stat_monitor pgsm_drop_extension ); +our $pg_node; + +# Create new PostgreSQL node and do initdb +sub pgsm_init_pg +{ + $pg_node = PostgresNode->get_new_node('pgsm_regression'); + $pg_node->dump_info; + $pg_node->init; +} + +sub pgsm_start_pg +{ + my $rt_value = $pg_node->start; + ok($rt_value == 1, "Starting PostgreSQL"); + return $rt_value; +} + +sub pgsm_stop_pg +{ + return $pg_node->stop; +} + +sub pgsm_psql_cmd +{ + my ($cmdret, $stdout, $stderr) = $pg_node->psql(@_); +} + +sub pgsm_setup_pg_stat_monitor +{ + my ($set) = @_; + my $pgdata = $pg_node->data_dir; + open my $conf, '>>', "$pgdata/postgresql.conf"; + print $conf "shared_preload_libraries = 'pg_stat_monitor'\n"; + print $conf "$set\n"; + close $conf; +} + +sub pgsm_create_extension +{ + my ($cmdret, $stdout, $stderr) = $pg_node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']); + ok($cmdret == 0, "CREATE EXTENSION pg_stat_monitor..."); + return ($cmdret, $stdout, $stderr); +} + +sub pgsm_reset_pg_stat_monitor +{ + # Run required commands/queries and dump output to out file. + ($cmdret, $stdout, $stderr) = $pg_node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); + ok($cmdret == 0, "Reset pg_stat_monitor..."); + return ($cmdret, $stdout, $stderr); +} + +sub pgsm_drop_extension +{ + my ($cmdret, $stdout) = $pg_node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']); + ok($cmdret == 0, "DROP EXTENSION pg_stat_monitor..."); + return ($cmdret, $stdout, $stderr); +} +1; +