From 9dc5530429083195e90129b3eb18f8d7a5f78451 Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Tue, 9 Jul 2019 13:36:42 +0200 Subject: [PATCH 4/4] add force_incremental_sort GUC --- src/backend/optimizer/path/costsize.c | 8 ++++++++ src/backend/utils/misc/guc.c | 10 ++++++++++ src/include/optimizer/cost.h | 1 + 3 files changed, 19 insertions(+) diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index c6aa17ba67..ee4487b158 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -140,6 +140,8 @@ bool enable_parallel_append = true; bool enable_parallel_hash = true; bool enable_partition_pruning = true; +bool force_incremental_sort = true; + typedef struct { PlannerInfo *root; @@ -1907,6 +1909,12 @@ cost_incremental_sort(Path *path, path->rows = input_tuples; path->startup_cost = startup_cost; path->total_cost = startup_cost + run_cost; + + if (force_incremental_sort) + { + path->startup_cost = input_startup_cost; + path->total_cost = input_total_cost; + } } /* diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index f922ee66a0..d2cc5b56b5 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -941,6 +941,16 @@ static struct config_bool ConfigureNamesBool[] = true, NULL, NULL, NULL }, + { + {"force_incremental_sort", PGC_USERSET, QUERY_TUNING_METHOD, + gettext_noop("Makes the incremental sort look like no-cost."), + NULL, + GUC_EXPLAIN + }, + &force_incremental_sort, + false, + NULL, NULL, NULL + }, { {"enable_incrementalsort", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of incremental sort steps."), diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index b9d7a77e65..bad1d5a330 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -66,6 +66,7 @@ extern PGDLLIMPORT bool enable_parallel_append; extern PGDLLIMPORT bool enable_parallel_hash; extern PGDLLIMPORT bool enable_partition_pruning; extern PGDLLIMPORT int constraint_exclusion; +extern PGDLLIMPORT bool force_incremental_sort; extern double index_pages_fetched(double tuples_fetched, BlockNumber pages, double index_pages, PlannerInfo *root); -- 2.21.0