diff --git a/cmd/explaintest/r/explain_easy.result b/cmd/explaintest/r/explain_easy.result index 0a4a8683215b6..f6631ebd4056b 100644 --- a/cmd/explaintest/r/explain_easy.result +++ b/cmd/explaintest/r/explain_easy.result @@ -137,7 +137,7 @@ id count task operator info Limit_9 1.00 root offset:0, count:1 └─IndexLookUp_17 1.00 root ├─Selection_14 3.00 cop gt(test.t4.b, 1) - │ └─IndexScan_12 9.00 cop table:t4, index:a, b, range:(1 +inf,+inf +inf], keep order:false, stats:pseudo + │ └─IndexScan_12 9.00 cop table:t4, index:a, b, range:(1,+inf], keep order:false, stats:pseudo └─Limit_16 1.00 cop offset:0, count:1 └─Selection_15 1.00 cop gt(test.t4.c, 1) └─TableScan_13 3.00 cop table:t4, keep order:false diff --git a/planner/core/physical_plan_test.go b/planner/core/physical_plan_test.go index bc65157a79ed7..bd5e2d7388908 100644 --- a/planner/core/physical_plan_test.go +++ b/planner/core/physical_plan_test.go @@ -70,7 +70,7 @@ func (s *testPlanSuite) TestDAGPlanBuilderSimpleCase(c *C) { // Test DNF condition + Double Read. { sql: "select * from t where (t.c > 0 and t.c < 2) or (t.c > 4 and t.c < 6) or (t.c > 8 and t.c < 10) or (t.c > 12 and t.c < 14) or (t.c > 16 and t.c < 18)", - best: "IndexLookUp(Index(t.c_d_e)[(0 +inf,2 NULL) (4 +inf,6 NULL) (8 +inf,10 NULL) (12 +inf,14 NULL) (16 +inf,18 NULL)], Table(t))", + best: "IndexLookUp(Index(t.c_d_e)[(0,2) (4,6) (8,10) (12,14) (16,18)], Table(t))", }, { sql: "select * from t where (t.c > 0 and t.c < 1) or (t.c > 2 and t.c < 3) or (t.c > 4 and t.c < 5) or (t.c > 6 and t.c < 7) or (t.c > 9 and t.c < 10)", diff --git a/util/ranger/ranger.go b/util/ranger/ranger.go index 0402209e25bb7..c7e8dce2a781f 100644 --- a/util/ranger/ranger.go +++ b/util/ranger/ranger.go @@ -333,22 +333,6 @@ func buildCNFIndexRange(sc *stmtctx.StatementContext, cols []*expression.Column, fixPrefixColRange(ranges, lengths, newTp) } - if len(ranges) > 0 && len(ranges[0].LowVal) < len(cols) { - for _, ran := range ranges { - if ran.HighExclude || ran.LowExclude { - if ran.HighExclude { - ran.HighVal = append(ran.HighVal, types.NewDatum(nil)) - } else { - ran.HighVal = append(ran.HighVal, types.MaxValueDatum()) - } - if ran.LowExclude { - ran.LowVal = append(ran.LowVal, types.MaxValueDatum()) - } else { - ran.LowVal = append(ran.LowVal, types.NewDatum(nil)) - } - } - } - } return ranges, nil } diff --git a/util/ranger/ranger_test.go b/util/ranger/ranger_test.go index 89edd131736da..8d8ae3be3a825 100644 --- a/util/ranger/ranger_test.go +++ b/util/ranger/ranger_test.go @@ -346,14 +346,14 @@ func (s *testRangerSuite) TestIndexRange(c *C) { exprStr: `a LIKE 'abc%'`, accessConds: `[like(test.t.a, abc%, 92)]`, filterConds: "[]", - resultStr: "[[\"abc\" NULL,\"abd\" NULL)]", + resultStr: "[[\"abc\",\"abd\")]", }, { indexPos: 0, exprStr: "a LIKE 'abc_'", accessConds: "[like(test.t.a, abc_, 92)]", filterConds: "[like(test.t.a, abc_, 92)]", - resultStr: "[(\"abc\" +inf,\"abd\" NULL)]", + resultStr: "[(\"abc\",\"abd\")]", }, { indexPos: 0, @@ -395,7 +395,7 @@ func (s *testRangerSuite) TestIndexRange(c *C) { exprStr: `a LIKE "\\\\a%"`, accessConds: `[like(test.t.a, \\a%, 92)]`, filterConds: "[]", - resultStr: "[[\"\\a\" NULL,\"\\b\" NULL)]", + resultStr: "[[\"\\a\",\"\\b\")]", }, { indexPos: 0, @@ -444,7 +444,7 @@ func (s *testRangerSuite) TestIndexRange(c *C) { exprStr: "c not in (1, 2, 3)", accessConds: "[not(in(test.t.c, 1, 2, 3))]", filterConds: "[]", - resultStr: "[(NULL +inf,1 NULL) (1 +inf,2 NULL) (2 +inf,3 NULL) (3 +inf,+inf +inf]]", + resultStr: "[(NULL,1) (1,2) (2,3) (3,+inf]]", }, { indexPos: 1, @@ -500,28 +500,28 @@ func (s *testRangerSuite) TestIndexRange(c *C) { exprStr: "(a > 'b' and a < 'bbb') or (a < 'cb' and a > 'a')", accessConds: "[or(and(gt(test.t.a, b), lt(test.t.a, bbb)), and(lt(test.t.a, cb), gt(test.t.a, a)))]", filterConds: "[]", - resultStr: "[(\"a\" +inf,\"cb\" NULL)]", + resultStr: "[(\"a\",\"cb\")]", }, { indexPos: 0, exprStr: "(a > 'a' and a < 'b') or (a >= 'b' and a < 'c')", accessConds: "[or(and(gt(test.t.a, a), lt(test.t.a, b)), and(ge(test.t.a, b), lt(test.t.a, c)))]", filterConds: "[]", - resultStr: "[(\"a\" +inf,\"c\" NULL)]", + resultStr: "[(\"a\",\"c\")]", }, { indexPos: 0, exprStr: "(a > 'a' and a < 'b' and b < 1) or (a >= 'b' and a < 'c')", accessConds: "[or(and(gt(test.t.a, a), lt(test.t.a, b)), and(ge(test.t.a, b), lt(test.t.a, c)))]", filterConds: "[or(and(and(gt(test.t.a, a), lt(test.t.a, b)), lt(test.t.b, 1)), and(ge(test.t.a, b), lt(test.t.a, c)))]", - resultStr: "[(\"a\" +inf,\"c\" NULL)]", + resultStr: "[(\"a\",\"c\")]", }, { indexPos: 0, exprStr: "(a in ('a', 'b') and b < 1) or (a >= 'b' and a < 'c')", accessConds: "[or(and(in(test.t.a, a, b), lt(test.t.b, 1)), and(ge(test.t.a, b), lt(test.t.a, c)))]", filterConds: "[]", - resultStr: `[["a" -inf,"a" 1) ["b" NULL,"c" NULL)]`, + resultStr: `[["a" -inf,"a" 1) ["b","c")]`, }, { indexPos: 0, @@ -952,9 +952,9 @@ func (s *testRangerSuite) TestIndexRangeElimininatedProjection(c *C) { testKit.MustQuery("explain select * from (select * from t union all select ifnull(a,b), b from t) sub where a > 0").Check(testkit.Rows( "Union_11 2.00 root ", "├─IndexReader_17 1.00 root index:IndexScan_16", - "│ └─IndexScan_16 1.00 cop table:t, index:a, b, range:(0 +inf,+inf +inf], keep order:false", + "│ └─IndexScan_16 1.00 cop table:t, index:a, b, range:(0,+inf], keep order:false", "└─IndexReader_23 1.00 root index:IndexScan_22", - " └─IndexScan_22 1.00 cop table:t, index:a, b, range:(0 +inf,+inf +inf], keep order:false", + " └─IndexScan_22 1.00 cop table:t, index:a, b, range:(0,+inf], keep order:false", )) testKit.MustQuery("select * from (select * from t union all select ifnull(a,b), b from t) sub where a > 0").Check(testkit.Rows( "1 2",