@@ -30,6 +30,7 @@ import (
30
30
"github.com/pingcap/tidb/pkg/parser/mysql"
31
31
"github.com/pingcap/tidb/pkg/sessionctx"
32
32
"github.com/pingcap/tidb/pkg/sessionctx/stmtctx"
33
+ "github.com/pingcap/tidb/pkg/sessionctx/variable"
33
34
"github.com/pingcap/tidb/pkg/statistics"
34
35
"github.com/pingcap/tidb/pkg/statistics/handle/storage"
35
36
statstypes "github.com/pingcap/tidb/pkg/statistics/handle/types"
@@ -300,6 +301,14 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
300
301
s .statsHandle .SPool ().Put (se )
301
302
}
302
303
}()
304
+ var skipTypes map [string ]struct {}
305
+ val , err := sctx .GetSessionVars ().GlobalVarsAccessor .GetGlobalSysVar (variable .TiDBAnalyzeSkipColumnTypes )
306
+ if err != nil {
307
+ logutil .BgLogger ().Warn ("failed to get global variable" , zap .Error (err ))
308
+ } else {
309
+ skipTypes = variable .ParseAnalyzeSkipColumnTypes (val )
310
+ }
311
+
303
312
item := task .Item .TableItemID
304
313
tbl , ok := s .statsHandle .Get (item .TableID )
305
314
@@ -335,6 +344,13 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
335
344
// so we have to get the column info from the domain.
336
345
wrapper .colInfo = tblInfo .Meta ().GetColumnByID (item .ID )
337
346
}
347
+ if skipTypes != nil {
348
+ _ , skip := skipTypes [types .TypeToStr (wrapper .colInfo .FieldType .GetType (), wrapper .colInfo .FieldType .GetCharset ())]
349
+ if skip {
350
+ return nil
351
+ }
352
+ }
353
+
338
354
// If this column is not analyzed yet and we don't have it in memory.
339
355
// We create a fake one for the pseudo estimation.
340
356
if loadNeeded && ! analyzed {
@@ -348,6 +364,7 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
348
364
return nil
349
365
}
350
366
}
367
+ failpoint .Inject ("handleOneItemTaskPanic" , nil )
351
368
t := time .Now ()
352
369
needUpdate := false
353
370
wrapper , err = s .readStatsForOneItem (sctx , item , wrapper , isPkIsHandle , task .Item .FullLoad )
0 commit comments