-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
120805: opt/memo: improve zigzag join cost and selectivity estimation with multi-column stats r=rytaft a=rytaft **opt: update seek and distribution cost of zigzag join to match scan** Prior to this commit, the optimizer could prefer a zigzag join over a scan even if they produced the same number of rows. This was because scans always included the cost of at least one seek (involving random I/O) and some distribution cost, while zigzag joins did not. This commit updates the cost of zigzag joins to include seek and distribution costs so they will never be chosen over scans unless they produce fewer rows. This change is behind the setting `optimizer_use_improved_zigzag_join_costing`. Release note (performance improvement): Added a new setting `optimizer_use_improved_zigzag_join_costing`. When enabled, the cost of zigzag joins is updated so they will be never be chosen over scans unless they produce fewer rows. This change only matters if the setting `enable_zigzag_join` is also true. **opt/memo: improve selectivity estimation with multi-column stats** This commit updates `correlationFromMultiColDistinctCounts` in `statisticsBuilder` to use a tighter lower bound for the multi-column selectivity. This avoids cases where we significantly over-estimate the selectivity of a multi-column predicate. Fixes #121397 Release note (performance improvement): Improved the selectivity estimation of multi-column filters when the multi-column distinct count is high. This avoids cases where we significantly over-estimate the selectivity of a multi-column predicate and as a result can prevent the optimizer from choosing a bad query plan. **sql: add setting optimizer_use_improved_multi_column_selectivity_estimate** Informs #121397 Release note (sql change): Added a setting `optimizer_use_improved_multi_column_selectivity_estimate`, which if enabled, causes the optimizer to use an improved selectivity estimate for multi-column predicates. This setting will default to true on versions 24.2+, and false on prior versions. **opt: improve variable names in selectivityFromMultiColDistinctCounts** This commit improves the variable names in `selectivityFromMultiColDistinctCounts` in `statisticsBuilder` to be more self-documenting. Release note: None 122674: jobs: avoid errors related to fraction completed r=dt a=stevendanna See individual commits for details. Co-authored-by: Rebecca Taft <[email protected]> Co-authored-by: Steven Danna <[email protected]>
- Loading branch information
Showing
44 changed files
with
1,476 additions
and
759 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 67 additions & 81 deletions
148
pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_query_behavior
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package jobs | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestChunkProgressLoggerLimitsFloatingPointError(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
ctx := context.Background() | ||
|
||
defer TestingSetProgressThresholds()() | ||
|
||
rangeCount := 1240725 | ||
|
||
var lastReported float32 | ||
l := NewChunkProgressLogger(func(_ context.Context, pct float32) error { | ||
require.Less(t, pct, float32(1.01)) | ||
lastReported = pct | ||
return nil | ||
}, rangeCount, 0) | ||
for i := 0; i < rangeCount; i++ { | ||
require.NoError(t, l.chunkFinished(ctx), "failed at update %d", i) | ||
} | ||
require.Greater(t, lastReported, float32(0.99)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.