From 647ff835c42ddd5a0d227a6faa59939789605e7f Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Jun 2014 03:34:44 +0400 Subject: [PATCH] dbms: improved performance of system.numbers table [#METR-11434]. --- dbms/src/Storages/StorageSystemNumbers.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dbms/src/Storages/StorageSystemNumbers.cpp b/dbms/src/Storages/StorageSystemNumbers.cpp index 0059c0561df..06114a143be 100644 --- a/dbms/src/Storages/StorageSystemNumbers.cpp +++ b/dbms/src/Storages/StorageSystemNumbers.cpp @@ -30,11 +30,15 @@ Block NumbersBlockInputStream::readImpl() ColumnUInt64::Container_t & vec = column->getData(); column_with_name_and_type.column = column; - for (size_t i = 0; i < block_size; ++i) - vec[i] = next++; + size_t curr = next; /// Локальная переменная почему-то работает быстрее (>20%), чем член класса. + UInt64 * pos = &vec[0]; /// Это тоже ускоряет код. + UInt64 * end = &vec[block_size]; + while (pos < end) + *pos++ = curr++; + next = curr; res.insert(column_with_name_and_type); - + return res; }