stats: replace Copy with ShallowCopy for table stats update logic (#62430)
ref pingcap/tidb#57868
This commit is contained in:
2
pkg/statistics/handle/cache/statscache.go
vendored
2
pkg/statistics/handle/cache/statscache.go
vendored
@ -206,7 +206,7 @@ func (s *StatsCacheImpl) Update(ctx context.Context, is infoschema.InfoSchema, t
|
||||
// If the column/index stats has not been updated, we can reuse the old table stats.
|
||||
// Only need to update the count and modify count.
|
||||
if ok && latestHistUpdateVersion > 0 && oldTbl.LastStatsHistVersion >= latestHistUpdateVersion {
|
||||
tbl = oldTbl.Copy()
|
||||
tbl = oldTbl.ShallowCopy()
|
||||
// count and modify count is updated in finalProcess
|
||||
needLoadColAndIdxStats = false
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ func TestLoadHist(t *testing.T) {
|
||||
require.False(t, newStatsTbl2 == newStatsTbl)
|
||||
// The histograms is not updated.
|
||||
newStatsTbl.ForEachColumnImmutable(func(id int64, hist *statistics.Column) bool {
|
||||
require.Equal(t, newStatsTbl2.GetCol(id), hist)
|
||||
require.Equal(t, hist.LastUpdateVersion, newStatsTbl2.GetCol(id).LastUpdateVersion)
|
||||
return false
|
||||
})
|
||||
require.Greater(t, newStatsTbl2.GetCol(3).LastUpdateVersion, newStatsTbl2.GetCol(1).LastUpdateVersion)
|
||||
|
||||
Reference in New Issue
Block a user