-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
planner, statistics: maintain histogram for inner join #8097
Closed
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8fe06a6
planner, statistics: maintain histogram for inner join
winoros 5347dc4
planner, statistics: maintain histogram for inner join
winoros 559031f
Merge branch 'inner-join-hist' of https://github.com/winoros/tidb int…
winoros 13ea82d
Merge branch 'master' into inner-join-hist
winoros cea7095
address comments
winoros b2ff7c1
add unit-test
winoros 2adb8dd
add unit test.
winoros ea60d70
address comments
winoros 8a9ac4f
remove index hist in result.
winoros 325c13d
add case for histColl count is not equal to hist count
winoros d9a25d1
address comments
winoros 0579e83
Merge branch 'master' into inner-join-hist
winoros 6211577
fix test && address comments
winoros 44c6cb7
Merge branch 'master' into inner-join-hist
zz-jason 41b5a4b
Merge branch 'master' into inner-join-hist
winoros c3befc4
avoid NaN
winoros 1c80d94
address comments and change the way of calculation
winoros 686c50c
Merge branch 'master' into inner-join-hist
winoros e1cecd5
Merge branch 'master' into inner-join-hist
winoros 15485aa
load if not loaded
winoros File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,61 @@ | ||
// Copyright 2018 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package statistics | ||
|
||
import ( | ||
. "github.com/pingcap/check" | ||
"github.com/pingcap/parser/mysql" | ||
"github.com/pingcap/tidb/types" | ||
"github.com/pingcap/tidb/util/chunk" | ||
) | ||
|
||
var _ = Suite(&HistogramTestSuite{}) | ||
|
||
type HistogramTestSuite struct { | ||
} | ||
|
||
func (s *HistogramTestSuite) TestMergeHistogramForInnerJoinIntCase(c *C) { | ||
intTp := types.NewFieldType(mysql.TypeLonglong) | ||
// aHist: 60 distinct value, each value repeats 2 times. | ||
aHist := NewHistogram(0, 60, 0, 0, intTp, chunk.InitialCapacity, 0) | ||
// [100, 200] | ||
aHist.Bounds.AppendInt64(0, 100) | ||
aHist.Bounds.AppendInt64(0, 200) | ||
aHist.Buckets = append(aHist.Buckets, Bucket{Repeat: 2, Count: 100}) | ||
// [210, 230] | ||
aHist.Bounds.AppendInt64(0, 210) | ||
aHist.Bounds.AppendInt64(0, 230) | ||
aHist.Buckets = append(aHist.Buckets, Bucket{Repeat: 2, Count: 120}) | ||
// bHist: 100 distinct value, each value repeats 100 times. | ||
bHist := NewHistogram(0, 100, 0, 0, intTp, chunk.InitialCapacity, 0) | ||
// [90, 120] | ||
bHist.Bounds.AppendInt64(0, 90) | ||
bHist.Bounds.AppendInt64(0, 120) | ||
bHist.Buckets = append(bHist.Buckets, Bucket{Repeat: 100, Count: 3000}) | ||
// [130, 160] | ||
bHist.Bounds.AppendInt64(0, 130) | ||
bHist.Bounds.AppendInt64(0, 160) | ||
bHist.Buckets = append(bHist.Buckets, Bucket{Repeat: 100, Count: 6000}) | ||
// [180, 220] | ||
bHist.Bounds.AppendInt64(0, 180) | ||
bHist.Bounds.AppendInt64(0, 220) | ||
bHist.Buckets = append(bHist.Buckets, Bucket{Repeat: 100, Count: 10000}) | ||
finalHist := MergeHistogramForInnerJoin(aHist, bHist, intTp) | ||
|
||
c.Assert(finalHist.ToString(0), Equals, `column:0 ndv:41 totColSize:0 | ||
num: 2079 lower_bound: 100 upper_bound: 120 repeats: 200 | ||
num: 3069 lower_bound: 130 upper_bound: 160 repeats: 200 | ||
num: 2079 lower_bound: 180 upper_bound: 200 repeats: 200 | ||
num: 1047 lower_bound: 210 upper_bound: 220 repeats: 200`) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we pass the
childStats
parameter down toderiveInnerJoinStatsWithHist
? so thisDeriveStats
function can be used by cascades planner as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, using
childStats
in new commits. But it uses the schema of join's children inside this method. Seems that i need some way to not rely on it.