planner: skip plan cache if plans have MemTableScan operator (#41830)
close pingcap/tidb#41829
This commit is contained in:
@ -1025,6 +1025,21 @@ func TestPlanCacheWithLimit(t *testing.T) {
|
||||
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 skip plan-cache: limit count more than 10000"))
|
||||
}
|
||||
|
||||
func TestPlanCacheMemoryTable(t *testing.T) {
|
||||
store := testkit.CreateMockStore(t)
|
||||
tk := testkit.NewTestKit(t, store)
|
||||
tk.MustExec("use test")
|
||||
tk.MustExec(`create table t1 (a int)`)
|
||||
tk.MustExec(`create table t2 (a int, b int)`)
|
||||
|
||||
tk.MustExec(`prepare st from 'select count(*) from information_schema.COLUMNS where table_name=?'`)
|
||||
tk.MustExec(`set @a='t1'`)
|
||||
tk.MustQuery(`execute st using @a`).Check(testkit.Rows("1")) // 1 column
|
||||
tk.MustExec(`set @a='t2'`)
|
||||
tk.MustQuery(`execute st using @a`).Check(testkit.Rows("2")) // 2 columns
|
||||
tk.MustQuery(`select @@last_plan_from_cache`).Check(testkit.Rows("0")) // plan accessing memory tables cannot hit the cache
|
||||
}
|
||||
|
||||
func TestPlanCacheWithSubquery(t *testing.T) {
|
||||
store := testkit.CreateMockStore(t)
|
||||
tk := testkit.NewTestKit(t, store)
|
||||
|
||||
@ -392,6 +392,8 @@ func isPhysicalPlanCacheable(sctx sessionctx.Context, p PhysicalPlan, paramNum,
|
||||
}
|
||||
case *PhysicalShuffle, *PhysicalShuffleReceiverStub:
|
||||
return false, "skip plan-cache: get a Shuffle plan"
|
||||
case *PhysicalMemTable:
|
||||
return false, "skip plan-cache: PhysicalMemTable plan is un-cacheable"
|
||||
case *PhysicalIndexMergeReader:
|
||||
if x.AccessMVIndex {
|
||||
return false, "skip plan-cache: the plan with IndexMerge accessing Multi-Valued Index is un-cacheable"
|
||||
|
||||
Reference in New Issue
Block a user