Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x49Wd-006x43-01 for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2026 04:03:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x49Wb-00BN5l-2B for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2026 04:03:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x49Wb-00BN5d-16 for pgsql-hackers@lists.postgresql.org; Wed, 09 Sep 2026 04:03:05 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x49WY-00000003h6N-373x for pgsql-hackers@lists.postgresql.org; Wed, 09 Sep 2026 04:03:05 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-39b2ad862bdso5946152a91.2 for ; Tue, 08 Sep 2026 21:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788926580; x=1789531380; darn=lists.postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:content-type :message-id:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=TCg87a69IXYgOAwrDN8RYxRoR/toNZ09/4faGZbdhbo=; b=Co43ZKRp3G6R/ZMuoEj1nyAu231U/oZq5HnpD6zRkaTye41/kI4hziOGUCSxfij0qp wAP4v0WolBjP+EPu1/vYTOMj3ljaruwjFBbkPK+Zn1F72/LFvq4jTIkAbyN9ovkKR+6x /zccyfWanj5YQF9v7p6lEhniZNzW+09Mfr4OHDrQIkYEVpJVJqnqujRXEBVLTd7kOZau Gm3x7amr5zMhvddMuvDKSzb+5kGKFpZkoU1aQhNwvMEye4R3k2antH2XHHrke8hv2m6p thFV7Kc4uz2V4GzZwTW7WudoORQGkEsS1v9CYXgUY3v2BKG9peTmU+z647aiZ3TIxs48 dlqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788926580; x=1789531380; h=references:to:cc:in-reply-to:date:subject:mime-version:content-type :message-id:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TCg87a69IXYgOAwrDN8RYxRoR/toNZ09/4faGZbdhbo=; b=WU1BHluZhTpFTD5hA/P7NDqDOImdn6G+xz4t0wmG0hPkoLZQ+gQgatMBEZzKTodfwB BjOjTSziOSYuR9AbVfLqvJ+Fa7JAZVsNM9pE0ApSackaN/+x/g697XRB8x1N6oA9sUMt +zMa0QIar8taDx59HPBQz0NbA+8l37smzAl0lHGmlX4pfrYrW/h/pLROlwD7GkJdZ4hH lNjRGpMJExNNAdhBzbWfTBZGSIK9jy9wTSoOldF8oUnUXkkpOzN4VI/nFW51LAB6I8UI Yb/ptEaaC5nrAFQVM/A7DCk/OAjj4mWE9/VxRh31OsY470ryvUhjGwptaQ6NGBsQrAEl C+xA== X-Forwarded-Encrypted: i=1; AKwUvBzhxncGuzC4+bMwzTEfap7+DPkMGrf+Aabu+Q4Q+lssCDzb56qLyGeQZk5F+sBx1JFmIImKVi8iD2qbGrxO@lists.postgresql.org X-Gm-Message-State: AFuF++l64mZesuVmtYu/CYSBVSgge2H3gs8jJIisargKmYYTvy5e6ay0 7UP8i3dVXhKIHYplpVTchCZ1GBRf0y/y6Y3wffcSEmRNiC2R0V9n6KFM X-Gm-Gg: AYBFou2DWxk+AGvZ/etbzbitc+xjUbTJ4n7eplEkvmwIueabL1oZKFgS1B3+FaB5EPo fukW+pxndVdTYdCeuGeOTSGvfTGrWnedwmg4ekPvYc9WCl3ZRNXooaPT/9emPDbKuMeBFi9LaPc 8XdMThZw83DZzcU+08LAXfyLdfYafbgte4HQCxkfVrvcarus2au5sb3iPT7f2PoB06csPldaBUB qacKOZrK57t2cl3egwJjQ4Co9cNNPdLGH2SJrAWf8ICgcBHb2TzbBul8id5RN1J5RhwyQNmlXDb nYCHg5vWYaSFIa5/Y5QmpG7ARYNAfnAnbZCNJuTzD3sKKkj10LOekqcDE+xGapEKV3j7rFt0JEp CDJ2/7RNMnCdeR6PUrpvqH4GVVMg4YJ9kfv5BIOtIBlh2MNvOJEXFVxDAd4C8DkuufN5ml6H7DZ /c4oNJbmxRA2P//AHpuOISxCl9xrYVgXTripVcb59Wke7FvZPOkthr4veVEckERINKjsfAc7ym8 h2CNczH X-Received: by 2002:a17:90b:3912:b0:398:c724:1bb1 with SMTP id 98e67ed59e1d1-39b26101524mr44236542a91.8.1788926580139; Tue, 08 Sep 2026 21:03:00 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.125]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b08bcc090sm35193210a91.4.2026.09.08.21.02.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Sep 2026 21:02:59 -0700 (PDT) From: Chao Li Message-Id: <6EB0849E-79FC-4FBA-A73A-8B076DE5CA33@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_48A55D46-8DC4-4960-B7A1-2C947DE6E461" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: Re: pg_stat_progress_cluster: do not default to CLUSTER Date: Wed, 9 Sep 2026 12:02:22 +0800 In-Reply-To: Cc: Zsolt Parragi , PostgreSQL Hackers , =?utf-8?Q?=C3=81lvaro_Herrera?= To: Fujii Masao References: X-Mailer: Apple Mail (2.3864.700.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_48A55D46-8DC4-4960-B7A1-2C947DE6E461 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 9, 2026, at 07:46, Fujii Masao wrote: >=20 > On Thu, Sep 3, 2026 at 7:39=E2=80=AFPM Zsolt Parragi = wrote: >> The attached patch fixes this to report NULL instead. >=20 > Thanks for the patch! It looks good to me. So, barring any objections, > I'll commit it. Also looks good to me. >=20 > BTW, as a separate issue, is the following also problematic? >=20 > WHEN command =3D 'REPACK' AND repack_index_relid =3D 0 THEN 'VACUUM = FULL' >=20 > 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? >=20 Yes, this is true. Now heapam_relation_copy_for_cluster() only sets = PROGRESS_REPACK_INDEX_RELID if (OldIndex !=3D NULL && !use_sort). So = when enable_indexscan is off, REPACK ... USING INDEX shows VACUUM FULL: ``` REPACK USING INDEX with enable_indexscan =3D 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 =3D 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/ --Apple-Mail=_48A55D46-8DC4-4960-B7A1-2C947DE6E461 Content-Disposition: attachment; filename=repack_index_relid-fix.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="repack_index_relid-fix.diff" Content-Transfer-Encoding: 7bit diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index b403fb990a7..4c1d4b2a80a 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -6806,8 +6806,8 @@ FROM pg_stat_get_backend_idset() AS backendid; cluster_index_relid oid - If the table is being scanned using an index, this is the OID of the - index being used; otherwise, it is zero. + OID of the index defining the order of the rewritten table, or zero + if no index ordering is requested. @@ -7480,8 +7480,8 @@ FROM pg_stat_get_backend_idset() AS backendid; repack_index_relid oid - If the table is being scanned using an index, this is the OID of the - index being used; otherwise, it is zero. + OID of the index defining the order of the rewritten table, or zero + if no index ordering is requested. diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 0f24a132564..dd2218bbbaf 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -660,16 +660,8 @@ heapam_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap, */ if (OldIndex != NULL && !use_sort) { - const int ci_index[] = { - PROGRESS_REPACK_PHASE, - PROGRESS_REPACK_INDEX_RELID - }; - int64 ci_val[2]; - - /* Set phase and OIDOldIndex to columns */ - ci_val[0] = PROGRESS_REPACK_PHASE_INDEX_SCAN_HEAP; - ci_val[1] = RelationGetRelid(OldIndex); - pgstat_progress_update_multi_param(2, ci_index, ci_val); + pgstat_progress_update_param(PROGRESS_REPACK_PHASE, + PROGRESS_REPACK_PHASE_INDEX_SCAN_HEAP); tableScan = NULL; heapScan = NULL; diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c index 57f28f1a420..6f7c37c39b2 100644 --- a/src/backend/commands/repack.c +++ b/src/backend/commands/repack.c @@ -511,6 +511,11 @@ cluster_rel(RepackCommand cmd, Relation OldHeap, Oid indexOid, bool recheck = ((params->options & CLUOPT_RECHECK) != 0); bool concurrent = ((params->options & CLUOPT_CONCURRENT) != 0); Oid ident_idx = InvalidOid; + const int progress_index[] = { + PROGRESS_REPACK_COMMAND, + PROGRESS_REPACK_INDEX_RELID + }; + const int64 progress_values[] = {cmd, indexOid}; /* Determine the lock mode to use. */ lmode = RepackLockLevel(concurrent); @@ -526,7 +531,8 @@ cluster_rel(RepackCommand cmd, Relation OldHeap, Oid indexOid, CHECK_FOR_INTERRUPTS(); pgstat_progress_start_command(PROGRESS_COMMAND_REPACK, tableOid); - pgstat_progress_update_param(PROGRESS_REPACK_COMMAND, cmd); + /* Report the ordering index even when using a sequential scan and sort. */ + pgstat_progress_update_multi_param(2, progress_index, progress_values); /* * Switch to the table owner's userid, so that any index functions are run --Apple-Mail=_48A55D46-8DC4-4960-B7A1-2C947DE6E461--