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, statistics: fix the inconsistent est when table has no stats #52427
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #52427 +/- ##
================================================
+ Coverage 72.2252% 75.0604% +2.8352%
================================================
Files 1467 1489 +22
Lines 426895 436889 +9994
================================================
+ Hits 308326 327931 +19605
+ Misses 99450 87983 -11467
- Partials 19119 20975 +1856
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -572,7 +572,9 @@ func CleanFakeItemsForShowHistInFlights(statsCache statstypes.StatsCache) int { | |||
if item.IsIndex { | |||
_, loadNeeded = tbl.IndexIsLoadNeeded(item.ID) | |||
} else { | |||
_, loadNeeded = tbl.ColumnIsLoadNeeded(item.ID, true) |
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 keep the async load unchanged. Wait for later patch to handle it.
/retest |
@@ -195,11 +195,21 @@ func (c *columnStatsUsageCollector) addHistNeededColumns(ds *DataSource) { | |||
colIDSet := intset.NewFastIntSet() | |||
|
|||
for _, col := range columns { | |||
// If the column is plan-generated one, Skip 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.
What does "plan-generated" mean?
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.
Such that ID=-1 means ExtraHandleCol
tblColID := model.TableItemID{TableID: ds.physicalTableID, ID: col.ID, IsIndex: false} | ||
colIDSet.Insert(int(col.ID)) | ||
c.histNeededCols[tblColID] = true | ||
} | ||
for _, col := range ds.Columns { | ||
// If the column is plan-generated one, Skip 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.
ditto.
// If we don't have it in memory, we create a fake hist for pseudo estimation. | ||
if !ok { | ||
// If we don't have this column. We skip it. | ||
// It's something ridiculous. But it's possible that the stats don't have some ColumnInfo. |
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.
So this means this column has stats but doesn't have ColumnInfo
.
In what case would this happen?
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.
Such that alter table add column
ddl event is not handled by the StatsHandle. Currently, the statistis.Table is initialized by the stats. not by the model.TableInfo
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hawkingrei, time-and-fate The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold |
[LGTM Timeline notifier]Timeline:
|
Co-authored-by: Zhou Kunqin <25057648+time-and-fate@users.noreply.github.com>
/unhold |
In response to a cherrypick label: new pull request created to branch |
What problem does this PR solve?
Issue Number: close #52426
Problem Summary:
What changed and how does it work?
The
Selectivity
needs a memory obj to trigger the pseudo estimation.We add one.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.