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

fix(optimizer): support pushdown pk to storage scan #795

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

skyzh
Copy link
Member

@skyzh skyzh commented Aug 11, 2023

Add a new rule that maps null to true so that storage filter on pk can be pushed down.

@skyzh
Copy link
Member Author

skyzh commented Aug 11, 2023

it seems that filter-scan-1 is still not correctly applied, that the last query in the planner test is not pushed down?

@skyzh
Copy link
Member Author

skyzh commented Aug 11, 2023

fixed b/c we didn't insert data into the table

@skyzh
Copy link
Member Author

skyzh commented Aug 11, 2023

... and obviously there are some sub-optimal plans 🤪 like two a > x and always false condition not eliminated.

@wangrunji0408
Copy link
Member

fixed b/c we didn't insert data into the table

Yes, in CBO, if a table is empty, then any plan is possible because all of them have zero cost...

Copy link
Member

@wangrunji0408 wangrunji0408 left a 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 } }
Copy link
Member

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"))

Comment on lines +54 to +55
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 }
Copy link
Member

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"))

Copy link
Member Author

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>
@skyzh skyzh enabled auto-merge April 1, 2024 22:55
@skyzh skyzh added this pull request to the merge queue Apr 1, 2024
Merged via the queue into main with commit b391b48 Apr 1, 2024
4 checks passed
@skyzh skyzh deleted the skyzh/fix-pk-pushdown branch April 1, 2024 23:06
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

Successfully merging this pull request may close these issues.

None yet

2 participants