Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizer: eliminate common sub-expressions #658

Open
lokax opened this issue Jun 2, 2022 · 1 comment
Open

Optimizer: eliminate common sub-expressions #658

lokax opened this issue Jun 2, 2022 · 1 comment

Comments

@lokax
Copy link
Member

lokax commented Jun 2, 2022

In the present, the optimizer doesn't realize any information abount common expression.
This causes the Expression Evaluator to evaluate expressions repeatedly for every input tuple.

For Example:

> explain select x * 2 + y, x * 2 + y + 4 from test;
PhysicalProjection:
    ((InputRef #0 * 2) + InputRef #1)
    (((InputRef #0 * 2) + InputRef #1) + 4)
  PhysicalTableScan:
      table #0,
      columns [0, 1],
      with_row_handler: false,
      is_sorted: false,
      expr: None

Maybe we should rewrite the plan to:

> explain select x * 2 + y, x * 2 + y + 4 from test;
PhysicalProjection:
    (InputRef #0)
    ((InputRef #0) + 4) 
  PhysicalProjection:
      ((InputRef #0 * 2) + InputRef #1)
    PhysicalTableScan:
          table #0,
          columns [0, 1],
          with_row_handler: false,
          is_sorted: false,
          expr: None
@skyzh
Copy link
Member

skyzh commented Jun 2, 2022

That's cool! We can see if we can do this optimization with optimizer rule 🤣

@lokax lokax changed the title Optimizer: eliminate common expressions Optimizer: eliminate common sub-expressions Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants