]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix briefly showing old progress stats for ANALYZE on inherited tables.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Sat, 30 Sep 2023 14:03:50 +0000 (17:03 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Sat, 30 Sep 2023 14:07:32 +0000 (17:07 +0300)
commit5ae245664830219bab2e2ada11d2379875f4501a
treea1b810072c2d8426047e0f78959cb95a5e39839c
parent3c1a1af91d9504e4ce0319f48e83f7c2d5765969
Fix briefly showing old progress stats for ANALYZE on inherited tables.

ANALYZE on a table with inheritance children analyzes all the child
tables in a loop. When stepping to next child table, it updated the
child rel ID value in the command progress stats, but did not reset
the 'sample_blks_total' and 'sample_blks_scanned' counters.
acquire_sample_rows() updates 'sample_blks_total' as soon as the scan
starts and 'sample_blks_scanned' after processing the first block, but
until then, pg_stat_progress_analyze would display a bogus combination
of the new child table relid with old counter values from the
previously processed child table. Fix by resetting 'sample_blks_total'
and 'sample_blks_scanned' to zero at the same time that
'current_child_table_relid' is updated.

Backpatch to v13, where pg_stat_progress_analyze view was introduced.

Reported-by: Justin Pryzby
Discussion: https://www.postgresql.org/message-id/20230122162345.GP13860%40telsasoft.com
src/backend/commands/analyze.c