Skip to content
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
4 changes: 4 additions & 0 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4211,6 +4211,10 @@ func (m *sessionDataMutator) SetUseProcTxnControlExtendedProtocolFix(val bool) {
m.data.UseProcTxnControlExtendedProtocolFix = val
}

func (m *sessionDataMutator) SetOptimizerUseMaxFrequencySelectivity(val bool) {
m.data.OptimizerUseMaxFrequencySelectivity = val
}

// Utility functions related to scrubbing sensitive information on SQL Stats.

// quantizeCounts ensures that the Count field in the
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/logictest/testdata/logic_test/information_schema
Original file line number Diff line number Diff line change
Expand Up @@ -4042,6 +4042,7 @@ optimizer_use_improved_zigzag_join_costing on
optimizer_use_limit_ordering_for_streaming_group_by on
optimizer_use_lock_elision_multiple_families off
optimizer_use_lock_op_for_serializable off
optimizer_use_max_frequency_selectivity on
optimizer_use_merged_partial_statistics on
optimizer_use_multicol_stats on
optimizer_use_not_visible_indexes off
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -3051,6 +3051,7 @@ optimizer_use_improved_zigzag_join_costing on N
optimizer_use_limit_ordering_for_streaming_group_by on NULL NULL NULL string
optimizer_use_lock_elision_multiple_families off NULL NULL NULL string
optimizer_use_lock_op_for_serializable off NULL NULL NULL string
optimizer_use_max_frequency_selectivity on NULL NULL NULL string
optimizer_use_merged_partial_statistics on NULL NULL NULL string
optimizer_use_multicol_stats on NULL NULL NULL string
optimizer_use_not_visible_indexes off NULL NULL NULL string
Expand Down Expand Up @@ -3276,6 +3277,7 @@ optimizer_use_improved_zigzag_join_costing on N
optimizer_use_limit_ordering_for_streaming_group_by on NULL user NULL on on
optimizer_use_lock_elision_multiple_families off NULL user NULL off off
optimizer_use_lock_op_for_serializable off NULL user NULL off off
optimizer_use_max_frequency_selectivity on NULL user NULL on on
optimizer_use_merged_partial_statistics on NULL user NULL on on
optimizer_use_multicol_stats on NULL user NULL on on
optimizer_use_not_visible_indexes off NULL user NULL off off
Expand Down Expand Up @@ -3500,6 +3502,7 @@ optimizer_use_improved_zigzag_join_costing NULL NULL NULL
optimizer_use_limit_ordering_for_streaming_group_by NULL NULL NULL NULL NULL
optimizer_use_lock_elision_multiple_families NULL NULL NULL NULL NULL
optimizer_use_lock_op_for_serializable NULL NULL NULL NULL NULL
optimizer_use_max_frequency_selectivity NULL NULL NULL NULL NULL
optimizer_use_merged_partial_statistics NULL NULL NULL NULL NULL
optimizer_use_multicol_stats NULL NULL NULL NULL NULL
optimizer_use_not_visible_indexes NULL NULL NULL NULL NULL
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/logictest/testdata/logic_test/show_source
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ optimizer_use_improved_zigzag_join_costing on
optimizer_use_limit_ordering_for_streaming_group_by on
optimizer_use_lock_elision_multiple_families off
optimizer_use_lock_op_for_serializable off
optimizer_use_max_frequency_selectivity on
optimizer_use_merged_partial_statistics on
optimizer_use_multicol_stats on
optimizer_use_not_visible_indexes off
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/exec/execbuilder/testdata/explain_redact
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ upsert bc
query T
EXPLAIN (OPT, MEMO, REDACT) INSERT INTO bc SELECT a::float + 1 FROM a ON CONFLICT (b) DO UPDATE SET b = bc.b + 100
----
memo (optimized, ~36KB, required=[presentation: info:25] [distribution: test])
memo (optimized, ~37KB, required=[presentation: info:25] [distribution: test])
├── G1: (explain G2 [distribution: test])
│ └── [presentation: info:25] [distribution: test]
│ ├── best: (explain G2="[distribution: test]" [distribution: test])
Expand Down Expand Up @@ -2435,7 +2435,7 @@ project
query T
EXPLAIN (OPT, MEMO, REDACT) SELECT * FROM bc JOIN f ON b = f + 1
----
memo (optimized, ~28KB, required=[presentation: info:14] [distribution: test])
memo (optimized, ~29KB, required=[presentation: info:14] [distribution: test])
├── G1: (explain G2 [presentation: b:1,c:2,f:7] [distribution: test])
│ └── [presentation: info:14] [distribution: test]
│ ├── best: (explain G2="[presentation: b:1,c:2,f:7] [distribution: test]" [presentation: b:1,c:2,f:7] [distribution: test])
Expand Down
8 changes: 8 additions & 0 deletions pkg/sql/opt/memo/expr_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,12 +885,20 @@ func (f *ExprFmtCtx) formatRelational(e RelExpr, tp treeprinter.Node) {
if relational.HasPlaceholder {
writeFlag("has-placeholder")
}
if p, ok := e.Private().(*JoinPrivate); ok {
if !p.ParameterizedCols.Empty() {
tp.Childf("parameterized columns: %s", p.ParameterizedCols)
}
}
if lookupJoin, ok := e.(*LookupJoinExpr); ok {
// For lookup joins, indicate whether reverse scans are required to
// satisfy the ordering.
if lookupJoinMustUseReverseScans(md, lookupJoin, &required.Ordering) {
writeFlag("reverse-scans")
}
if !lookupJoin.ParameterizedCols.Empty() {
tp.Childf("parameterized columns: %s", lookupJoin.ParameterizedCols)
}
}

if f.Buffer.Len() != 0 {
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/opt/memo/memo.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ type Memo struct {
internal bool
usePre_25_2VariadicBuiltins bool
useExistsFilterHoistRule bool
useMaxFrequencySelectivity bool

// txnIsoLevel is the isolation level under which the plan was created. This
// affects the planning of some locking operations, so it must be included in
Expand Down Expand Up @@ -314,6 +315,7 @@ func (m *Memo) Init(ctx context.Context, evalCtx *eval.Context) {
internal: evalCtx.SessionData().Internal,
usePre_25_2VariadicBuiltins: evalCtx.SessionData().UsePre_25_2VariadicBuiltins,
useExistsFilterHoistRule: evalCtx.SessionData().OptimizerUseExistsFilterHoistRule,
useMaxFrequencySelectivity: evalCtx.SessionData().OptimizerUseMaxFrequencySelectivity,
txnIsoLevel: evalCtx.TxnIsoLevel,
}
m.metadata.Init()
Expand Down Expand Up @@ -492,6 +494,7 @@ func (m *Memo) IsStale(
m.internal != evalCtx.SessionData().Internal ||
m.usePre_25_2VariadicBuiltins != evalCtx.SessionData().UsePre_25_2VariadicBuiltins ||
m.useExistsFilterHoistRule != evalCtx.SessionData().OptimizerUseExistsFilterHoistRule ||
m.useMaxFrequencySelectivity != evalCtx.SessionData().OptimizerUseMaxFrequencySelectivity ||
m.txnIsoLevel != evalCtx.TxnIsoLevel {
return true, nil
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/opt/memo/memo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,12 @@ func TestMemoIsStale(t *testing.T) {
evalCtx.SessionData().OptimizerUseImprovedMultiColumnSelectivityEstimate = false
notStale()

// Stale optimizer_use_max_frequency_selectivity.
evalCtx.SessionData().OptimizerUseMaxFrequencySelectivity = true
stale()
evalCtx.SessionData().OptimizerUseMaxFrequencySelectivity = false
notStale()

// Stale optimizer_prove_implication_with_virtual_computed_columns.
evalCtx.SessionData().OptimizerProveImplicationWithVirtualComputedColumns = true
stale()
Expand Down
Loading