Skip to content

Commit

Permalink
address
Browse files Browse the repository at this point in the history
  • Loading branch information
lzmhhh123 committed Oct 29, 2019
1 parent d2d1a9d commit b8a6a7a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ func (p *LogicalJoin) constructInnerTableScanTask(
for i := range ds.stats.Cardinality {
ds.stats.Cardinality[i] = 1
}
rowSize := ds.TblColHists.GetTableAvgRowSize(ds.TblCols, ts.StoreType, ds.tableInfo.PKIsHandle)
rowSize := ds.TblColHists.GetTableAvgRowSize(ds.TblCols, ts.StoreType, true)
sessVars := ds.ctx.GetSessionVars()
copTask := &copTask{
tablePlan: ts,
Expand Down
6 changes: 3 additions & 3 deletions planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func (ds *DataSource) buildIndexMergeTableScan(prop *property.PhysicalProperty,
}
}
}
rowSize := ds.TblColHists.GetTableAvgRowSize(ds.TblCols, ts.StoreType, ds.tableInfo.PKIsHandle)
rowSize := ds.TblColHists.GetTableAvgRowSize(ds.TblCols, ts.StoreType, true)
partialCost += totalRowCount * rowSize * sessVars.ScanFactor
ts.stats = ds.tableStats.ScaleByExpectCnt(totalRowCount)
if ds.statisticTable.Pseudo {
Expand Down Expand Up @@ -1069,9 +1069,9 @@ func (ds *DataSource) getOriginalPhysicalTableScan(prop *property.PhysicalProper
ts.stats = ds.tableStats.ScaleByExpectCnt(rowCount)
var rowSize float64
if ts.StoreType == kv.TiKV {
rowSize = ds.TblColHists.GetTableAvgRowSize(ds.TblCols, ts.StoreType, ds.tableInfo.PKIsHandle)
rowSize = ds.TblColHists.GetTableAvgRowSize(ds.TblCols, ts.StoreType, true)
} else {
rowSize = ds.TblColHists.GetTableAvgRowSize(ts.Schema().Columns, ts.StoreType, ds.tableInfo.PKIsHandle)
rowSize = ds.TblColHists.GetTableAvgRowSize(ts.Schema().Columns, ts.StoreType, ds.handleCol != nil)
}
sessVars := ds.ctx.GetSessionVars()
cost := rowCount * rowSize * sessVars.ScanFactor
Expand Down
4 changes: 2 additions & 2 deletions statistics/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,15 +691,15 @@ func (coll *HistColl) GetAvgRowSize(cols []*expression.Column, isEncodedKey bool
}

// GetTableAvgRowSize computes average row size for a table scan, exclude the index key-value pairs.
func (coll *HistColl) GetTableAvgRowSize(cols []*expression.Column, storeType kv.StoreType, pkIsHandle bool) (size float64) {
func (coll *HistColl) GetTableAvgRowSize(cols []*expression.Column, storeType kv.StoreType, handleInCols bool) (size float64) {
size = coll.GetAvgRowSize(cols, false)
switch storeType {
case kv.TiKV:
size += tablecodec.RecordRowKeyLen
// The `cols` for TiKV always contain the row_id, so prefix row size subtract its length.
size -= 8
case kv.TiFlash:
if !pkIsHandle {
if !handleInCols {
size += 8 /* row_id length */
}
}
Expand Down

0 comments on commit b8a6a7a

Please sign in to comment.