Re: pg_stat_progress_cluster: do not default to CLUSTER

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Subject: Re: pg_stat_progress_cluster: do not default to CLUSTER
Date: 2026-09-09 04:02:22
Message-ID: 6EB0849E-79FC-4FBA-A73A-8B076DE5CA33@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Sep 9, 2026, at 07:46, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> On Thu, Sep 3, 2026 at 7:39 PM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
>> The attached patch fixes this to report NULL instead.
>
> Thanks for the patch! It looks good to me. So, barring any objections,
> I'll commit it.

Also looks good to me.

>
> BTW, as a separate issue, is the following also problematic?
>
> WHEN command = 'REPACK' AND repack_index_relid = 0 THEN 'VACUUM FULL'
>
> REPACK ... USING INDEX ... should basically be displayed as "CLUSTER".
> But, if an index scan is not used (for example, when
> enable_indexscan is disabled), repack_index_relid can be 0, causing
> it to be displayed as "VACUUM FULL" unexpectedly. Thoughts?
>

Yes, this is true. Now heapam_relation_copy_for_cluster() only sets PROGRESS_REPACK_INDEX_RELID if (OldIndex != NULL && !use_sort). So when enable_indexscan is off, REPACK ... USING INDEX shows VACUUM FULL:
```
REPACK USING INDEX with enable_indexscan = off
SET
pg_sleep
----------

(1 row)

pid | relid | repack_command | repack_index_relid | compatibility_command | phase
-------+--------+----------------+--------------------+-----------------------+------------------
57523 | j4_1.t | REPACK | 0 | VACUUM FULL | rebuilding index
(1 row)
```

When enable_indexscan is on, it show CLUSTER:
```
REPACK USING INDEX with enable_indexscan = on
SET
pg_sleep
----------

(1 row)

pid | relid | repack_command | repack_index_relid | compatibility_command | phase
-------+--------+----------------+--------------------+-----------------------+------------------
57591 | j4_1.t | REPACK | 16455 | CLUSTER | rebuilding index
(1 row)
```

So, repack_index_relid now describes the actual scan method but not if index ordering was requested. Maybe we should set PROGRESS_REPACK_INDEX_RELID in cluster_rel() rather than heapam_relation_copy_for_cluster()? Like in the attache diff.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
repack_index_relid-fix.diff application/octet-stream 3.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message solai v 2026-09-09 04:22:12 Re: Preserve statistics targets with ALTER TABLE ALTER COLUMN TYPE
Previous Message Hayato Kuroda (Fujitsu) 2026-09-09 03:57:48 RE: [PATCH] Report changes discarded for relations not in the subscription