@@ -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"
@@ -306,6 +307,14 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
306
307
s .statsHandle .SPool ().Destroy (se )
307
308
}
308
309
}()
310
+ var skipTypes map [string ]struct {}
311
+ val , err := sctx .GetSessionVars ().GlobalVarsAccessor .GetGlobalSysVar (variable .TiDBAnalyzeSkipColumnTypes )
312
+ if err != nil {
313
+ logutil .BgLogger ().Warn ("failed to get global variable" , zap .Error (err ))
314
+ } else {
315
+ skipTypes = variable .ParseAnalyzeSkipColumnTypes (val )
316
+ }
317
+
309
318
item := task .Item .TableItemID
310
319
statsTbl , ok := s .statsHandle .Get (item .TableID )
311
320
@@ -342,6 +351,13 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
342
351
// so we have to get the column info from the domain.
343
352
wrapper .colInfo = tblInfo .GetColumnByID (item .ID )
344
353
}
354
+ if skipTypes != nil {
355
+ _ , skip := skipTypes [types .TypeToStr (wrapper .colInfo .FieldType .GetType (), wrapper .colInfo .FieldType .GetCharset ())]
356
+ if skip {
357
+ return nil
358
+ }
359
+ }
360
+
345
361
// If this column is not analyzed yet and we don't have it in memory.
346
362
// We create a fake one for the pseudo estimation.
347
363
// Otherwise, it will trigger the sync/async load again, even if the column has not been analyzed.
@@ -351,6 +367,7 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
351
367
return nil
352
368
}
353
369
}
370
+ failpoint .Inject ("handleOneItemTaskPanic" , nil )
354
371
t := time .Now ()
355
372
needUpdate := false
356
373
wrapper , err = s .readStatsForOneItem (sctx , item , wrapper , isPkIsHandle , task .Item .FullLoad )
0 commit comments