Add local blocks timing statistics columns local_blk_{write|read}_time

This commit is contained in:
Artem Gavrilov
2024-05-24 20:55:13 +02:00
parent cd6d836feb
commit 60a03d1c94
5 changed files with 69 additions and 47 deletions

View File

@@ -28,8 +28,8 @@ my %pg_versions_pgsm_columns = ( 17 => "application_name,".
"datname,dbid,elevel,jit_emission_count,jit_emission_time,jit_functions," .
"jit_generation_time,jit_inlining_count,jit_inlining_time," .
"jit_optimization_count,jit_optimization_time," .
"local_blks_dirtied,local_blks_hit,local_blks_read," .
"local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
"local_blk_read_time,local_blk_write_time,local_blks_dirtied,local_blks_hit,".
"local_blks_read,local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
"mean_plan_time,message,min_exec_time,min_plan_time,pgsm_query_id,planid," .
"plans,query,query_plan,queryid,relations,resp_calls,rows," .
"shared_blk_read_time,shared_blk_write_time,shared_blks_dirtied," .

View File

@@ -70,10 +70,19 @@ is($stdout,'t',"Check: local_blks_hit should not be 0.");
trim($stdout);
is($stdout,'t',"Check: local_blks_dirtied should not be 0.");
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.local_blk_write_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%INSERT INTO t1%\'', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
trim($stdout);
is($stdout,'t',"Check: local_blk_write_time should not be 0.");
# Compare values for query 'SELECT * FROM t1'
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT PGSM.local_blks_hit != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%FROM t1%\';', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
trim($stdout);
is($stdout,'t',"Check: shared_blks_hit should not be 0.");
is($stdout,'t',"Check: local_blks_hit should not be 0.");
# TODO: Find a way how to bypass cache and ger real block reads
# ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.local_blk_read_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%FROM t1%\';', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
# trim($stdout);
# is($stdout,'t',"Check: local_blk_read_time should not be 0.");
# DROP EXTENSION
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);