@@ -282,9 +282,9 @@ func (h *Handle) initStatsHistograms4Chunk(is infoschema.InfoSchema, cache stats
282
282
}
283
283
}
284
284
285
- // initStatsHistogramsSQLGen generates the SQL to load all stats_histograms records.
285
+ // genInitStatsHistogramsSQL generates the SQL to load all stats_histograms records.
286
286
// We need to read all the records since we need to do initialization of table.ColAndIdxExistenceMap.
287
- func initStatsHistogramsSQLGen (isPaging bool ) string {
287
+ func genInitStatsHistogramsSQL (isPaging bool ) string {
288
288
selectPrefix := "select /*+ ORDER_INDEX(mysql.stats_histograms,tbl) */ HIGH_PRIORITY table_id, is_index, hist_id, distinct_count, version, null_count, cm_sketch, tot_col_size, stats_ver, correlation, flag, last_analyze_pos from mysql.stats_histograms"
289
289
orderSuffix := " order by table_id"
290
290
if ! isPaging {
@@ -294,7 +294,7 @@ func initStatsHistogramsSQLGen(isPaging bool) string {
294
294
}
295
295
296
296
func (h * Handle ) initStatsHistogramsLite (ctx context.Context , cache statstypes.StatsCache ) error {
297
- sql := initStatsHistogramsSQLGen (false )
297
+ sql := genInitStatsHistogramsSQL (false )
298
298
rc , err := util .Exec (h .initStatsCtx , sql )
299
299
if err != nil {
300
300
return errors .Trace (err )
@@ -317,7 +317,7 @@ func (h *Handle) initStatsHistogramsLite(ctx context.Context, cache statstypes.S
317
317
}
318
318
319
319
func (h * Handle ) initStatsHistograms (is infoschema.InfoSchema , cache statstypes.StatsCache ) error {
320
- sql := initStatsHistogramsSQLGen (false )
320
+ sql := genInitStatsHistogramsSQL (false )
321
321
rc , err := util .Exec (h .initStatsCtx , sql )
322
322
if err != nil {
323
323
return errors .Trace (err )
@@ -351,7 +351,7 @@ func (h *Handle) initStatsHistogramsByPaging(is infoschema.InfoSchema, cache sta
351
351
}()
352
352
353
353
sctx := se .(sessionctx.Context )
354
- sql := initStatsHistogramsSQLGen (true )
354
+ sql := genInitStatsHistogramsSQL (true )
355
355
rc , err := util .Exec (sctx , sql , task .StartTid , task .EndTid )
356
356
if err != nil {
357
357
return errors .Trace (err )
@@ -430,10 +430,10 @@ func (*Handle) initStatsTopN4Chunk(cache statstypes.StatsCache, iter *chunk.Iter
430
430
}
431
431
}
432
432
433
- // initStatsTopNSQLGen generates the SQL to load all stats_top_n records.
433
+ // genInitStatsTopNSQLForIndexes generates the SQL to load all stats_top_n records for indexes .
434
434
// We only need to load the indexes' since we only record the existence of columns in ColAndIdxExistenceMap.
435
435
// The stats of the column is not loaded during the bootstrap process.
436
- func initStatsTopNSQLGen (isPaging bool ) string {
436
+ func genInitStatsTopNSQLForIndexes (isPaging bool ) string {
437
437
selectPrefix := "select /*+ ORDER_INDEX(mysql.stats_top_n,tbl) */ HIGH_PRIORITY table_id, hist_id, value, count from mysql.stats_top_n where is_index = 1"
438
438
orderSuffix := " order by table_id"
439
439
if ! isPaging {
@@ -443,7 +443,7 @@ func initStatsTopNSQLGen(isPaging bool) string {
443
443
}
444
444
445
445
func (h * Handle ) initStatsTopN (cache statstypes.StatsCache , totalMemory uint64 ) error {
446
- sql := initStatsTopNSQLGen (false )
446
+ sql := genInitStatsTopNSQLForIndexes (false )
447
447
rc , err := util .Exec (h .initStatsCtx , sql )
448
448
if err != nil {
449
449
return errors .Trace (err )
@@ -476,7 +476,7 @@ func (h *Handle) initStatsTopNByPaging(cache statstypes.StatsCache, task initsta
476
476
}
477
477
}()
478
478
sctx := se .(sessionctx.Context )
479
- sql := initStatsTopNSQLGen (true )
479
+ sql := genInitStatsTopNSQLForIndexes (true )
480
480
rc , err := util .Exec (sctx , sql , task .StartTid , task .EndTid )
481
481
if err != nil {
482
482
return errors .Trace (err )
@@ -614,10 +614,10 @@ func (*Handle) initStatsBuckets4Chunk(cache statstypes.StatsCache, iter *chunk.I
614
614
}
615
615
}
616
616
617
- // initStatsBucketsSQLGen generates the SQL to load all stats_top_n records.
617
+ // genInitStatsBucketsSQLForIndexes generates the SQL to load all stats_buckets records for indexes .
618
618
// We only need to load the indexes' since we only record the existence of columns in ColAndIdxExistenceMap.
619
619
// The stats of the column is not loaded during the bootstrap process.
620
- func initStatsBucketsSQLGen (isPaging bool ) string {
620
+ func genInitStatsBucketsSQLForIndexes (isPaging bool ) string {
621
621
selectPrefix := "select /*+ ORDER_INDEX(mysql.stats_buckets,tbl) */ HIGH_PRIORITY table_id, hist_id, count, repeats, lower_bound, upper_bound, ndv from mysql.stats_buckets where is_index=1"
622
622
orderSuffix := " order by table_id"
623
623
if ! isPaging {
@@ -636,7 +636,7 @@ func (h *Handle) initStatsBuckets(cache statstypes.StatsCache, totalMemory uint6
636
636
return errors .Trace (err )
637
637
}
638
638
} else {
639
- sql := initStatsBucketsSQLGen (false )
639
+ sql := genInitStatsBucketsSQLForIndexes (false )
640
640
rc , err := util .Exec (h .initStatsCtx , sql )
641
641
if err != nil {
642
642
return errors .Trace (err )
@@ -675,7 +675,7 @@ func (h *Handle) initStatsBucketsByPaging(cache statstypes.StatsCache, task init
675
675
}
676
676
}()
677
677
sctx := se .(sessionctx.Context )
678
- sql := initStatsBucketsSQLGen (true )
678
+ sql := genInitStatsBucketsSQLForIndexes (true )
679
679
rc , err := util .Exec (sctx , sql , task .StartTid , task .EndTid )
680
680
if err != nil {
681
681
return errors .Trace (err )
0 commit comments