Open findepi opened 5 years ago
The problem here could be estimating when it's worth to do subexpression extraction (how complex it should be to consider extraction). On one hand, CPU could optimize expression evaluation. On the other hand, if you added another projection for that subexpression then the overhead might not be worth it.
Perhaps some approach when common subexpression is evaluated once within generated bytecode for two expressions is feasible and would not introduce any overhead.
Hi @findepi I am just wondering. Is this optimization related to common sub-expression elimination? As it has been implemented in Presto 0.245 version. Thanks.
In case of a query that computes a deterministic sub-expression multiple times, we should compute it only once.
For example, the following query could compute
split(x, '_')[2]
once and reuse.