postgres.git / summary / log / commit / refs

commit    8a1b5b3d43883454d3438674eaca71184f7e6dec
Author:   Fujii Masao <fujii@postgresql.org>
Date:     Wed Sep 16 09:36:43 2026 +0000

    Suppress progress reporting when creating TOAST indexes
    
    Previously, when REPACK, CLUSTER, or VACUUM FULL created a transient TOAST
    table, index_rebuild_count in pg_stat_progress_repack and
    pg_stat_progress_cluster reported 2 before any indexes on the main table
    had been rebuilt. This could mislead users monitoring the operation.
    
    This happened because creating the TOAST index writes the CREATE INDEX phase
    to the same progress slot used for the index rebuild count of the enclosing
    command.
    
    Fix this by passing INDEX_CREATE_SUPPRESS_PROGRESS when creating a TOAST
    index, preserving the progress information of the enclosing command and
    keeping the count at zero until the main-table indexes are rebuilt.
    
    Author: Adam Lee <adam8157@gmail.com>
    Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
    Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
    Discussion: https://postgr.es/m/aj4gJQMba0kClQmj@Mac
    Backpatch-through: 19


src/backend/catalog/toasting.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c index 4aa52a4bd25..15a4267c64b 100644 --- a/src/backend/catalog/toasting.c +++ b/src/backend/catalog/toasting.c @@ -325,6 +325,10 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, coloptions[0] = 0; coloptions[1] = 0; + /* + * Don't let index creation overwrite progress information for the command + * that caused the TOAST table to be created. + */ index_create(toast_rel, toast_idxname, toastIndexOid, InvalidOid, InvalidOid, InvalidOid, indexInfo, @@ -332,7 +336,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, BTREE_AM_OID, rel->rd_rel->reltablespace, collationIds, opclassIds, NULL, coloptions, NULL, (Datum) 0, - INDEX_CREATE_IS_PRIMARY, 0, true, true, NULL); + INDEX_CREATE_IS_PRIMARY | INDEX_CREATE_SUPPRESS_PROGRESS, + 0, true, true, NULL); table_close(toast_rel, NoLock); [parent: c05d5ce12366]