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