mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
dbms: Server: Performance improvement. [#METR-16778]
This commit is contained in:
parent
b4f65a44e9
commit
135cac6d77
@ -36,11 +36,14 @@ public:
|
|||||||
|
|
||||||
ASTPtr clone() const override;
|
ASTPtr clone() const override;
|
||||||
|
|
||||||
|
/// Получить глубокую копию дерева первого запроса SELECT.
|
||||||
|
ASTPtr cloneFirstSelect() const;
|
||||||
|
|
||||||
/// Возвращает указатель на формат из последнего SELECT'а цепочки UNION ALL.
|
/// Возвращает указатель на формат из последнего SELECT'а цепочки UNION ALL.
|
||||||
const IAST * getFormat() const override;
|
const IAST * getFormat() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPtr cloneImpl() const;
|
ASTPtr cloneImpl(bool traverse_union_all) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool distinct = false;
|
bool distinct = false;
|
||||||
|
@ -720,10 +720,7 @@ QueryProcessingStage::Enum InterpreterSelectQuery::executeFetchColumns(BlockInpu
|
|||||||
if (storage->isRemote())
|
if (storage->isRemote())
|
||||||
{
|
{
|
||||||
/// В случае удаленного запроса отправляем только SELECT, который выполнится.
|
/// В случае удаленного запроса отправляем только SELECT, который выполнится.
|
||||||
actual_query_ptr = query_ptr->clone();
|
actual_query_ptr = query.cloneFirstSelect();
|
||||||
auto actual_select_query = static_cast<ASTSelectQuery *>(&*actual_query_ptr);
|
|
||||||
actual_select_query->prev_union_all = nullptr;
|
|
||||||
actual_select_query->next_union_all = nullptr;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
actual_query_ptr = query_ptr;
|
actual_query_ptr = query_ptr;
|
||||||
|
@ -134,7 +134,7 @@ void ASTSelectQuery::rewriteSelectExpressionList(const Names & column_names)
|
|||||||
|
|
||||||
ASTPtr ASTSelectQuery::clone() const
|
ASTPtr ASTSelectQuery::clone() const
|
||||||
{
|
{
|
||||||
ASTPtr ptr = cloneImpl();
|
ASTPtr ptr = cloneImpl(true);
|
||||||
|
|
||||||
/// Установить указатели на предыдущие запросы SELECT.
|
/// Установить указатели на предыдущие запросы SELECT.
|
||||||
ASTPtr current = ptr;
|
ASTPtr current = ptr;
|
||||||
@ -150,7 +150,14 @@ ASTPtr ASTSelectQuery::clone() const
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTPtr ASTSelectQuery::cloneImpl() const
|
ASTPtr ASTSelectQuery::cloneFirstSelect() const
|
||||||
|
{
|
||||||
|
ASTPtr res = cloneImpl(false);
|
||||||
|
static_cast<ASTSelectQuery *>(&*res)->prev_union_all = nullptr;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASTPtr ASTSelectQuery::cloneImpl(bool traverse_union_all) const
|
||||||
{
|
{
|
||||||
ASTSelectQuery * res = new ASTSelectQuery(*this);
|
ASTSelectQuery * res = new ASTSelectQuery(*this);
|
||||||
ASTPtr ptr{res};
|
ASTPtr ptr{res};
|
||||||
@ -187,11 +194,16 @@ ASTPtr ASTSelectQuery::cloneImpl() const
|
|||||||
|
|
||||||
#undef CLONE
|
#undef CLONE
|
||||||
|
|
||||||
if (next_union_all)
|
if (traverse_union_all)
|
||||||
{
|
{
|
||||||
res->next_union_all = static_cast<const ASTSelectQuery *>(&*next_union_all)->cloneImpl();
|
if (next_union_all)
|
||||||
res->children.push_back(res->next_union_all);
|
{
|
||||||
|
res->next_union_all = static_cast<const ASTSelectQuery *>(&*next_union_all)->cloneImpl(true);
|
||||||
|
res->children.push_back(res->next_union_all);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
res->next_union_all = nullptr;
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user