pg_stat_database update stats_reset only by pg_stat_reset

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

pg_stat_database update stats_reset only by pg_stat_reset

张连壮
pg_stat_reset_single_table_counters/pg_stat_reset_single_function_counters only update pg_stat_database column stats_reset.
stat_reset shuld update when all the column is reset.

sample:
drop database if exists lzzhang_db;
create database lzzhang_db;
\c lzzhang_db

create table lzzhang_tab(id int);
insert into lzzhang_tab values(1);
insert into lzzhang_tab values(1);

select tup_fetched, stats_reset from pg_stat_database where datname='lzzhang_db';
select pg_sleep(1);

select pg_stat_reset_single_table_counters('lzzhang_tab'::regclass::oid);
select tup_fetched, stats_reset from pg_stat_database where datname='lzzhang_db';

result:
 tup_fetched |          stats_reset          
-------------+-------------------------------
         514 | 2019-05-12 03:22:55.702753+08
(1 row)
 tup_fetched |          stats_reset          
-------------+-------------------------------
         710 | 2019-05-12 03:22:56.729336+08
(1 row)
tup_fetched is not reset but stats_reset is reset.

0001-pg_stat_database-update-stats_reset-only-by-pg_stat_.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: pg_stat_database update stats_reset only by pg_stat_reset

张连壮
it reset statistics for a single table and update the column stats_reset of pg_stat_database.
but i think that stats_reset shoud be database-level statistics, a single table should not update the column stats_reset.

i am monitor the xact_commit every 5 minutes, when stats_reset is reset but ohter columns is not reset, i can't decide
if i will recount the xact_commit, because pg_stat_reset make all column to zero. pg_stat_reset_single_table_counters
only reset the column stats_reset.


张连壮 <[hidden email]> 于2019年5月13日周一 下午3:30写道:
pg_stat_reset_single_table_counters/pg_stat_reset_single_function_counters only update pg_stat_database column stats_reset.
stat_reset shuld update when all the column is reset.

sample:
drop database if exists lzzhang_db;
create database lzzhang_db;
\c lzzhang_db

create table lzzhang_tab(id int);
insert into lzzhang_tab values(1);
insert into lzzhang_tab values(1);

select tup_fetched, stats_reset from pg_stat_database where datname='lzzhang_db';
select pg_sleep(1);

select pg_stat_reset_single_table_counters('lzzhang_tab'::regclass::oid);
select tup_fetched, stats_reset from pg_stat_database where datname='lzzhang_db';

result:
 tup_fetched |          stats_reset          
-------------+-------------------------------
         514 | 2019-05-12 03:22:55.702753+08
(1 row)
 tup_fetched |          stats_reset          
-------------+-------------------------------
         710 | 2019-05-12 03:22:56.729336+08
(1 row)
tup_fetched is not reset but stats_reset is reset.