From 435394242ca5b08d179be16a6bfe966a8d243764 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 17 Aug 2014 06:17:23 +0400 Subject: [PATCH] dbms: improved performance of filtering [#METR-2944]. --- dbms/src/DataStreams/FilterBlockInputStream.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dbms/src/DataStreams/FilterBlockInputStream.cpp b/dbms/src/DataStreams/FilterBlockInputStream.cpp index 3a36d42b710..75de7654b96 100644 --- a/dbms/src/DataStreams/FilterBlockInputStream.cpp +++ b/dbms/src/DataStreams/FilterBlockInputStream.cpp @@ -88,6 +88,15 @@ Block FilterBlockInputStream::readImpl() if (filtered_rows == 0) continue; + /// Если через фильтр проходят все строчки. + if (filtered_rows == filter.size()) + { + /// Заменим столбец с фильтром на константу. + res.getByPosition(filter_column).column = new ColumnConstUInt8(filtered_rows, 1); + /// Остальные столбцы трогать не нужно. + return res; + } + /// Фильтруем остальные столбцы. for (size_t i = 0; i < columns; ++i) {