Open qw4990 opened 2 years ago
PTAL @fixdb @winoros @AilinKid
It seems like that tikv does not support this kind of collation
Hey, I would love to work on this!
/assign
After examining the code, I think the problem here is that we currently only support constant propagating for columns with same collation.
See codes below(expression/constant_propagation.go: L238-259) `func (s *propConstSolver) propagateColumnEQ() {
for i := range s.conditions {
if fun, ok := s.conditions[i].(*ScalarFunction); ok && fun.FuncName.L == ast.EQ {
......................
// TODO: Enable hybrid types in ConstantPropagate.
if lOk && rOk && lCol.GetType().GetCollate() == rCol.GetType().GetCollate() && !lCol.GetType().Hybrid() && !rCol.GetType().Hybrid() {
lID := s.getColID(lCol)
rID := s.getColID(rCol)
s.unionSet.Union(lID, rID)
visited[i] = true
}
}
}`
Only if lCol.GetType().GetCollate() == rCol.GetType().GetCollate()
, we will generate the condition test.t2.risk_id = 'xxx'
, which will then be pushed down and finally create the IndexRangeScan
for test2.
Should we compare the type without the collate()?
Could you guys pls verify my thoughts? @qw4990
/assign
Enhancement
The predicate
t1.risk_id = 'xxxx'
should be propagated tot2
and the optimizer should generate aIndexRangeScan
fort2
. If removeCOLLATE utf8mb4_general_ci
, this predicate can be pushed down.