未验证 提交 efdc8ebb 编写于 作者: V Vitaly Baranov 提交者: GitHub

Merge pull request #17589 from ClickHouse/backport/20.12/16988

Backport #16988 to 20.12: Fix performance with Merge table over huge number of MergeTree tables
......@@ -139,11 +139,6 @@ ExpressionAnalyzer::ExpressionAnalyzer(
analyzeAggregation();
}
bool ExpressionAnalyzer::isRemoteStorage() const
{
return storage() && storage()->isRemote();
}
void ExpressionAnalyzer::analyzeAggregation()
{
......
......@@ -164,7 +164,7 @@ protected:
const ASTSelectQuery * getSelectQuery() const;
bool isRemoteStorage() const;
bool isRemoteStorage() const { return syntax->is_remote_storage; }
};
class SelectQueryExpressionAnalyzer;
......
......@@ -387,6 +387,19 @@ std::vector<const ASTFunction *> getAggregates(ASTPtr & query, const ASTSelectQu
}
TreeRewriterResult::TreeRewriterResult(
const NamesAndTypesList & source_columns_,
ConstStoragePtr storage_,
const StorageMetadataPtr & metadata_snapshot_,
bool add_special)
: storage(storage_)
, metadata_snapshot(metadata_snapshot_)
, source_columns(source_columns_)
{
collectSourceColumns(add_special);
is_remote_storage = storage && storage->isRemote();
}
/// Add columns from storage to source_columns list. Deduplicate resulted list.
/// Special columns are non physical columns, for example ALIAS
void TreeRewriterResult::collectSourceColumns(bool add_special)
......
......@@ -53,6 +53,9 @@ struct TreeRewriterResult
bool optimize_trivial_count = false;
/// Cache isRemote() call for storage, because it may be too heavy.
bool is_remote_storage = false;
/// Results of scalar sub queries
Scalars scalars;
......@@ -60,13 +63,7 @@ struct TreeRewriterResult
const NamesAndTypesList & source_columns_,
ConstStoragePtr storage_ = {},
const StorageMetadataPtr & metadata_snapshot_ = {},
bool add_special = true)
: storage(storage_)
, metadata_snapshot(metadata_snapshot_)
, source_columns(source_columns_)
{
collectSourceColumns(add_special);
}
bool add_special = true);
void collectSourceColumns(bool add_special);
void collectUsedColumns(const ASTPtr & query, bool is_select);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册