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