Do not apply the optimization when plan is built only for analysis

This commit is contained in:
Igor Nikonov 2023-03-06 10:47:32 +00:00
parent b6f05a6399
commit 56e8547f7e

View File

@ -410,13 +410,12 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(const QueryTreeNodePtr & tabl
}
/// Apply trivial_count optimization if possible
bool is_trivial_count_applied = is_single_table_expression && table_node && select_query_info.has_aggregates
bool is_trivial_count_applied = !select_query_options.only_analyze && is_single_table_expression && table_node && select_query_info.has_aggregates
&& applyTrivialCountIfPossible(query_plan, *table_node, select_query_info.query_tree, planner_context->getQueryContext(), columns_names);
if (is_trivial_count_applied)
{
if (!select_query_options.only_analyze)
from_stage = QueryProcessingStage::WithMergeableState;
from_stage = QueryProcessingStage::WithMergeableState;
}
else
{