diff --git a/dbms/src/Interpreters/Aggregator.cpp b/dbms/src/Interpreters/Aggregator.cpp index 963184eac7b..d86ec714294 100644 --- a/dbms/src/Interpreters/Aggregator.cpp +++ b/dbms/src/Interpreters/Aggregator.cpp @@ -501,6 +501,7 @@ Block Aggregator::convertToBlock(AggregatedDataVariants & data_variants) AggregatedDataWithUInt64Key & data = data_variants.key64; IColumn & first_column = *key_columns[0]; + first_column.reserve(data.size() + with_totals); size_t j = with_totals ? 1 : 0; for (AggregatedDataWithUInt64Key::const_iterator it = data.begin(); it != data.end(); ++it, ++j) @@ -515,6 +516,7 @@ Block Aggregator::convertToBlock(AggregatedDataVariants & data_variants) { AggregatedDataWithStringKey & data = data_variants.key_string; IColumn & first_column = *key_columns[0]; + first_column.reserve(data.size() + with_totals); size_t j = with_totals ? 1 : 0; for (AggregatedDataWithStringKey::const_iterator it = data.begin(); it != data.end(); ++it, ++j) @@ -529,6 +531,9 @@ Block Aggregator::convertToBlock(AggregatedDataVariants & data_variants) { AggregatedDataWithKeys128 & data = data_variants.keys128; + for (size_t i = 0; i < keys_size; ++i) + key_columns[i]->reserve(data.size() + with_totals); + size_t j = with_totals ? 1 : 0; for (AggregatedDataWithKeys128::const_iterator it = data.begin(); it != data.end(); ++it, ++j) { @@ -548,6 +553,9 @@ Block Aggregator::convertToBlock(AggregatedDataVariants & data_variants) { AggregatedDataHashed & data = data_variants.hashed; + for (size_t i = 0; i < keys_size; ++i) + key_columns[i]->reserve(data.size() + with_totals); + size_t j = with_totals ? 1 : 0; for (AggregatedDataHashed::const_iterator it = data.begin(); it != data.end(); ++it, ++j) {