pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Honor enable_sort and enable_seqscan in CLUSTER and REPACK 3+ messages / 1 participants [nested] [flat]
* pgsql: Honor enable_sort and enable_seqscan in CLUSTER and REPACK @ 2026-11-24 02:36 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Fujii Masao @ 2026-11-24 02:36 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Raja Sai Pranav <rajasaipranav0@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/19881-cc00ace224a1fa3e@postgresql.org Backpatch-through: 18 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/927939e924a0cb5ab400df32212ced0d72b02869 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Honor enable_sort and enable_seqscan in CLUSTER and REPACK @ 2026-11-24 02:36 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Fujii Masao @ 2026-11-24 02:36 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Raja Sai Pranav <rajasaipranav0@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Honor enable_sort and enable_seqscan in CLUSTER and REPACK @ 2026-11-24 02:36 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Fujii Masao @ 2026-11-24 02:36 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Raja Sai Pranav <rajasaipranav0@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/19881-cc00ace224a1fa3e@postgresql.org Backpatch-through: 18 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d7025bf715cf94f2c5d16aae47a04626397993d7 Modified Files -------------- src/backend/optimizer/plan/planner.c | 4 +++- src/test/regress/expected/cluster.out | 22 ++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 17 +++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-11-24 02:36 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-24 02:36 pgsql: Honor enable_sort and enable_seqscan in CLUSTER and REPACK Fujii Masao <fujii@postgresql.org> 2026-11-24 02:36 pgsql: Honor enable_sort and enable_seqscan in CLUSTER and REPACK Fujii Masao <fujii@postgresql.org> 2026-11-24 02:36 pgsql: Honor enable_sort and enable_seqscan in CLUSTER and REPACK Fujii Masao <fujii@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox