-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: calc access path
when doing deriveStats
.
#6346
Changes from 1 commit
391e389
2039b18
50fd959
ba77bdf
d1a7691
8192bfa
5d3620f
d170ac3
e528c54
8d5775b
e6bc81b
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 |
---|---|---|
|
@@ -331,31 +331,29 @@ func (ds *DataSource) deriveTablePathStats(path *accessPath) error { | |
var err error | ||
sc := ds.ctx.GetSessionVars().StmtCtx | ||
path.countAfterAccess = float64(ds.statisticTable.Count) | ||
path.tableFilters = ds.pushedDownConds | ||
var pkCol *expression.Column | ||
if ds.tableInfo.PKIsHandle { | ||
if pkColInfo := ds.tableInfo.GetPkColInfo(); pkColInfo != nil { | ||
pkCol = expression.ColInfo2Col(ds.schema.Columns, pkColInfo) | ||
} | ||
} | ||
if pkCol != nil { | ||
path.ranges = ranger.FullIntRange(mysql.HasUnsignedFlag(pkCol.RetType.Flag)) | ||
} else { | ||
if pkCol == nil { | ||
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. We'better add some test cases to cover pkCol == nil and pkCol !=nil. 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. the status of pkCol is covered executor's unit test 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. But why all test cases can be passed when line 336~340 was missed before, 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. let me check it first. |
||
path.ranges = ranger.FullIntRange(false) | ||
return nil | ||
} | ||
if len(ds.pushedDownConds) > 0 { | ||
if pkCol != nil { | ||
path.accessConds, path.tableFilters = ranger.DetachCondsForTableRange(ds.ctx, ds.pushedDownConds, pkCol) | ||
path.ranges, err = ranger.BuildTableRange(path.accessConds, sc, pkCol.RetType) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
path.countAfterAccess, err = ds.statisticTable.GetRowCountByIntColumnRanges(sc, pkCol.ID, path.ranges) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
} else { | ||
path.tableFilters = ds.pushedDownConds | ||
} | ||
path.ranges = ranger.FullIntRange(mysql.HasUnsignedFlag(pkCol.RetType.Flag)) | ||
if len(ds.pushedDownConds) == 0 { | ||
return nil | ||
} | ||
path.accessConds, path.tableFilters = ranger.DetachCondsForTableRange(ds.ctx, ds.pushedDownConds, pkCol) | ||
path.ranges, err = ranger.BuildTableRange(path.accessConds, sc, pkCol.RetType) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
path.countAfterAccess, err = ds.statisticTable.GetRowCountByIntColumnRanges(sc, pkCol.ID, path.ranges) | ||
if err != nil { | ||
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. no need to check, |
||
return errors.Trace(err) | ||
} | ||
return nil | ||
} | ||
|
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.
We'better add some test cases to cover
pkCol == nil
andpkCol !=nil
.