[ 
https://issues.apache.org/jira/browse/FLINK-23555?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

weibowen updated FLINK-23555:
-----------------------------
    Description: 
When we write a sql like 
{code:java}
select udf2(udf1(field), udf3(udf1(field) ...{code}
udf1(field) will be invoked twice. However once udf1 has a bad performance, it 
will have a huge impact to the whole task. More times invoked, huger impact.

I hope that whatever how many times udf1(field) writed in sql, Flink will take 
advantage of common subexpression elimination and only invoke it once.

Then i do some work on this, and here is the comparison.

 

[^企业微信截图_ec5bf14d-2393-4c31-9c90-f0d2cbc5e827.png]

 

 

  was:
When we write a sql like 

By default, Flink uses {{org.apache.calcite.rex.RexProgram#expandLocalRef}} to 
remove local references which reverses the effect of common subexpression 
elimination


> Improve common subexpression elimination by using local references
> ------------------------------------------------------------------
>
>                 Key: FLINK-23555
>                 URL: https://issues.apache.org/jira/browse/FLINK-23555
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / Planner
>            Reporter: weibowen
>            Priority: Major
>             Fix For: 1.14.0
>
>
> When we write a sql like 
> {code:java}
> select udf2(udf1(field), udf3(udf1(field) ...{code}
> udf1(field) will be invoked twice. However once udf1 has a bad performance, 
> it will have a huge impact to the whole task. More times invoked, huger 
> impact.
> I hope that whatever how many times udf1(field) writed in sql, Flink will 
> take advantage of common subexpression elimination and only invoke it once.
> Then i do some work on this, and here is the comparison.
>  
> [^企业微信截图_ec5bf14d-2393-4c31-9c90-f0d2cbc5e827.png]
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to