-
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
statistics: refactor statistics package. #3044
Conversation
Prepare for more accurate estimation.
@@ -125,7 +125,7 @@ func (p *requiredProperty) String() string { | |||
type physicalPlanInfo struct { | |||
p PhysicalPlan | |||
cost float64 | |||
count uint64 | |||
count float64 |
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.
Why change this to float64?
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 do division operation on count
, integer value loses precision.
@@ -239,3 +258,97 @@ func PseudoTable(ti *model.TableInfo) *Table { | |||
} | |||
return t | |||
} | |||
|
|||
func getPseudoRowCountByIndexRanges(sc *variable.StatementContext, indexRanges []*types.IndexRange, inAndEQCnt int, |
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.
Any test case for the newly added functions?
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.
It's not newly added, just moved from plan.
There are test cases in plan cover this.
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.
The current algorithm is not good, will be changed later.
We can add test cases when we change it.
statistics/builder.go
Outdated
} | ||
} else if totalCount-lastCount <= valuesPerBucket { | ||
} else if totalCount-float64(lastCount) <= valuesPerBucket { | ||
// TODO: Making sampleFactor as float may be better. |
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.
sampleFactor
is already float?
@@ -172,8 +173,8 @@ func (t *Table) String() string { | |||
return strings.Join(strs, "\n") | |||
} | |||
|
|||
// ColumnIsInvalid checks if this column is invalid. Exported for test. |
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.
now we don't export it
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.
LGTM
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.
LGTM
Prepare for more accurate estimation.