Skip to content

Commit

Permalink
opt: Remove experimental_optimizer_mutations flag
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
andy-kimball committed Feb 5, 2019
1 parent 2d75cf1 commit cabe058
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 77 deletions.
1 change: 0 additions & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<tr><td><code>server.web_session_timeout</code></td><td>duration</td><td><code>168h0m0s</code></td><td>the duration that a newly created web session will be valid</td></tr>
<tr><td><code>sql.defaults.default_int_size</code></td><td>integer</td><td><code>8</code></td><td>the size, in bytes, of an INT type</td></tr>
<tr><td><code>sql.defaults.distsql</code></td><td>enumeration</td><td><code>1</code></td><td>default distributed SQL execution mode [off = 0, auto = 1, on = 2]</td></tr>
<tr><td><code>sql.defaults.experimental_optimizer_mutations</code></td><td>boolean</td><td><code>false</code></td><td>default experimental_optimizer_mutations mode</td></tr>
<tr><td><code>sql.defaults.experimental_vectorize</code></td><td>enumeration</td><td><code>0</code></td><td>default experimental_vectorize mode [off = 0, on = 1, always = 2]</td></tr>
<tr><td><code>sql.defaults.optimizer</code></td><td>enumeration</td><td><code>1</code></td><td>default cost-based optimizer mode [off = 0, on = 1, local = 2]</td></tr>
<tr><td><code>sql.defaults.results_buffer.size</code></td><td>byte size</td><td><code>16 KiB</code></td><td>default size of the buffer that accumulates results for a statement or a batch of statements before they are sent to the client. This can be overridden on an individual connection with the 'results_buffer_size' parameter. Note that auto-retries generally only happen while no results have been delivered to the client, so reducing this size can increase the number of retriable errors a client receives. On the other hand, increasing the buffer size can increase the delay until the client receives the first result row. Updating the setting only affects new connections. Setting to 0 disables any buffering.</td></tr>
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/updates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,13 @@ func TestReportUsage(t *testing.T) {
`[false,false,false] SET application_name = $1`,
`[false,false,false] SET application_name = DEFAULT`,
`[false,false,false] SET application_name = _`,
`[false,false,false] UPDATE _ SET _ = _ + _`,
`[true,false,false] CREATE TABLE _ (_ INT8, CONSTRAINT _ CHECK (_ > _))`,
`[true,false,false] INSERT INTO _ SELECT unnest(ARRAY[_, _, __more2__])`,
`[true,false,false] INSERT INTO _ VALUES (_), (__more2__)`,
`[true,false,false] INSERT INTO _ VALUES (length($1::STRING)), (__more1__)`,
`[true,false,false] INSERT INTO _(_, _) VALUES (_, _)`,
`[true,false,false] SELECT (_, _, __more2__) = (SELECT _, _, _, _ FROM _ LIMIT _)`,
`[true,false,false] UPDATE _ SET _ = _ + _`,
`[true,false,true] CREATE TABLE _ (_ INT8 PRIMARY KEY, _ INT8, INDEX (_) INTERLEAVE IN PARENT _ (_))`,
`[true,false,true] SELECT _ / $1`,
`[true,false,true] SELECT _ / _`,
Expand Down
12 changes: 0 additions & 12 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ var OptimizerClusterMode = settings.RegisterEnumSetting(
},
)

// OptimizerMutationsClusterMode controls the cluster default for when the cost-
// based optimizer is planning mutation statements.
var OptimizerMutationsClusterMode = settings.RegisterBoolSetting(
"sql.defaults.experimental_optimizer_mutations",
"default experimental_optimizer_mutations mode",
false,
)

// VectorizeClusterMode controls the cluster default for when automatic
// vectorization is enabled.
var VectorizeClusterMode = settings.RegisterEnumSetting(
Expand Down Expand Up @@ -1676,10 +1668,6 @@ func (m *sessionDataMutator) SetOptimizerMode(val sessiondata.OptimizerMode) {
m.data.OptimizerMode = val
}

func (m *sessionDataMutator) SetOptimizerMutations(val bool) {
m.data.OptimizerMutations = val
}

func (m *sessionDataMutator) SetSerialNormalizationMode(val sessiondata.SerialNormalizationMode) {
m.data.SerialNormalizationMode = val
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,13 +933,6 @@ func (t *logicTest) setUser(user string) func() {
if _, err := db.Exec(fmt.Sprintf("SET OPTIMIZER = %s;", optMode)); err != nil {
t.Fatal(err)
}

// Use the cost-based-optimizer for planning mutation statements.
if optMode == "on" {
if _, err := db.Exec("SET experimental_optimizer_mutations = true"); err != nil {
t.Fatal(err)
}
}
}
// The default value for extra_float_digits assumed by tests is
// 0. However, lib/pq by default configures this to 2 during
Expand Down
13 changes: 0 additions & 13 deletions pkg/sql/logictest/testdata/logic_test/optimizer
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,3 @@ SELECT * FROM test.t
2 20
3 30
4 40

# Test the experimental_optimizer_mutations flag.
statement ok
SET experimental_optimizer_mutations = false

statement error pq: no data source matches prefix: t
UPDATE t SET v=(SELECT v+1 FROM t AS t2 WHERE t2.k=t.k)

statement ok
SET experimental_optimizer_mutations = true

statement ok
UPDATE t SET v=(SELECT v+1 FROM t AS t2 WHERE t2.k=t.k)
5 changes: 2 additions & 3 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ SELECT
FROM
pg_catalog.pg_settings
WHERE
name != 'optimizer' AND name != 'crdb_version' AND name != 'experimental_optimizer_mutations'
name != 'optimizer' AND name != 'crdb_version'
----
name setting category short_desc extra_desc vartype
application_name · NULL NULL NULL string
Expand Down Expand Up @@ -1372,7 +1372,7 @@ SELECT
FROM
pg_catalog.pg_settings
WHERE
name != 'optimizer' AND name != 'crdb_version' AND name != 'experimental_optimizer_mutations'
name != 'optimizer' AND name != 'crdb_version'
----
name setting unit context enumvals boot_val reset_val
application_name · NULL user NULL · ·
Expand Down Expand Up @@ -1429,7 +1429,6 @@ default_transaction_read_only NULL NULL NULL NULL NULL
distsql NULL NULL NULL NULL NULL
experimental_enable_zigzag_join NULL NULL NULL NULL NULL
experimental_force_split_at NULL NULL NULL NULL NULL
experimental_optimizer_mutations NULL NULL NULL NULL NULL
experimental_reorder_joins_limit NULL NULL NULL NULL NULL
experimental_serial_normalization NULL NULL NULL NULL NULL
experimental_vectorize NULL NULL NULL NULL NULL
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/testdata/logic_test/show_source
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ UTF8 1
query TT colnames
SELECT *
FROM [SHOW ALL]
WHERE variable != 'optimizer' AND variable != 'crdb_version' AND variable != 'experimental_optimizer_mutations'
WHERE variable != 'optimizer' AND variable != 'crdb_version'
----
variable value
application_name ·
Expand Down
10 changes: 5 additions & 5 deletions pkg/sql/opt/exec/execbuilder/testdata/explain
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ render · ·
└── filter · ·
│ filter variable = 'database'
└── values · ·
· size 3 columns, 41 rows
· size 3 columns, 40 rows

query TTT
EXPLAIN SHOW TIME ZONE
Expand All @@ -195,7 +195,7 @@ render · ·
└── filter · ·
│ filter variable = 'timezone'
└── values · ·
· size 3 columns, 41 rows
· size 3 columns, 40 rows

query TTT
EXPLAIN SHOW DEFAULT_TRANSACTION_ISOLATION
Expand All @@ -204,7 +204,7 @@ render · ·
└── filter · ·
│ filter variable = 'default_transaction_isolation'
└── values · ·
· size 3 columns, 41 rows
· size 3 columns, 40 rows

query TTT
EXPLAIN SHOW TRANSACTION ISOLATION LEVEL
Expand All @@ -213,7 +213,7 @@ render · ·
└── filter · ·
│ filter variable = 'transaction_isolation'
└── values · ·
· size 3 columns, 41 rows
· size 3 columns, 40 rows

query TTT
EXPLAIN SHOW TRANSACTION PRIORITY
Expand All @@ -222,7 +222,7 @@ render · ·
└── filter · ·
│ filter variable = 'transaction_priority'
└── values · ·
· size 3 columns, 41 rows
· size 3 columns, 40 rows

query TTT
EXPLAIN SHOW COLUMNS FROM foo
Expand Down
5 changes: 0 additions & 5 deletions pkg/sql/opt/optbuilder/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ func init() {
// ON CONFLICT clause is present, since it joins a new set of rows to the input
// and thereby scrambles the input ordering.
func (b *Builder) buildInsert(ins *tree.Insert, inScope *scope) (outScope *scope) {
// Put UPSERT behind feature flag.
if ins.OnConflict != nil && !b.evalCtx.SessionData.OptimizerMutations {
panic(unimplementedf("cost-based optimizer is not planning UPSERT statements"))
}

if ins.With != nil {
inScope = b.buildCTE(ins.With.CTEList, inScope)
defer b.checkCTEUsage(inScope)
Expand Down
4 changes: 0 additions & 4 deletions pkg/sql/opt/optbuilder/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ import (
// mutations are applied, or the order of any returned rows (i.e. it won't
// become a physical property required of the Update operator).
func (b *Builder) buildUpdate(upd *tree.Update, inScope *scope) (outScope *scope) {
if !b.evalCtx.SessionData.OptimizerMutations {
panic(unimplementedf("cost-based optimizer is not planning UPDATE statements"))
}

if upd.OrderBy != nil && upd.Limit == nil {
panic(builderError{errors.New("UPDATE statement requires LIMIT when ORDER BY is used")})
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/sql/opt/testutils/opt_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ func NewOptTester(catalog cat.Catalog, sql string) *OptTester {

// Set any OptTester-wide session flags here.

// Enable CBO planning for UPDATE statements, for all tests.
ot.evalCtx.SessionData.OptimizerMutations = true

// Enable zigzag joins for all opt tests. Execbuilder tests exercise
// cases where this flag is false.
ot.evalCtx.SessionData.ZigzagJoinEnabled = true
Expand Down
3 changes: 0 additions & 3 deletions pkg/sql/sessiondata/session_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ type SessionData struct {
// OptimizerMode indicates whether to use the experimental optimizer for
// query planning.
OptimizerMode OptimizerMode
// OptimizerMutations indicates whether to use the cost-based optimizer to
// plan UPDATE statements.
OptimizerMutations bool
// SerialNormalizationMode indicates how to handle the SERIAL pseudo-type.
SerialNormalizationMode SerialNormalizationMode
// SearchPath is a list of namespaces to search builtins in.
Expand Down
19 changes: 0 additions & 19 deletions pkg/sql/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,25 +398,6 @@ var varGen = map[string]sessionVar{
},
},

// CockroachDB extension.
`experimental_optimizer_mutations`: {
GetStringVal: makeBoolGetStringValFn(`experimental_optimizer_mutations`),
Set: func(_ context.Context, m *sessionDataMutator, s string) error {
b, err := parsePostgresBool(s)
if err != nil {
return err
}
m.SetOptimizerMutations(b)
return nil
},
Get: func(evalCtx *extendedEvalContext) string {
return formatBoolAsPostgresSetting(evalCtx.SessionData.OptimizerMutations)
},
GlobalDefault: func(sv *settings.Values) string {
return formatBoolAsPostgresSetting(OptimizerMutationsClusterMode.Get(sv))
},
},

// CockroachDB extension.
`experimental_serial_normalization`: {
Set: func(_ context.Context, m *sessionDataMutator, s string) error {
Expand Down

0 comments on commit cabe058

Please sign in to comment.