Skip to content
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

Merged
merged 4 commits into from
Apr 13, 2017
Merged

Conversation

coocood
Copy link
Member

@coocood coocood commented Apr 12, 2017

  1. Move estimate-range logic to statistics package
  2. Change count type from int64 to float64
  3. Separate pseudo and real logic.

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
Copy link
Member

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?

Copy link
Member Author

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,
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

@hanfei1991 hanfei1991 added the priority/P1 The issue has P1 priority. label Apr 12, 2017
}
} else if totalCount-lastCount <= valuesPerBucket {
} else if totalCount-float64(lastCount) <= valuesPerBucket {
// TODO: Making sampleFactor as float may be better.
Copy link
Contributor

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.
Copy link
Member

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

Copy link
Member

@hanfei1991 hanfei1991 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hanfei1991 hanfei1991 merged commit dcf12b5 into master Apr 13, 2017
@hanfei1991 hanfei1991 deleted the coocood/estimate-range branch April 13, 2017 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/P1 The issue has P1 priority.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants