@@ -33,23 +33,27 @@ func init() {
33
33
}
34
34
35
35
// GetRowCountByColumnRanges estimates the row count by a slice of Range.
36
- func GetRowCountByColumnRanges (sctx context.PlanContext , coll * statistics.HistColl , colID int64 , colRanges []* ranger.Range ) (result float64 , err error ) {
36
+ func GetRowCountByColumnRanges (sctx context.PlanContext , coll * statistics.HistColl , colUniqueID int64 , colRanges []* ranger.Range ) (result float64 , err error ) {
37
37
var name string
38
38
if sctx .GetSessionVars ().StmtCtx .EnableOptimizerDebugTrace {
39
39
debugtrace .EnterContextCommon (sctx )
40
- debugTraceGetRowCountInput (sctx , colID , colRanges )
40
+ debugTraceGetRowCountInput (sctx , colUniqueID , colRanges )
41
41
defer func () {
42
42
debugtrace .RecordAnyValuesWithNames (sctx , "Name" , name , "Result" , result )
43
43
debugtrace .LeaveContextCommon (sctx )
44
44
}()
45
45
}
46
46
sc := sctx .GetSessionVars ().StmtCtx
47
- c , ok := coll .Columns [colID ]
48
- recordUsedItemStatsStatus (sctx , c , coll .PhysicalID , colID )
47
+ c , ok := coll .Columns [colUniqueID ]
48
+ colInfoID := colUniqueID
49
+ if len (coll .UniqueID2colInfoID ) > 0 {
50
+ colInfoID = coll .UniqueID2colInfoID [colUniqueID ]
51
+ }
52
+ recordUsedItemStatsStatus (sctx , c , coll .PhysicalID , colInfoID )
49
53
if c != nil && c .Info != nil {
50
54
name = c .Info .Name .O
51
55
}
52
- if statistics .ColumnStatsIsInvalid (c , sctx , coll , colID ) {
56
+ if statistics .ColumnStatsIsInvalid (c , sctx , coll , colUniqueID ) {
53
57
result , err = getPseudoRowCountByColumnRanges (sc .TypeCtx (), float64 (coll .RealtimeCount ), colRanges , 0 )
54
58
if err == nil && sc .EnableOptimizerCETrace && ok {
55
59
ceTraceRange (sctx , coll .PhysicalID , []string {c .Info .Name .O }, colRanges , "Column Stats-Pseudo" , uint64 (result ))
@@ -71,23 +75,27 @@ func GetRowCountByColumnRanges(sctx context.PlanContext, coll *statistics.HistCo
71
75
}
72
76
73
77
// GetRowCountByIntColumnRanges estimates the row count by a slice of IntColumnRange.
74
- func GetRowCountByIntColumnRanges (sctx context.PlanContext , coll * statistics.HistColl , colID int64 , intRanges []* ranger.Range ) (result float64 , err error ) {
78
+ func GetRowCountByIntColumnRanges (sctx context.PlanContext , coll * statistics.HistColl , colUniqueID int64 , intRanges []* ranger.Range ) (result float64 , err error ) {
75
79
var name string
76
80
if sctx .GetSessionVars ().StmtCtx .EnableOptimizerDebugTrace {
77
81
debugtrace .EnterContextCommon (sctx )
78
- debugTraceGetRowCountInput (sctx , colID , intRanges )
82
+ debugTraceGetRowCountInput (sctx , colUniqueID , intRanges )
79
83
defer func () {
80
84
debugtrace .RecordAnyValuesWithNames (sctx , "Name" , name , "Result" , result )
81
85
debugtrace .LeaveContextCommon (sctx )
82
86
}()
83
87
}
84
88
sc := sctx .GetSessionVars ().StmtCtx
85
- c , ok := coll .Columns [colID ]
86
- recordUsedItemStatsStatus (sctx , c , coll .PhysicalID , colID )
89
+ c , ok := coll .Columns [colUniqueID ]
90
+ colInfoID := colUniqueID
91
+ if len (coll .UniqueID2colInfoID ) > 0 {
92
+ colInfoID = coll .UniqueID2colInfoID [colUniqueID ]
93
+ }
94
+ recordUsedItemStatsStatus (sctx , c , coll .PhysicalID , colInfoID )
87
95
if c != nil && c .Info != nil {
88
96
name = c .Info .Name .O
89
97
}
90
- if statistics .ColumnStatsIsInvalid (c , sctx , coll , colID ) {
98
+ if statistics .ColumnStatsIsInvalid (c , sctx , coll , colUniqueID ) {
91
99
if len (intRanges ) == 0 {
92
100
return 0 , nil
93
101
}
0 commit comments