| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Honor enable_sort and enable_seqscan in CLUSTER and REPACK |
| Date: | 2026-11-24 02:36:25 |
| Message-ID: | E1xVgOO-000000005iD-39mT@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Honor enable_sort and enable_seqscan in CLUSTER and REPACK
CLUSTER and REPACK USING INDEX could choose a sequential scan and sort
even when enable_sort or enable_seqscan was off and an enabled index
scan was available. This could also cause unexpected temporary disk
usage for sorting.
The cause was that plan_cluster_use_sort() compared only total costs,
ignoring the disabled-node counts used to enforce these settings.
In v19 and later, it also left default_pgs_mask at zero, marking both
scan paths as disabled regardless of enable_seqscan.
Fix this by using compare_path_costs() to compare disabled-node counts
before costs, and initializing the strategy mask for the scan paths.
An enabled index scan is now preferred when either enable_sort or
enable_seqscan is off, regardless of the estimated costs.
Backpatch to v18, where the cost comparison regression was introduced.
Reported-by: Noah <imchifan8(at)gmail(dot)com>
Author: Raja Sai Pranav <rajasaipranav0(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/19881-cc00ace224a1fa3e@postgresql.org
Backpatch-through: 18
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/d51990fdba1f3afb267eb6051b32283a20de6387
Modified Files
--------------
src/backend/optimizer/plan/planner.c | 12 +++++++++++-
src/test/regress/expected/cluster.out | 22 ++++++++++++++++++++++
src/test/regress/sql/cluster.sql | 17 +++++++++++++++++
3 files changed, 50 insertions(+), 1 deletion(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-11-24 03:27:43 | pgsql: Allocate pgstats entry body before insert into shared hashtable |
| Previous Message | Masahiko Sawada | 2026-11-23 23:11:04 | pgsql: Add an xid argument to the logical decoding message callbacks. |