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

planner: remove useless check #54907

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/planner/core/collect_column_stats_usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func (c *columnStatsUsageCollector) collectFromPlan(lp base.LogicalPlan) {

// CollectColumnStatsUsage collects column stats usage from logical plan.
// predicate indicates whether to collect predicate columns and histNeeded indicates whether to collect histogram-needed columns.
// First return value: predicate columns (nil if predicate is false)
// First return value: predicate columns
// Second return value: histogram-needed columns (nil if histNeeded is false)
// Third return value: ds.PhysicalTableID from all DataSource (always collected)
func CollectColumnStatsUsage(lp base.LogicalPlan, histNeeded bool) (
Expand Down
5 changes: 2 additions & 3 deletions pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,8 @@ func (s *session) UpdateColStatsUsage(predicateColumns []model.TableItemID) {
t := time.Now()
colMap := make(map[model.TableItemID]time.Time, len(predicateColumns))
for _, col := range predicateColumns {
if col.IsIndex {
continue
}
// TODO: Remove this assertion once it has been confirmed to operate correctly over a period of time.
intest.Assert(!col.IsIndex, "predicate column should only be table column")
colMap[col] = t
}
s.statsCollector.UpdateColStatsUsage(colMap)
Expand Down
31 changes: 0 additions & 31 deletions pkg/statistics/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,37 +422,6 @@ func (hg *Histogram) StandardizeForV2AnalyzeIndex() {
hg.Bounds = c
}

// AddIdxVals adds the given values to the histogram.
func (hg *Histogram) AddIdxVals(idxValCntPairs []TopNMeta) {
totalAddCnt := int64(0)
slices.SortFunc(idxValCntPairs, func(i, j TopNMeta) int {
return bytes.Compare(i.Encoded, j.Encoded)
})
for bktIdx, pairIdx := 0, 0; bktIdx < hg.Len(); bktIdx++ {
for pairIdx < len(idxValCntPairs) {
// If the current val smaller than current bucket's lower bound, skip it.
cmpResult := bytes.Compare(hg.Bounds.Column(0).GetBytes(bktIdx*2), idxValCntPairs[pairIdx].Encoded)
if cmpResult > 0 {
continue
}
// If the current val bigger than current bucket's upper bound, break.
cmpResult = bytes.Compare(hg.Bounds.Column(0).GetBytes(bktIdx*2+1), idxValCntPairs[pairIdx].Encoded)
if cmpResult < 0 {
break
}
totalAddCnt += int64(idxValCntPairs[pairIdx].Count)
hg.Buckets[bktIdx].NDV++
if cmpResult == 0 {
hg.Buckets[bktIdx].Repeat = int64(idxValCntPairs[pairIdx].Count)
pairIdx++
break
}
pairIdx++
}
hg.Buckets[bktIdx].Count += totalAddCnt
}
}

// ToString gets the string representation for the histogram.
func (hg *Histogram) ToString(idxCols int) string {
strs := make([]string, 0, hg.Len()+1)
Expand Down