mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #3340 from CurtizJ/issue-3253
Fix unnecessarily preparations for join at initial server [ISSUE-3253]
This commit is contained in:
commit
b9ecc4b819
@ -574,14 +574,20 @@ void ExpressionAnalyzer::initGlobalSubqueries(ASTPtr & ast)
|
||||
{
|
||||
/// For GLOBAL IN.
|
||||
if (do_global && (func->name == "globalIn" || func->name == "globalNotIn"))
|
||||
{
|
||||
addExternalStorage(func->arguments->children.at(1));
|
||||
has_global_subqueries = true;
|
||||
}
|
||||
}
|
||||
else if (ASTTablesInSelectQueryElement * table_elem = typeid_cast<ASTTablesInSelectQueryElement *>(ast.get()))
|
||||
{
|
||||
/// For GLOBAL JOIN.
|
||||
if (do_global && table_elem->table_join
|
||||
&& static_cast<const ASTTableJoin &>(*table_elem->table_join).locality == ASTTableJoin::Locality::Global)
|
||||
{
|
||||
addExternalStorage(table_elem->table_expression);
|
||||
has_global_subqueries = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,8 @@ public:
|
||||
|
||||
bool isRewriteSubqueriesPredicate() { return rewrite_subqueries; }
|
||||
|
||||
bool hasGlobalSubqueries() { return has_global_subqueries; }
|
||||
|
||||
private:
|
||||
ASTPtr query;
|
||||
ASTSelectQuery * select_query;
|
||||
@ -216,6 +218,7 @@ private:
|
||||
|
||||
/// Do I need to prepare for execution global subqueries when analyzing the query.
|
||||
bool do_global;
|
||||
bool has_global_subqueries = false;
|
||||
|
||||
SubqueriesForSets subqueries_for_sets;
|
||||
|
||||
|
@ -549,6 +549,10 @@ void InterpreterSelectQuery::executeImpl(Pipeline & pipeline, const BlockInputSt
|
||||
if (query.limit_length)
|
||||
executePreLimit(pipeline);
|
||||
}
|
||||
|
||||
// If there is no global subqueries, we can run subqueries only when recieve them on server.
|
||||
if (!query_analyzer->hasGlobalSubqueries() && !expressions.subqueries_for_sets.empty())
|
||||
executeSubqueriesInSetsAndJoins(pipeline, expressions.subqueries_for_sets);
|
||||
}
|
||||
|
||||
if (expressions.second_stage)
|
||||
@ -654,7 +658,7 @@ void InterpreterSelectQuery::executeImpl(Pipeline & pipeline, const BlockInputSt
|
||||
}
|
||||
}
|
||||
|
||||
if (!expressions.subqueries_for_sets.empty())
|
||||
if (query_analyzer->hasGlobalSubqueries() && !expressions.subqueries_for_sets.empty())
|
||||
executeSubqueriesInSetsAndJoins(pipeline, expressions.subqueries_for_sets);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user