fix wrong check for disabling "read in order" optimization

This commit is contained in:
CurtizJ 2019-08-21 20:42:44 +03:00
parent a1560448d6
commit d573c4ec3e
3 changed files with 8 additions and 1 deletions

View File

@ -884,7 +884,7 @@ void InterpreterSelectQuery::executeImpl(TPipeline & pipeline, const BlockInputS
}
SortingInfoPtr sorting_info;
if (settings.optimize_read_in_order && storage && query.orderBy() && !query.groupBy() && !query.final() && !query.join())
if (settings.optimize_read_in_order && storage && query.orderBy() && !query_analyzer->hasAggregation() && !query.final() && !query.join())
{
if (const MergeTreeData * merge_tree_data = dynamic_cast<const MergeTreeData *>(storage.get()))
sorting_info = optimizeReadInOrder(*merge_tree_data, query, context, syntax_analyzer_result);

View File

@ -0,0 +1,6 @@
SET optimize_read_in_order = 1;
DROP TABLE IF EXISTS order_with_aggr;
CREATE TABLE order_with_aggr(a Int) ENGINE = MergeTree ORDER BY a;
INSERT INTO order_with_aggr SELECT * FROM numbers(100);
SELECT sum(a) as s FROM order_with_aggr ORDER BY s;