Skip to content

Commit 992d2ca

Browse files
committed
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
1 parent 6d2de07 commit 992d2ca

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/backend/commands/analyze.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,8 +1534,25 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
15341534
AcquireSampleRowsFunc acquirefunc = acquirefuncs[i];
15351535
double childblocks = relblocks[i];
15361536

1537-
pgstat_progress_update_param(PROGRESS_ANALYZE_CURRENT_CHILD_TABLE_RELID,
1538-
RelationGetRelid(childrel));
1537+
/*
1538+
* Report progress. The sampling function will normally report blocks
1539+
* done/total, but we need to reset them to 0 here, so that they don't
1540+
* show an old value until that.
1541+
*/
1542+
{
1543+
const int progress_index[] = {
1544+
PROGRESS_ANALYZE_CURRENT_CHILD_TABLE_RELID,
1545+
PROGRESS_ANALYZE_BLOCKS_DONE,
1546+
PROGRESS_ANALYZE_BLOCKS_TOTAL
1547+
};
1548+
const int64 progress_vals[] = {
1549+
RelationGetRelid(childrel),
1550+
0,
1551+
0,
1552+
};
1553+
1554+
pgstat_progress_update_multi_param(3, progress_index, progress_vals);
1555+
}
15391556

15401557
if (childblocks > 0)
15411558
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy