From f61ea15d56e0624accec14f7f1e966ad3e1e3ce0 Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Fri, 16 Jul 2021 20:40:00 +0300 Subject: [PATCH] fix pushdown of limit to reading stage --- src/Interpreters/InterpreterSelectQuery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp index 0750dd6e27c..95a8da4216c 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -1925,7 +1925,7 @@ void InterpreterSelectQuery::executeFetchColumns(QueryProcessingStage::Enum proc } /// If we don't have filtration, we can pushdown limit to reading stage for optimizations. - UInt64 limit = (query.where() || query.prewhere()) ? 0 : getLimitForSorting(query, context); + UInt64 limit = (query.where() || query.prewhere() || query.groupBy()) ? 0 : getLimitForSorting(query, context); if (query_info.projection) query_info.projection->input_order_info = query_info.projection->order_optimizer->getInputOrder(query_info.projection->desc->metadata, context, limit);