mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Move QueryPipelineBuilder::setMaxThreads() into the InterpreterInsertQuery
This commit is contained in:
parent
ae5570e6d6
commit
83c271f446
@ -398,19 +398,23 @@ BlockIO InterpreterInsertQuery::execute()
|
||||
return std::make_shared<ExpressionTransform>(in_header, actions);
|
||||
});
|
||||
|
||||
auto num_select_threads = pipeline.getNumThreads();
|
||||
|
||||
size_t num_select_threads = pipeline.getNumThreads();
|
||||
size_t num_insert_threads = std::max_element(out_chains.begin(), out_chains.end(), [&](const auto &a, const auto &b)
|
||||
{
|
||||
return a.getNumThreads() < b.getNumThreads();
|
||||
})->getNumThreads();
|
||||
pipeline.addChains(std::move(out_chains));
|
||||
|
||||
pipeline.setMaxThreads(num_insert_threads);
|
||||
/// Don't use more threads for insert then for select to reduce memory consumption.
|
||||
if (!settings.parallel_view_processing && pipeline.getNumThreads() > num_select_threads)
|
||||
pipeline.setMaxThreads(num_select_threads);
|
||||
|
||||
pipeline.setSinks([&](const Block & cur_header, QueryPipelineBuilder::StreamType) -> ProcessorPtr
|
||||
{
|
||||
return std::make_shared<EmptySink>(cur_header);
|
||||
});
|
||||
|
||||
/// Don't use more threads for insert then for select to reduce memory consumption.
|
||||
if (!settings.parallel_view_processing && pipeline.getNumThreads() > num_select_threads)
|
||||
pipeline.setMaxThreads(num_select_threads);
|
||||
|
||||
if (!allow_materialized)
|
||||
{
|
||||
for (const auto & column : metadata_snapshot->getColumns())
|
||||
|
@ -139,7 +139,6 @@ void QueryPipelineBuilder::addChains(std::vector<Chain> chains)
|
||||
{
|
||||
checkInitializedAndNotCompleted();
|
||||
pipe.addChains(std::move(chains));
|
||||
setMaxThreads(pipe.maxParallelStreams());
|
||||
}
|
||||
|
||||
void QueryPipelineBuilder::addChain(Chain chain)
|
||||
@ -149,7 +148,6 @@ void QueryPipelineBuilder::addChain(Chain chain)
|
||||
chains.emplace_back(std::move(chain));
|
||||
pipe.resize(1);
|
||||
pipe.addChains(std::move(chains));
|
||||
setMaxThreads(pipe.maxParallelStreams());
|
||||
}
|
||||
|
||||
void QueryPipelineBuilder::transform(const Transformer & transformer)
|
||||
|
Loading…
Reference in New Issue
Block a user