-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
expression: constraint propagate for '>' and monotonous function #8640
Conversation
dcb25d5
to
e11f0ed
Compare
PTAL @winoros |
PTAL @winoros |
Tiny update. I remove this rule, it's not useful for partition pruning and adds code complexity
PTAL @winoros |
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
con1, ok = f1.GetArgs()[1].(*Constant) | ||
if !ok { | ||
return | ||
} |
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.
We don't consider const op col
?
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.
There are only two rules that really useful to partition pruning:
- col < const
- col >= const
Why?
create table ... partition by col
p1 values less than const1
p2 values less than const2
...
Let's take a look at p2
, the filter expressions are:
col >= const1 and col < const2
The final conditions would be:
col >= const1 and col < const2 and query
So the problem become that whether we can propagate:
col >= const1 and query => false
col < const2 and query => false
ruleColumnOPConst
means use col op const
as rule, perfectly cover the above two.
You'll find the PR can't handle the const op col
.
It doesn't matter, we can add another rule that transform
const op col
to col op const
Then you'll find the rule order matters.
Not a serious problem, we can control the order by
newConstraintSolver(ruleTransformConstOPColumn, ruleColumnOPConst)
I'll make pruning for select ... where to_days(c) > '2018-01-04'
work, and improve some cases later.
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.
I'll make pruning for select ... where to_days(c) > '2018-01-04' work, and improve some cases later.
Thant would be great.
@@ -32,12 +32,16 @@ var _ = Suite(&testExpressionSuite{}) | |||
type testExpressionSuite struct{} | |||
|
|||
func newColumn(id int) *Column { |
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.
how about:
s/newColumn/newInt64Column/
s/newColumnWithType/newColumn/
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.
There are so many newColumn
in this file https://github.com/pingcap/tidb/blob/3cf386b5ca2300a0e0cebeae64d58eac9fcbff6c/expression/constant_test.go
If the function signature changes, it bring about ~50 (lines) irrelevant changes to this PR.
And this is _test.go
, in this file newColumn
indicates newInt64Column
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
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #8640 +/- ##
=========================================
Coverage ? 67.52%
=========================================
Files ? 363
Lines ? 75073
Branches ? 0
=========================================
Hits ? 50693
Misses ? 19905
Partials ? 4475
Continue to review full report at Codecov.
|
What problem does this PR solve?
Propagate some thing like:
What is changed and how it works?
Add a propagate rule
ruleColumnGTConst
leverage this PR #7643Some simple rules:
A more complicate rule:
Prove:
Check List
Tests
Related changes
Ref #7516
This change is