expression: constraint propagate for '>' and monotonous function#8640
expression: constraint propagate for '>' and monotonous function#8640tiancaiamao merged 12 commits intopingcap:masterfrom
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 |
| con1, ok = f1.GetArgs()[1].(*Constant) | ||
| if !ok { | ||
| return | ||
| } |
There was a problem hiding this comment.
We don't consider const op col?
There was a problem hiding this comment.
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.
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.
how about:
s/newColumn/newInt64Column/
s/newColumnWithType/newColumn/
There was a problem hiding this comment.
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
|
/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
ruleColumnGTConstleverage this PR #7643Some simple rules:
A more complicate rule:
Prove:
Check List
Tests
Related changes
Ref #7516
This change is