-
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
plan: always chose the smaller child as outer for IndexJoin #6996
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ package plan | |
|
||
import ( | ||
"fmt" | ||
"math" | ||
|
||
"github.com/juju/errors" | ||
"github.com/pingcap/tidb/ast" | ||
|
@@ -163,6 +164,8 @@ type LogicalPlan interface { | |
// deriveStats derives statistic info between plans. | ||
deriveStats() (*statsInfo, error) | ||
|
||
cardinality() float64 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add |
||
|
||
// preparePossibleProperties is only used for join and aggregation. Like group by a,b,c, all permutation of (a,b,c) is | ||
// valid, but the ordered indices in leaf plan is limited. So we can get all possible order properties by a pre-walking. | ||
// Please make sure that children's method is called though we may not need its return value, | ||
|
@@ -320,6 +323,20 @@ type basePlan struct { | |
stats *statsInfo | ||
} | ||
|
||
func (p *DataSource) cardinality() float64 { | ||
if p.statsAfterSelect == nil { | ||
return math.MaxFloat64 | ||
} | ||
return p.statsAfterSelect.count | ||
} | ||
|
||
func (p *basePlan) cardinality() float64 { | ||
if p.stats == nil { | ||
return math.MaxFloat64 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why return MaxFloat64 here? |
||
} | ||
return p.stats.count | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not cardinality, cardinality is the number of elements in a set. |
||
} | ||
|
||
func (p *basePlan) replaceExprColumns(replace map[string]*expression.Column) { | ||
} | ||
|
||
|
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.
Can we move this to line 402?