for trivial INSERT SELECT, adjust block size in bytes as well

This commit is contained in:
Alexander Kuzmenkov 2021-05-12 12:40:39 +03:00
parent ab75f86ee9
commit 70d4ee3cde

View File

@ -200,6 +200,8 @@ BlockIO InterpreterInsertQuery::execute()
if (is_trivial_insert_select)
{
fmt::print(stderr, "is trivial insert select\n");
/** When doing trivial INSERT INTO ... SELECT ... FROM table,
* don't need to process SELECT with more than max_insert_threads
* and it's reasonable to set block size for SELECT to the desired block size for INSERT
@ -210,8 +212,13 @@ BlockIO InterpreterInsertQuery::execute()
new_settings.max_threads = std::max<UInt64>(1, settings.max_insert_threads);
if (settings.min_insert_block_size_rows && table->prefersLargeBlocks())
if (table->prefersLargeBlocks())
{
if (settings.min_insert_block_size_rows)
new_settings.max_block_size = settings.min_insert_block_size_rows;
if (settings.min_insert_block_size_bytes)
new_settings.preferred_block_size_bytes = settings.min_insert_block_size_bytes;
}
auto new_context = Context::createCopy(context);
new_context->setSettings(new_settings);