diff --git a/planner/core/find_best_task.go b/planner/core/find_best_task.go index 5dac575aaddf1..7959461779074 100644 --- a/planner/core/find_best_task.go +++ b/planner/core/find_best_task.go @@ -675,9 +675,14 @@ func (ds *DataSource) findBestTask(prop *property.PhysicalProperty, planCounter canConvertPointGet = canConvertPointGet && candidate.path.StoreType != kv.TiFlash if !candidate.path.IsIntHandlePath { canConvertPointGet = canConvertPointGet && - candidate.path.Index.Unique && - !candidate.path.Index.HasPrefixIndex() && - len(candidate.path.Ranges[0].LowVal) == len(candidate.path.Index.Columns) + candidate.path.Index.Unique && !candidate.path.Index.HasPrefixIndex() + idxColsLen := len(candidate.path.Index.Columns) + for _, ran := range candidate.path.Ranges { + if len(ran.LowVal) != idxColsLen { + canConvertPointGet = false + break + } + } } if ds.table.Meta().GetPartitionInfo() != nil && !tryOldPartitionImplementation(ds.ctx) { canConvertPointGet = false diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 1257d2458d7f2..020d89dec37ee 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -1519,3 +1519,17 @@ partition p2 values less than (10))`) tk.MustQuery("explain " + tt).Check(testkit.Rows(output[i].Plan...)) } } + +func (s *testIntegrationSuite) TestPartialBatchPointGet(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists t") + tk.MustExec("create table t (c_int int, c_str varchar(40), primary key(c_int, c_str))") + tk.MustExec("insert into t values (3, 'bose')") + tk.MustQuery("select * from t where c_int in (3)").Check(testkit.Rows( + "3 bose", + )) + tk.MustQuery("select * from t where c_int in (3) or c_str in ('yalow') and c_int in (1, 2)").Check(testkit.Rows( + "3 bose", + )) +}