Add optimize setting to explain plan.

This commit is contained in:
Nikolai Kochetov 2020-09-23 20:42:46 +03:00
parent c320e77cb5
commit 74e785a2fe

View File

@ -119,13 +119,17 @@ struct QueryPlanSettings
{
QueryPlan::ExplainPlanOptions query_plan_options;
/// Apply query plan optimisations.
bool optimize = true;
constexpr static char name[] = "PLAN";
std::unordered_map<std::string, std::reference_wrapper<bool>> boolean_settings =
{
{"header", query_plan_options.header},
{"description", query_plan_options.description},
{"actions", query_plan_options.actions}
{"actions", query_plan_options.actions},
{"optimize", optimize},
};
};
@ -248,7 +252,8 @@ BlockInputStreamPtr InterpreterExplainQuery::executeImpl()
InterpreterSelectWithUnionQuery interpreter(ast.getExplainedQuery(), context, SelectQueryOptions());
interpreter.buildQueryPlan(plan);
plan.optimize();
if (settings.optimize)
plan.optimize();
WriteBufferFromOStream buffer(ss);
plan.explainPlan(buffer, settings.query_plan_options);