@@ -28,6 +28,7 @@ import (
28
28
"github.com/pingcap/tidb/pkg/parser/mysql"
29
29
"github.com/pingcap/tidb/pkg/sessionctx"
30
30
"github.com/pingcap/tidb/pkg/sessionctx/stmtctx"
31
+ "github.com/pingcap/tidb/pkg/sessionctx/variable"
31
32
"github.com/pingcap/tidb/pkg/statistics"
32
33
"github.com/pingcap/tidb/pkg/statistics/handle/storage"
33
34
utilstats "github.com/pingcap/tidb/pkg/statistics/handle/util"
@@ -280,6 +281,19 @@ func (h *Handle) handleOneItemTask(task *NeededItemTask) (err error) {
280
281
h .SPool ().Put (se )
281
282
}
282
283
}()
284
+ << << << < HEAD:pkg / statistics / handle / handle_hist .go
285
+ == == == =
286
+ var skipTypes map [string ]struct {}
287
+ val , err := sctx .GetSessionVars ().GlobalVarsAccessor .GetGlobalSysVar (variable .TiDBAnalyzeSkipColumnTypes )
288
+ if err != nil {
289
+ logutil .BgLogger ().Warn ("failed to get global variable" , zap .Error (err ))
290
+ } else {
291
+ skipTypes = variable .ParseAnalyzeSkipColumnTypes (val )
292
+ }
293
+
294
+ item := task .Item .TableItemID
295
+ tbl , ok := s .statsHandle .Get (item .TableID )
296
+ >> >> >> > bfec7325a12 (statsitstics : avoid sync load column which is skiped type to analyze (#57144 )):pkg / statistics / handle / syncload / stats_syncload.go
283
297
284
298
item := task .TableItemID
285
299
tbl , ok := h .Get (item .TableID )
@@ -294,12 +308,44 @@ func (h *Handle) handleOneItemTask(task *NeededItemTask) (err error) {
294
308
}
295
309
wrapper .idx = index
296
310
} else {
311
+ << << << < HEAD:pkg / statistics / handle / handle_hist .go
297
312
col , ok := tbl .Columns [item .ID ]
298
313
if ! ok || col .IsFullLoad () {
314
+ == == == =
315
+ col , loadNeeded , analyzed := tbl .ColumnIsLoadNeeded (item .ID , task .Item .FullLoad )
316
+ if ! loadNeeded {
317
+ return nil
318
+ }
319
+ if col != nil {
320
+ wrapper .colInfo = col .Info
321
+ } else {
322
+ // Now, we cannot init the column info in the ColAndIdxExistenceMap when to disable lite-init-stats.
323
+ // so we have to get the column info from the domain.
324
+ wrapper .colInfo = tblInfo .Meta ().GetColumnByID (item .ID )
325
+ }
326
+ if skipTypes != nil {
327
+ _ , skip := skipTypes [types .TypeToStr (wrapper .colInfo .FieldType .GetType (), wrapper .colInfo .FieldType .GetCharset ())]
328
+ if skip {
329
+ return nil
330
+ }
331
+ }
332
+
333
+ // If this column is not analyzed yet and we don't have it in memory.
334
+ // We create a fake one for the pseudo estimation.
335
+ if loadNeeded && ! analyzed {
336
+ wrapper .col = & statistics.Column {
337
+ PhysicalID : item .TableID ,
338
+ Info : wrapper .colInfo ,
339
+ Histogram : * statistics .NewHistogram (item .ID , 0 , 0 , 0 , & wrapper .colInfo .FieldType , 0 , 0 ),
340
+ IsHandle : isPkIsHandle && mysql .HasPriKeyFlag (wrapper .colInfo .GetFlag ()),
341
+ }
342
+ s .updateCachedItem (tblInfo , item , wrapper .col , wrapper .idx , task .Item .FullLoad )
343
+ >> >> >> > bfec7325a12 (statsitstics : avoid sync load column which is skiped type to analyze (#57144 )):pkg / statistics / handle / syncload / stats_syncload.go
299
344
return nil
300
345
}
301
346
wrapper .col = col
302
347
}
348
+ failpoint .Inject ("handleOneItemTaskPanic" , nil )
303
349
t := time .Now ()
304
350
needUpdate := false
305
351
wrapper , err = h .readStatsForOneItem (sctx , item , wrapper )
0 commit comments