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

A new rule engine for Optimizer #43360

Closed
elsa0520 opened this issue Apr 24, 2023 · 6 comments · Fixed by #47526
Closed

A new rule engine for Optimizer #43360

elsa0520 opened this issue Apr 24, 2023 · 6 comments · Fixed by #47526
Assignees
Labels
sig/planner SIG: Planner type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@elsa0520
Copy link
Contributor

elsa0520 commented Apr 24, 2023

Feature Request

Is your feature request related to a problem? Please describe:
Current optimizer rewrite rules are executed sequentially once and some specific rules (column prunning) are done multiple times hard coded.

  • Applying rules multiple times is not possible if a rule triggers another rule (for example: eliminating projections triggers join elimination). Missing such cases are lost optimization opportunities.

Describe the feature you'd like:

The New rule engine for pre-processing phase changes logical plan to another logical plan.
It also should satisfy following requirements:

  • Applying rules multiple times by rule engine instead of hard code manually.
  • Clean fast path for fast queries
  • Easier testing for enabling/disabling rules
  • Adding new rules is easier with this new architecture

Design

Design

  • Code factoring:
  • Rule engine design is based on the following abstraction
    • List of API's for rule1, rule2, ... RuleN. (ordered rule set as set of interfaces)
    • Order of rules "RuleOrder" = {RuleX, RuleY, ....}
    • 2 dimensional array of rule interactions where M(i,j) = true means that If Rulei is applied then we should also do Rulej

The final product is depicted in the diagram below where we do pre-processing (FD, derived stats and hint annotations) of rewrites first and then we execute the rewrite engine.

image

@elsa0520 elsa0520 added the type/feature-request Categorizes issue or PR as related to a new feature. label Apr 24, 2023
@elsa0520
Copy link
Contributor Author

Please assign for me and ahmad ~

@elsa0520
Copy link
Contributor Author

Please label planner ~

@elsa0520
Copy link
Contributor Author

elsa0520 commented Apr 24, 2023

Functional components issue link: #43361

@time-and-fate time-and-fate added the sig/planner SIG: Planner label Apr 24, 2023
@time-and-fate
Copy link
Member

Please assign for me and ahmad ~

You can assign yourself by commenting "/assign" and assign other people by commenting "/assign @username"

@time-and-fate
Copy link
Member

/assign @elsa0520

@elsa0520
Copy link
Contributor Author

/assign @ghazalfamilyusa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
3 participants