Call getQueryProcessingStage() once, since it is heavy for StorageDistributed

Refs: #9808
This commit is contained in:
Azat Khuzhin 2020-04-01 21:38:01 +03:00
parent 1777e2fd6b
commit 8d372b0be7

View File

@ -287,7 +287,8 @@ Pipes StorageMerge::createSources(const SelectQueryInfo & query_info, const Quer
return pipes;
}
if (processed_stage <= storage->getQueryProcessingStage(*modified_context, query_info.query))
auto storage_stage = storage->getQueryProcessingStage(*modified_context, query_info.query);
if (processed_stage <= storage_stage)
{
/// If there are only virtual columns in query, you must request at least one other column.
if (real_column_names.empty())
@ -295,7 +296,7 @@ Pipes StorageMerge::createSources(const SelectQueryInfo & query_info, const Quer
pipes = storage->read(real_column_names, modified_query_info, *modified_context, processed_stage, max_block_size, UInt32(streams_num));
}
else if (processed_stage > storage->getQueryProcessingStage(*modified_context, query_info.query))
else if (processed_stage > storage_stage)
{
modified_query_info.query->as<ASTSelectQuery>()->replaceDatabaseAndTable(source_database, table_name);