diff --git a/config/config.go b/config/config.go index eb2afaba3403c..a6ba012727b28 100644 --- a/config/config.go +++ b/config/config.go @@ -617,7 +617,7 @@ var defaultConf = Config{ HeaderTimeout: 5, }, PreparedPlanCache: PreparedPlanCache{ - Enabled: true, + Enabled: false, Capacity: 100, MemoryGuardRatio: 0.1, }, diff --git a/config/config.toml.example b/config/config.toml.example index a43edf8639949..60e86c847f205 100644 --- a/config/config.toml.example +++ b/config/config.toml.example @@ -312,7 +312,7 @@ networks = "" header-timeout = 5 [prepared-plan-cache] -enabled = true +enabled = false capacity = 100 memory-guard-ratio = 0.1 diff --git a/expression/integration_test.go b/expression/integration_test.go index 95a6e0faae9c6..440067d3ca9e0 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -5893,9 +5893,19 @@ func (s *testIntegrationSuite) TestCastStrToInt(c *C) { func (s *testIntegrationSerialSuite) TestPreparePlanCache(c *C) { tk := testkit.NewTestKit(c, s.store) - // Plan cache should now be on by default - c.Assert(plannercore.PreparedPlanCacheEnabled(), Equals, true) + // Plan cache should now be off by default + c.Assert(plannercore.PreparedPlanCacheEnabled(), Equals, false) + orgEnable := plannercore.PreparedPlanCacheEnabled() + defer func() { + plannercore.SetPreparedPlanCache(orgEnable) + }() + plannercore.SetPreparedPlanCache(true) + var err error + tk.Se, err = session.CreateSession4TestWithOpt(s.store, &session.Opt{ + PreparedPlanCache: kvcache.NewSimpleLRUCache(100, 0.1, math.MaxUint64), + }) + c.Assert(err, IsNil) // Use the example from the docs https://docs.pingcap.com/tidb/stable/sql-prepare-plan-cache tk.MustExec("use test") tk.MustExec("drop table if exists t;") diff --git a/planner/core/cache.go b/planner/core/cache.go index 93e8ba5ec49df..1e87a984331b0 100644 --- a/planner/core/cache.go +++ b/planner/core/cache.go @@ -32,8 +32,8 @@ import ( var ( // preparedPlanCacheEnabledValue stores the global config "prepared-plan-cache-enabled". - // The value is true unless "prepared-plan-cache-enabled" is FALSE in configuration. - preparedPlanCacheEnabledValue int32 = 1 + // The value is false unless "prepared-plan-cache-enabled" is true in configuration. + preparedPlanCacheEnabledValue int32 = 0 // PreparedPlanCacheCapacity stores the global config "prepared-plan-cache-capacity". PreparedPlanCacheCapacity uint = 100 // PreparedPlanCacheMemoryGuardRatio stores the global config "prepared-plan-cache-memory-guard-ratio".