1 aggregationscale_all 1111111 111111 11111 aggregationscale_small 111111 11111 aggregationscale_big 1111111 111111 create table mingroupby_orderbylimit1_{aggregationscale_all}_tuple Engine=MergeTree order by tuple() AS select toUInt64( number % {aggregationscale_all} ) key, toUInt64(1) value from numbers(2000000); create table mingroupby_orderbylimit1_{aggregationscale_all}_key_value Engine=MergeTree order by (key,value) AS select toUInt64( number % {aggregationscale_all} ) key, toUInt64(1) value from numbers(2000000); SELECT key, min(value) FROM mingroupby_orderbylimit1_{aggregationscale_big}_tuple group by key format Null; SELECT key, min(value) FROM mingroupby_orderbylimit1_{aggregationscale_big}_key_value group by key format Null; SELECT key, value FROM mingroupby_orderbylimit1_{aggregationscale_small}_tuple order by key, value limit 1 by key format Null; SELECT key, value FROM mingroupby_orderbylimit1_{aggregationscale_small}_key_value order by key, value limit 1 by key format Null; DROP TABLE IF EXISTS mingroupby_orderbylimit1_{aggregationscale_all}_tuple DROP TABLE IF EXISTS mingroupby_orderbylimit1_{aggregationscale_all}_key_value