dynamobi/dynamobi — Issue #637: [FRG-235] minimize subexpression decomposition in RexProgram
Author: dynamobi-build
Created: 2011-12-30 03:39:44+00:00
State: open
Labels: FRG, Statement Processing

[reporter="jvs", created="Wed, 8 Nov 2006 23:13:49 -0500 (GMT-05:00)"]
Consider an expression like (1+2)*3+(1+2)*5

In a RexProgram, this is fully decompsed into

t1=1

t2=2

t3=$t1+$t2

t4=3

t5=$t3*$t4

t6=5

t7=$t3*$t6

t8=$t5+$t7

In EXPLAIN OUTPUT, this is difficult to read quickly. One possibility is to collapse everything except real common subexpressions, hence

t1=1+2

t2=$t1*3+$t1*5

I recently added RexProgram.getReferenceCounts(), which can be used to distinguish true common subexpressions from other decomposed subexpressions. It would be easy to make RexProgramBuilder perform a smart collapse using something like this. Main impediment is plan .ref updates.