Skip to content

RBO Optimizer implementation#45

Merged
KKould merged 18 commits intoKipData:mainfrom
KKould:main
Aug 17, 2023
Merged

RBO Optimizer implementation#45
KKould merged 18 commits intoKipData:mainfrom
KKould:main

Conversation

@KKould
Copy link
Copy Markdown
Member

@KKould KKould commented Aug 11, 2023

What problem does this PR solve?

Add corresponding issue link with summary if exists -->

Issue link:

What is changed and how it works?

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

@KKould KKould added the enhancement New feature or request label Aug 11, 2023
@KKould KKould added this to the v0.1 milestone Aug 11, 2023
@KKould KKould self-assigned this Aug 11, 2023
KKould added 7 commits August 12, 2023 19:59
…HILD_RULE` Rule to push down the Project to reduce the IO generated by redundant columns
…E` and `COMBINE_FILTERS_RULE` to minimize the calculation amount of Projection and merge Filter calculation
…e the related structure of the Limit operator
…ush the Filter condition before the Join, and only works for the JoinType of Inner/Left/Right
Comment thread src/optimizer/rule/pushdown_limit.rs Outdated
predicate: |op| match op {
Operator::Limit(_) => true,
_ => false
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could simplify code with matches!

Comment thread src/optimizer/rule/pushdown_limit.rs Outdated
}
}

/// Push down `Limit` past a `Project`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect comment

Comment thread src/optimizer/rule/pushdown_limit.rs Outdated
}

/// Push down `Limit` past a `Project`.
pub struct PushLimitIntoTableScan;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub struct PushLimitIntoTableScan;
pub struct PushLimitIntoScan;

Comment on lines +141 to +145
if let Some(grandson_id) = match ty {
JoinType::Left => Some(graph.children_at(child_id)[0]),
JoinType::Right => Some(graph.children_at(child_id)[1]),
_ => None
} {
Copy link
Copy Markdown
Member

@lewiszlw lewiszlw Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss inner/cross/full join

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss inner/cross/full join

inner/corss/full cannot be pushed down

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why comment For INNER and CROSS JOIN, we push limits to both the left and right sides if join condition is empty.

Comment thread src/optimizer/heuristic/graph.rs Outdated
#[derive(Debug, PartialEq, Clone)]
pub struct HepNode {
node: OptExprNode,
source_id: Option<HepNodeId>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source_id is really confused, parent_id here seems more readable.


#[test]
fn test_limit_project_transpose() -> Result<()> {
let plan = select_sql_run("select c1, c2 from t1 limit 1")?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this plan? Is project -> limit -> scan? If so, this plan doesn't match LimitProjectTranspose rule.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project -> limit -> scan

limit -> project -> scan

@KKould KKould merged commit eee925d into KipData:main Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants