mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #11114 from azat/max_threads-simple-query-optimization-fix
Do not reserve extra threads after max threads optimization for simple queries
This commit is contained in:
commit
c83014bc76
@ -1533,7 +1533,7 @@ void InterpreterSelectQuery::executeFetchColumns(
|
||||
if constexpr (pipeline_with_processors)
|
||||
{
|
||||
if (streams.size() == 1 || pipes.size() == 1)
|
||||
pipeline.setMaxThreads(streams.size());
|
||||
pipeline.setMaxThreads(1);
|
||||
|
||||
/// Unify streams. They must have same headers.
|
||||
if (streams.size() > 1)
|
||||
|
@ -271,6 +271,11 @@ QueryPipeline InterpreterSelectWithUnionQuery::executeWithProcessors()
|
||||
{
|
||||
auto common_header = getCommonHeaderForUnion(headers);
|
||||
main_pipeline.unitePipelines(std::move(pipelines), common_header);
|
||||
|
||||
// nested queries can force 1 thread (due to simplicity)
|
||||
// but in case of union this cannot be done.
|
||||
UInt64 max_threads = context->getSettingsRef().max_threads;
|
||||
main_pipeline.setMaxThreads(std::min<UInt64>(nested_interpreters.size(), max_threads));
|
||||
}
|
||||
|
||||
main_pipeline.addInterpreterContext(context);
|
||||
|
@ -0,0 +1,21 @@
|
||||
DROP TABLE IF EXISTS data_01283;
|
||||
|
||||
CREATE TABLE data_01283 engine=MergeTree()
|
||||
ORDER BY key
|
||||
PARTITION BY key
|
||||
AS SELECT number key FROM numbers(10);
|
||||
|
||||
SET log_queries=1;
|
||||
SELECT * FROM data_01283 LIMIT 1 FORMAT Null;
|
||||
SET log_queries=0;
|
||||
SYSTEM FLUSH LOGS;
|
||||
|
||||
-- 1 for PullingAsyncPipelineExecutor::pull
|
||||
-- 1 for AsynchronousBlockInputStream
|
||||
SELECT
|
||||
throwIf(count() != 1, 'no query was logged'),
|
||||
throwIf(length(thread_ids) != 2, 'too many threads used')
|
||||
FROM system.query_log
|
||||
WHERE type = 'QueryFinish' AND query LIKE '%data_01283 LIMIT 1%'
|
||||
GROUP BY thread_ids
|
||||
FORMAT Null;
|
Loading…
Reference in New Issue
Block a user