Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: disable prepare plan cache by default #23240

Merged
merged 4 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ var defaultConf = Config{
HeaderTimeout: 5,
},
PreparedPlanCache: PreparedPlanCache{
Enabled: true,
Enabled: false,
Capacity: 100,
MemoryGuardRatio: 0.1,
},
Expand Down
2 changes: 1 addition & 1 deletion config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ networks = ""
header-timeout = 5

[prepared-plan-cache]
enabled = true
enabled = false
capacity = 100
memory-guard-ratio = 0.1

Expand Down
14 changes: 12 additions & 2 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;")
Expand Down
4 changes: 2 additions & 2 deletions planner/core/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down