Currently expressions in alias columns are executed in 'greedy' way (so they are calculated also for the rows which will be thrown away).
drop table if exists aliases_lazyness;
create table aliases_lazyness (x UInt32, y ALIAS sleepEachRow(0.1)) Engine=MergeTree ORDER BY x;
insert into aliases_lazyness(x) select * from numbers(40);
SELECT x,y FROM aliases_lazyness WHERE x = 1;
-- that will calc y for all 40 raws (and die because of too big sleep time requested)
SELECT x, sleepEachRow(0.1) as y FROM aliases_lazyness WHERE x = 1;
-- that will calc y for 4 rows (one data block?). Acceptable.
SELECT x, y FROM aliases_lazyness PREWHERE x = 1;
-- that will calc y for 1 row. Perfect.
Why can't first select work as 3rd or at least second?
Motivation: We've created some handy aliases for some complicated expressions which involve dict lookups, and some processing to make it easier for users to access them without copy & paste of those complicated expressions. But when users try to use that aliases - it works much slower than when expressions appears in selects directly.
Currently expressions in alias columns are executed in 'greedy' way (so they are calculated also for the rows which will be thrown away).
Why can't first select work as 3rd or at least second?
Motivation: We've created some handy aliases for some complicated expressions which involve dict lookups, and some processing to make it easier for users to access them without copy & paste of those complicated expressions. But when users try to use that aliases - it works much slower than when expressions appears in selects directly.