Merge pull request #41164 from ClickHouse/revert-41015-window_func_optimization_setting

Revert "Query plan optimization setting: read in window order"
This commit is contained in:
Dmitry Novik 2022-09-10 00:34:33 +02:00 committed by GitHub
commit 1a47426b6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 10 deletions

View File

@ -58,8 +58,6 @@ public:
/// Add limits from external query.
void addStorageLimits(const StorageLimitsList & limits);
ContextPtr getContext() const { return context; }
protected:
ASTPtr query_ptr;
ContextMutablePtr context;

View File

@ -316,7 +316,7 @@ QueryPipeline InterpreterExplainQuery::executeImpl()
interpreter.buildQueryPlan(plan);
if (settings.optimize)
plan.optimize(QueryPlanOptimizationSettings::fromContext(interpreter.getContext()));
plan.optimize(QueryPlanOptimizationSettings::fromContext(getContext()));
if (settings.json)
{
@ -326,7 +326,7 @@ QueryPipeline InterpreterExplainQuery::executeImpl()
auto plan_array = std::make_unique<JSONBuilder::JSONArray>();
plan_array->add(std::move(plan_map));
auto format_settings = getFormatSettings(interpreter.getContext());
auto format_settings = getFormatSettings(getContext());
format_settings.json.quote_64bit_integers = false;
JSONBuilder::FormatSettings json_format_settings{.settings = format_settings};

View File

@ -63,7 +63,7 @@ inline const auto & getOptimizations()
{tryMergeExpressions, "mergeExpressions", &QueryPlanOptimizationSettings::optimize_plan},
{tryPushDownFilter, "pushDownFilter", &QueryPlanOptimizationSettings::filter_push_down},
{tryExecuteFunctionsAfterSorting, "liftUpFunctions", &QueryPlanOptimizationSettings::optimize_plan},
{tryReuseStorageOrderingForWindowFunctions, "reuseStorageOrderingForWindowFunctions", &QueryPlanOptimizationSettings::optimize_read_in_window_order}
{tryReuseStorageOrderingForWindowFunctions, "reuseStorageOrderingForWindowFunctions", &QueryPlanOptimizationSettings::optimize_plan}
}};
return optimizations;

View File

@ -11,7 +11,6 @@ QueryPlanOptimizationSettings QueryPlanOptimizationSettings::fromSettings(const
settings.optimize_plan = from.query_plan_enable_optimizations;
settings.max_optimizations_to_apply = from.query_plan_max_optimizations_to_apply;
settings.filter_push_down = from.query_plan_filter_push_down;
settings.optimize_read_in_window_order = from.optimize_read_in_window_order;
return settings;
}

View File

@ -21,9 +21,6 @@ struct QueryPlanOptimizationSettings
/// If filter push down optimization is enabled.
bool filter_push_down = true;
/// window functions read in order optimization
bool optimize_read_in_window_order = true;
static QueryPlanOptimizationSettings fromSettings(const Settings & from);
static QueryPlanOptimizationSettings fromContext(ContextPtr from);
};

View File

@ -61,7 +61,12 @@ size_t tryReuseStorageOrderingForWindowFunctions(QueryPlan::Node * parent_node,
return 0;
}
const auto context = read_from_merge_tree->getContext();
auto context = read_from_merge_tree->getContext();
if (!context->getSettings().optimize_read_in_window_order)
{
return 0;
}
const auto & query_info = read_from_merge_tree->getQueryInfo();
const auto * select_query = query_info.query->as<ASTSelectQuery>();