-
Notifications
You must be signed in to change notification settings - Fork 208
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
fix(optimizer): support pushdown pk to storage scan #795
Conversation
it seems that |
fixed b/c we didn't insert data into the table |
... and obviously there are some sub-optimal plans 🤪 like two |
Yes, in CBO, if a table is empty, then any plan is possible because all of them have zero cost... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
└── Scan | ||
├── table: t1 | ||
├── list: [ a, b ] | ||
├── filter: and { lhs: > { lhs: 0, rhs: a }, rhs: > { lhs: a, rhs: 1 } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that we should add some rules to rewrite this to false
🤔
Maybe:
rw!(""; "(and (> ?x ?a) (< ?x ?b))" => "false" if is_greater_than_or_equal("?a", "?b"))
Filter { cond: and { lhs: > { lhs: b, rhs: 1 }, rhs: > { lhs: a, rhs: 3 } }, cost: 15.1, rows: 1.25 } | ||
└── Scan { table: t1, list: [ a, b ], filter: > { lhs: a, rhs: 1 }, cost: 10, rows: 5 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto. a > 1 and a > 3
should be rewrited to a > 3
.
Maybe:
rw!(""; "(and (> ?x ?a) (> ?x ?b))" => "(> ?x ?a)" if is_greater_than_or_equal("?a", "?b"))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will make it in a separate pull request
Signed-off-by: Alex Chi <iskyzh@gmail.com>
cd03496
to
f08b89d
Compare
Add a new rule that maps null to true so that storage filter on pk can be pushed down.