diff --git a/src/Storages/StorageFile.cpp b/src/Storages/StorageFile.cpp index 9972549c292..fc36b4a9f62 100644 --- a/src/Storages/StorageFile.cpp +++ b/src/Storages/StorageFile.cpp @@ -51,6 +51,7 @@ #include #include #include +#include namespace ProfileEvents @@ -606,8 +607,11 @@ public: if (!read_buf) read_buf = createReadBuffer(current_path, storage->use_table_fd, storage->getName(), storage->table_fd, storage->compression_method, context); + const Settings & settings = context->getSettingsRef(); + chassert(storage->paths.size()); + const auto max_parsing_threads = std::max(settings.max_threads/storage->paths.size(),1UL); auto format - = context->getInputFormat(storage->format_name, *read_buf, block_for_format, max_block_size, storage->format_settings, storage->paths.size()); + = context->getInputFormat(storage->format_name, *read_buf, block_for_format, max_block_size, storage->format_settings, max_parsing_threads); QueryPipelineBuilder builder; builder.init(Pipe(format));