diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index f75b52719d..eb17eddd05 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -2370,6 +2370,7 @@ AtEOXact_PgStat(bool isCommit, bool parallel) /* forget live/dead stats seen by backend thus far */ tabstat->t_counts.t_delta_live_tuples = 0; tabstat->t_counts.t_delta_dead_tuples = 0; + tabstat->t_counts.t_changed_tuples = 0; } /* insert adds a live tuple, delete removes one */ tabstat->t_counts.t_delta_live_tuples += @@ -2605,6 +2606,7 @@ pgstat_twophase_postcommit(TransactionId xid, uint16 info, /* forget live/dead stats seen by backend thus far */ pgstat_info->t_counts.t_delta_live_tuples = 0; pgstat_info->t_counts.t_delta_dead_tuples = 0; + pgstat_info->t_counts.t_changed_tuples = 0; } pgstat_info->t_counts.t_delta_live_tuples += rec->tuples_inserted - rec->tuples_deleted; @@ -6455,6 +6457,7 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) { tabentry->n_live_tuples = 0; tabentry->n_dead_tuples = 0; + tabentry->changes_since_analyze = 0; tabentry->inserts_since_vacuum = 0; } tabentry->n_live_tuples += tabmsg->t_counts.t_delta_live_tuples; diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out index b01e58b98c..e8d96eabd5 100644 --- a/src/test/regress/expected/stats.out +++ b/src/test/regress/expected/stats.out @@ -77,7 +77,7 @@ begin extract(epoch from clock_timestamp() - start_time); end $$ language plpgsql; --- test effects of TRUNCATE on n_live_tup/n_dead_tup counters +-- test effects of TRUNCATE on n_live_tup/n_dead_tup/n_mod_since_analyze counters CREATE TABLE trunc_stats_test(id serial); CREATE TABLE trunc_stats_test1(id serial, stuff text); CREATE TABLE trunc_stats_test2(id serial); @@ -160,16 +160,16 @@ SELECT wait_for_stats(); (1 row) -- check effects -SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup +SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup, n_mod_since_analyze FROM pg_stat_user_tables WHERE relname like 'trunc_stats_test%' order by relname; - relname | n_tup_ins | n_tup_upd | n_tup_del | n_live_tup | n_dead_tup --------------------+-----------+-----------+-----------+------------+------------ - trunc_stats_test | 3 | 0 | 0 | 0 | 0 - trunc_stats_test1 | 4 | 2 | 1 | 1 | 0 - trunc_stats_test2 | 1 | 0 | 0 | 1 | 0 - trunc_stats_test3 | 4 | 0 | 0 | 2 | 2 - trunc_stats_test4 | 2 | 0 | 0 | 0 | 2 + relname | n_tup_ins | n_tup_upd | n_tup_del | n_live_tup | n_dead_tup | n_mod_since_analyze +-------------------+-----------+-----------+-----------+------------+------------+--------------------- + trunc_stats_test | 3 | 0 | 0 | 0 | 0 | 0 + trunc_stats_test1 | 4 | 2 | 1 | 1 | 0 | 1 + trunc_stats_test2 | 1 | 0 | 0 | 1 | 0 | 1 + trunc_stats_test3 | 4 | 0 | 0 | 2 | 2 | 2 + trunc_stats_test4 | 2 | 0 | 0 | 0 | 2 | 0 (5 rows) SELECT st.seq_scan >= pr.seq_scan + 1, diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql index feaaee6326..70227a0a6c 100644 --- a/src/test/regress/sql/stats.sql +++ b/src/test/regress/sql/stats.sql @@ -77,7 +77,7 @@ begin end $$ language plpgsql; --- test effects of TRUNCATE on n_live_tup/n_dead_tup counters +-- test effects of TRUNCATE on n_live_tup/n_dead_tup/n_mod_since_analyze counters CREATE TABLE trunc_stats_test(id serial); CREATE TABLE trunc_stats_test1(id serial, stuff text); CREATE TABLE trunc_stats_test2(id serial); @@ -155,7 +155,7 @@ RESET enable_bitmapscan; SELECT wait_for_stats(); -- check effects -SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup +SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup, n_mod_since_analyze FROM pg_stat_user_tables WHERE relname like 'trunc_stats_test%' order by relname;