diff --git a/pkg/planner/cardinality/row_count_index.go b/pkg/planner/cardinality/row_count_index.go index 4393bf3b45..c89b6e290c 100644 --- a/pkg/planner/cardinality/row_count_index.go +++ b/pkg/planner/cardinality/row_count_index.go @@ -476,9 +476,6 @@ func expBackoffEstimation(sctx planctx.PlanContext, idx *statistics.Index, coll // `GetRowCountByIndexRanges()` when the input `indexRange` is a multi-column range. This // check avoids infinite recursion. for _, idxID := range idxIDs { - if idxID == idx.Histogram.ID { - continue - } idxStats := coll.GetIdx(idxID) if idxStats == nil || statistics.IndexStatsIsInvalid(sctx, idxStats, coll, idxID) { continue diff --git a/pkg/planner/core/casetest/BUILD.bazel b/pkg/planner/core/casetest/BUILD.bazel index 3b0bd7eed7..65d11c6afd 100644 --- a/pkg/planner/core/casetest/BUILD.bazel +++ b/pkg/planner/core/casetest/BUILD.bazel @@ -12,7 +12,7 @@ go_test( ], data = glob(["testdata/**"]), flaky = True, - shard_count = 27, + shard_count = 28, deps = [ "//pkg/domain", "//pkg/errno", diff --git a/pkg/planner/core/casetest/integration_test.go b/pkg/planner/core/casetest/integration_test.go index 1aedce1d9e..9793d1c337 100644 --- a/pkg/planner/core/casetest/integration_test.go +++ b/pkg/planner/core/casetest/integration_test.go @@ -515,3 +515,22 @@ func TestIndexMergeJSONMemberOf2FlakyPart(t *testing.T) { "└─TableRowIDScan_6(Probe) 1.00 cop[tikv] table:t keep order:false, stats:partial[d:unInitialized]", )) } + +func TestIssue56915(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec(`use test`) + tk.MustExec(`drop table if exists t`) + tk.MustExec(`create table t(a int, b int, j json, index ia(a), index mvi( (cast(j as signed array)), a, b) );`) + tk.MustExec(`insert into t value(1,1,'[1,2,3,4,5]');`) + tk.MustExec(`insert into t value(1,1,'[1,2,3,4,5]');`) + tk.MustExec(`insert into t value(1,1,'[1,2,3,4,5]');`) + tk.MustExec(`insert into t value(1,1,'[1,2,3,4,5]');`) + tk.MustExec(`insert into t value(1,1,'[6]');`) + tk.MustExec(`analyze table t all columns;`) + tk.MustQuery("explain format = brief select * from t where a = 1 and 6 member of (j);").Check(testkit.Rows( + "IndexMerge 1.00 root type: union", + "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:mvi(cast(`j` as signed array), a, b) range:[6 1,6 1], keep order:false, stats:partial[j:unInitialized]", + "└─TableRowIDScan(Probe) 1.00 cop[tikv] table:t keep order:false, stats:partial[j:unInitialized]", + )) +} diff --git a/tests/integrationtest/t/planner/core/indexmerge_path.test b/tests/integrationtest/t/planner/core/indexmerge_path.test index 1d29657dee..3d6e7085e4 100644 --- a/tests/integrationtest/t/planner/core/indexmerge_path.test +++ b/tests/integrationtest/t/planner/core/indexmerge_path.test @@ -15,7 +15,6 @@ analyze table t index a; analyze table t index a, idx, idx2; --disable_warnings - # TestIndexMergeJSONMemberOf drop table if exists t; create table t( @@ -503,4 +502,3 @@ EXPLAIN format = brief SELECT /*+ use_index_merge(t1, mvi4) */ * from t1 where c = 1 and json_contains(j, '[4,5]') and d not like '%test%'; -