LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
53 stars 24 forks source link

[FRG-235] minimize subexpression decomposition in RexProgram #637

Open dynamobi-build opened 12 years ago

dynamobi-build commented 12 years ago

[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.

dynamobi-build commented 12 years ago

[author="jvs", created="Wed, 8 Nov 2006 23:14:53 -0500 (GMT-05:00)"] Julian, would you be OK with this change?

dynamobi-build commented 12 years ago

[author="jhyde", created="Wed, 8 Nov 2006 23:42:27 -0500 (GMT-05:00)"] No objections in principle.

However, it might be more difficult to write RexProgramBuilder code, since you can no longer assume that each operand of an expression is a RexLocalRef.

It might be simpler to simplify the expression when printing it, but keep the uniform internal representation inside RexProgram.