Skip to content

Commit 571abfd

Browse files
Disable trivial count optimization with additional_table_filters in analyzer.
1 parent e718dd8 commit 571abfd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Planner/PlannerJoinTree.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ bool applyTrivialCountIfPossible(
208208
if (row_policy_filter)
209209
return {};
210210

211+
if (select_query_info.additional_filter_ast)
212+
return false;
213+
211214
/** Transaction check here is necessary because
212215
* MergeTree maintains total count for all parts in Active state and it simply returns that number for trivial select count() from table query.
213216
* But if we have current transaction, then we should return number of rows in current snapshot (that may include parts in Outdated state),
@@ -663,6 +666,7 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres
663666
is_single_table_expression &&
664667
(table_node || table_function_node) &&
665668
select_query_info.has_aggregates &&
669+
settings.additional_table_filters.value.empty() &&
666670
applyTrivialCountIfPossible(query_plan, table_expression_query_info, table_node, table_function_node, select_query_info.query_tree, planner_context->getMutableQueryContext(), table_expression_data.getColumnNames());
667671

668672
if (is_trivial_count_applied)

0 commit comments

Comments
 (0)