Skip to content

Commit e5a8a23

Browse files
authored
*: enable the predicate columns feature by default (pingcap#54440)
ref pingcap#53567
1 parent 0b9cd2f commit e5a8a23

File tree

121 files changed

+481
-342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+481
-342
lines changed

br/pkg/backup/schema_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func TestBuildBackupRangeAndSchemaWithBrokenStats(t *testing.T) {
206206
tk.MustExec("drop table if exists t3;")
207207
tk.MustExec("create table t3 (a char(1));")
208208
tk.MustExec("insert into t3 values ('1');")
209-
tk.MustExec("analyze table t3;")
209+
tk.MustExec("analyze table t3 all columns;")
210210
// corrupt the statistics like pingcap/br#679.
211211
tk.MustExec(`
212212
update mysql.stats_buckets set upper_bound = 0xffffffff
@@ -251,7 +251,7 @@ func TestBuildBackupRangeAndSchemaWithBrokenStats(t *testing.T) {
251251
require.NotNil(t, schemas[0].DB)
252252

253253
// recover the statistics.
254-
tk.MustExec("analyze table t3;")
254+
tk.MustExec("analyze table t3 all columns;")
255255

256256
_, backupSchemas, _, err = backup.BuildBackupRangeAndInitSchema(m.Storage, f, math.MaxUint64, false, true)
257257
require.NoError(t, err)

br/pkg/restore/snap_client/systable_restore_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,5 @@ func TestCheckSysTableCompatibility(t *testing.T) {
115115
//
116116
// The above variables are in the file br/pkg/restore/systable_restore.go
117117
func TestMonitorTheSystemTableIncremental(t *testing.T) {
118-
require.Equal(t, int64(209), session.CurrentBootstrapVersion)
118+
require.Equal(t, int64(210), session.CurrentBootstrapVersion)
119119
}

pkg/executor/analyze_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ func TestAnalyzePartitionTableByConcurrencyInDynamic(t *testing.T) {
108108
tk.MustExec("set @@tidb_partition_prune_mode='dynamic'")
109109
tk.MustExec("use test")
110110
tk.MustExec("create table t(id int) partition by hash(id) partitions 4")
111+
tk.MustExec("select * from t where id = 0")
112+
do, err := session.GetDomain(store)
113+
require.NoError(t, err)
114+
statsHandle := do.StatsHandle()
115+
require.NoError(t, statsHandle.DumpColStatsUsageToKV())
111116
testcases := []struct {
112117
concurrency string
113118
}{

pkg/executor/distsql_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func TestAdaptiveClosestRead(t *testing.T) {
381381

382382
tk.MustExec("create table t(id int primary key, s varchar(8), p varchar(16));")
383383
tk.MustExec("insert into t values (1, '00000001', '0000000000000001'), (2, '00000003', '0000000000000002'), (3, '00000011', '0000000000000003');")
384-
tk.MustExec("analyze table t;")
384+
tk.MustExec("analyze table t all columns;")
385385

386386
tk.MustExec("set @@tidb_partition_prune_mode ='static';")
387387
tk.MustExec("set tidb_replica_read = 'closest-adaptive';")
@@ -404,7 +404,7 @@ func TestAdaptiveClosestRead(t *testing.T) {
404404
tk.MustExec("drop table if exists t")
405405
tk.MustExec("create table t(id int primary key, s varchar(8), p varchar(16)) " + partitionDef)
406406
tk.MustExec("insert into t values (1, '00000001', '0000000000000001'), (2, '00000003', '0000000000000002'), (3, '00000011', '0000000000000003'), (4, '00000044', '0000000000000004');")
407-
tk.MustExec("analyze table t;")
407+
tk.MustExec("analyze table t all columns;")
408408
// estimate cost is 38
409409
checkMetrics("select s from t where id >= 1 and id < 3;", 1, 0)
410410
// estimate cost is 39 with 2 cop request
@@ -414,7 +414,7 @@ func TestAdaptiveClosestRead(t *testing.T) {
414414
tk.MustExec("drop table if exists t;")
415415
tk.MustExec("create table t (id int, s varchar(8), p varchar(8), key `idx_s_p`(`s`, `p`));")
416416
tk.MustExec("insert into t values (1, 'test1000', '11111111'), (2, 'test2000', '11111111');")
417-
tk.MustExec("analyze table t;")
417+
tk.MustExec("analyze table t all columns;")
418418
// avg row size = 27.91
419419
checkMetrics("select p from t where s >= 'test' and s < 'test11'", 0, 1)
420420
checkMetrics("select p from t where s >= 'test' and s < 'test22'", 1, 0)
@@ -424,7 +424,7 @@ func TestAdaptiveClosestRead(t *testing.T) {
424424
tk.MustExec("drop table if exists t;")
425425
tk.MustExec("create table t (v int, id int, p varchar(8), key `idx_id_p`(`id`, `p`)) " + partitionDef)
426426
tk.MustExec("insert into t values (1, 1, '11111111'), (2, 2, '22222222'), (3, 3, '33333333'), (4, 4, '44444444');")
427-
tk.MustExec("analyze table t;")
427+
tk.MustExec("analyze table t all columns;")
428428
// avg row size = 19
429429
checkMetrics("select p from t where id >= 1 and id < 3", 1, 0)
430430
checkMetrics("select p from t where id >= 2 and id < 4", 0, 2)
@@ -435,7 +435,7 @@ func TestAdaptiveClosestRead(t *testing.T) {
435435
tk.MustExec("create table t (id int, s varchar(8), p varchar(50), key `idx_s`(`s`));")
436436
str := "this_is_a_string_with_length_of_50________________"
437437
tk.MustExec(fmt.Sprintf("insert into t values (1, 'test1000', '%s'), (2, 'test2000', '%s');", str, str))
438-
tk.MustExec("analyze table t;")
438+
tk.MustExec("analyze table t all columns;")
439439
tk.MustExec("set tidb_adaptive_closest_read_threshold = 80;")
440440
// IndexReader cost is 22, TableReader cost (1 row) is 67
441441
checkMetrics("select/*+ FORCE_INDEX(t, idx_s) */ p from t where s >= 'test' and s < 'test11'", 0, 2)
@@ -447,7 +447,7 @@ func TestAdaptiveClosestRead(t *testing.T) {
447447
// use int field to avoid the planer estimation with big random fluctuation.
448448
tk.MustExec("create table t (id int, v bigint not null, s1 int not null, s2 int not null, key `idx_v_s1`(`s1`, `v`), key `idx_s2`(`s2`));")
449449
tk.MustExec("insert into t values (1, 1, 1, 1), (2, 2, 2, 2), (3, 3, 3, 3);")
450-
tk.MustExec("analyze table t;")
450+
tk.MustExec("analyze table t all columns;")
451451
tk.MustExec("set tidb_adaptive_closest_read_threshold = 30;")
452452
// 2 IndexScan with cost 19/56, 2 TableReader with cost 32.5/65.
453453
checkMetrics("select/* +USE_INDEX_MERGE(t) */ id from t use index(`idx_v_s1`) use index(idx_s2) where (s1 < 3 and v > 0) or s2 = 3;", 3, 1)

pkg/executor/historical_stats_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestRecordHistoryStatsAfterAnalyze(t *testing.T) {
4242
tk.MustExec("set global tidb_enable_historical_stats = 0")
4343
tk.MustExec("use test")
4444
tk.MustExec("drop table if exists t")
45-
tk.MustExec("create table t(a int, b varchar(10))")
45+
tk.MustExec("create table t(a int, b varchar(10), index idx(a, b))")
4646

4747
h := dom.StatsHandle()
4848
is := dom.InfoSchema()
@@ -103,7 +103,7 @@ func TestRecordHistoryStatsMetaAfterAnalyze(t *testing.T) {
103103
tk.MustExec("set global tidb_enable_historical_stats = 0")
104104
tk.MustExec("use test")
105105
tk.MustExec("drop table if exists t")
106-
tk.MustExec("create table t(a int, b int)")
106+
tk.MustExec("create table t(a int, b int, index idx(a, b))")
107107
tk.MustExec("analyze table test.t")
108108

109109
h := dom.StatsHandle()
@@ -162,7 +162,7 @@ func TestGCHistoryStatsAfterDropTable(t *testing.T) {
162162
tk.MustExec("set global tidb_enable_historical_stats = 1")
163163
tk.MustExec("use test")
164164
tk.MustExec("drop table if exists t")
165-
tk.MustExec("create table t(a int, b varchar(10))")
165+
tk.MustExec("create table t(a int, b varchar(10), index idx(a, b))")
166166
tk.MustExec("analyze table test.t")
167167
is := dom.InfoSchema()
168168
tableInfo, err := is.TableByName(context.Background(), model.NewCIStr("test"), model.NewCIStr("t"))
@@ -248,7 +248,7 @@ func TestGCOutdatedHistoryStats(t *testing.T) {
248248
tk.MustExec("set global tidb_enable_historical_stats = 1")
249249
tk.MustExec("use test")
250250
tk.MustExec("drop table if exists t")
251-
tk.MustExec("create table t(a int, b varchar(10))")
251+
tk.MustExec("create table t(a int, b varchar(10), index idx(a, b))")
252252
tk.MustExec("analyze table test.t")
253253
is := dom.InfoSchema()
254254
tableInfo, err := is.TableByName(context.Background(), model.NewCIStr("test"), model.NewCIStr("t"))

pkg/executor/infoschema_reader_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func TestForAnalyzeStatus(t *testing.T) {
309309
tk.MustExec("insert into analyze_test values (1,2),(3,4)")
310310

311311
tk.MustQuery("select distinct TABLE_NAME from information_schema.analyze_status where TABLE_NAME='analyze_test'").Check([][]any{})
312-
tk.MustExec("analyze table analyze_test")
312+
tk.MustExec("analyze table analyze_test all columns")
313313
tk.MustQuery("select distinct TABLE_NAME from information_schema.analyze_status where TABLE_NAME='analyze_test'").Check(testkit.Rows("analyze_test"))
314314

315315
// test the privilege of new user for information_schema.analyze_status
@@ -326,7 +326,7 @@ func TestForAnalyzeStatus(t *testing.T) {
326326
// test the privilege of user with privilege of test.t1 for information_schema.analyze_status
327327
tk.MustExec("create table t1 (a int, b int, index idx(a))")
328328
tk.MustExec("insert into t1 values (1,2),(3,4)")
329-
tk.MustExec("analyze table t1")
329+
tk.MustExec("analyze table t1 all columns")
330330
tk.MustQuery("show warnings").Check(testkit.Rows("Note 1105 Analyze use auto adjusted sample rate 1.000000 for table test.t1, reason to use this rate is \"use min(1, 110000/10000) as the sample-rate=1\"")) // 1 note.
331331
require.NoError(t, dom.StatsHandle().LoadNeededHistograms())
332332
tk.MustExec("CREATE ROLE r_t1 ;")

pkg/executor/set_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -682,11 +682,11 @@ func TestSetVar(t *testing.T) {
682682
require.Error(t, tk.ExecToErr("set global tidb_enable_column_tracking = -1"))
683683

684684
// test for tidb_analyze_column_options
685-
tk.MustQuery("select @@tidb_analyze_column_options").Check(testkit.Rows("ALL"))
686-
tk.MustExec("set global tidb_analyze_column_options = 'PREDICATE'")
687685
tk.MustQuery("select @@tidb_analyze_column_options").Check(testkit.Rows("PREDICATE"))
688-
tk.MustExec("set global tidb_analyze_column_options = 'all'")
686+
tk.MustExec("set global tidb_analyze_column_options = 'ALL'")
689687
tk.MustQuery("select @@tidb_analyze_column_options").Check(testkit.Rows("ALL"))
688+
tk.MustExec("set global tidb_analyze_column_options = 'predicate'")
689+
tk.MustQuery("select @@tidb_analyze_column_options").Check(testkit.Rows("PREDICATE"))
690690
require.Error(t, tk.ExecToErr("set global tidb_analyze_column_options = 'UNKNOWN'"))
691691

692692
// test for tidb_ignore_prepared_cache_close_stmt

pkg/executor/show_stats_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestShowStatsMeta(t *testing.T) {
3636
tk.MustExec("drop table if exists t, t1")
3737
tk.MustExec("create table t (a int, b int)")
3838
tk.MustExec("create table t1 (a int, b int)")
39-
tk.MustExec("analyze table t, t1")
39+
tk.MustExec("analyze table t, t1 all columns")
4040
result := tk.MustQuery("show stats_meta")
4141
result = result.Sort()
4242
require.Len(t, result.Rows(), 2)
@@ -78,11 +78,11 @@ func TestShowStatsHistograms(t *testing.T) {
7878
tk.MustExec("use test")
7979
tk.MustExec("drop table if exists t")
8080
tk.MustExec("create table t (a int, b int)")
81-
tk.MustExec("analyze table t")
81+
tk.MustExec("analyze table t all columns")
8282
result := tk.MustQuery("show stats_histograms")
8383
require.Len(t, result.Rows(), 2)
8484
tk.MustExec("insert into t values(1,1)")
85-
tk.MustExec("analyze table t")
85+
tk.MustExec("analyze table t all columns")
8686
result = tk.MustQuery("show stats_histograms").Sort()
8787
require.Len(t, result.Rows(), 2)
8888
require.Equal(t, "a", result.Rows()[0][3])

pkg/executor/test/analyzetest/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ go_test(
2828
"//pkg/statistics",
2929
"//pkg/statistics/handle/autoanalyze/exec",
3030
"//pkg/testkit",
31+
"//pkg/testkit/analyzehelper",
3132
"//pkg/util/dbterror/exeerrors",
3233
"@com_github_pingcap_errors//:errors",
3334
"@com_github_pingcap_failpoint//:failpoint",

pkg/executor/test/analyzetest/analyze_bench_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ func BenchmarkAnalyzePartition(b *testing.B) {
4949
tk.MustExec(insertStr)
5050
b.ResetTimer()
5151
for i := 0; i < b.N; i++ {
52-
tk.MustExec("analyze table t")
52+
tk.MustExec("analyze table t all columns")
5353
}
5454
}

pkg/executor/test/analyzetest/analyze_test.go

+23-8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/pingcap/tidb/pkg/statistics"
4242
"github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/exec"
4343
"github.com/pingcap/tidb/pkg/testkit"
44+
"github.com/pingcap/tidb/pkg/testkit/analyzehelper"
4445
"github.com/pingcap/tidb/pkg/util/dbterror/exeerrors"
4546
"github.com/stretchr/testify/require"
4647
)
@@ -63,6 +64,7 @@ PARTITION BY RANGE ( a ) (
6364
for i := 1; i < 21; i++ {
6465
tk.MustExec(fmt.Sprintf(`insert into t values (%d, %d, "hello")`, i, i))
6566
}
67+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "c")
6668
tk.MustExec("analyze table t")
6769

6870
is := tk.Session().(sessionctx.Context).GetInfoSchema().(infoschema.InfoSchema)
@@ -205,6 +207,7 @@ func TestAnalyzeTooLongColumns(t *testing.T) {
205207
tk.MustExec(fmt.Sprintf("insert into t values ('%s')", value))
206208

207209
tk.MustExec("set @@session.tidb_analyze_skip_column_types = ''")
210+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "a")
208211
tk.MustExec("analyze table t")
209212
is := tk.Session().(sessionctx.Context).GetInfoSchema().(infoschema.InfoSchema)
210213
table, err := is.TableByName(context.Background(), model.NewCIStr("test"), model.NewCIStr("t"))
@@ -505,14 +508,20 @@ func TestAdjustSampleRateNote(t *testing.T) {
505508
result := tk.MustQuery("show stats_meta where table_name = 't'")
506509
require.Equal(t, "220000", result.Rows()[0][5])
507510
tk.MustExec("analyze table t")
508-
tk.MustQuery("show warnings").Check(testkit.Rows("Note 1105 Analyze use auto adjusted sample rate 0.500000 for table test.t, reason to use this rate is \"use min(1, 110000/220000) as the sample-rate=0.5\""))
511+
tk.MustQuery("show warnings").Check(testkit.Rows(
512+
"Warning 1105 No predicate column has been collected yet for table test.t, so only indexes and the columns composing the indexes will be analyzed",
513+
"Note 1105 Analyze use auto adjusted sample rate 0.500000 for table test.t, reason to use this rate is \"use min(1, 110000/220000) as the sample-rate=0.5\"",
514+
))
509515
tk.MustExec("insert into t values(1),(1),(1)")
510516
require.NoError(t, statsHandle.DumpStatsDeltaToKV(true))
511517
require.NoError(t, statsHandle.Update(is))
512518
result = tk.MustQuery("show stats_meta where table_name = 't'")
513519
require.Equal(t, "3", result.Rows()[0][5])
514520
tk.MustExec("analyze table t")
515-
tk.MustQuery("show warnings").Check(testkit.Rows("Note 1105 Analyze use auto adjusted sample rate 1.000000 for table test.t, reason to use this rate is \"use min(1, 110000/3) as the sample-rate=1\""))
521+
tk.MustQuery("show warnings").Check(testkit.Rows(
522+
"Warning 1105 No predicate column has been collected yet for table test.t, so only indexes and the columns composing the indexes will be analyzed",
523+
"Note 1105 Analyze use auto adjusted sample rate 1.000000 for table test.t, reason to use this rate is \"use min(1, 110000/3) as the sample-rate=1\"",
524+
))
516525
}
517526

518527
func TestAnalyzeIndex(t *testing.T) {
@@ -620,7 +629,7 @@ func TestAnalyzeSamplingWorkPanic(t *testing.T) {
620629
tk := testkit.NewTestKit(t, store)
621630
tk.MustExec("use test")
622631
tk.MustExec("set @@session.tidb_analyze_version = 2")
623-
tk.MustExec("create table t(a int)")
632+
tk.MustExec("create table t(a int, index idx(a))")
624633
tk.MustExec("insert into t values(1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12)")
625634
tk.MustExec("split table t between (-9223372036854775808) and (9223372036854775807) regions 12")
626635

@@ -644,6 +653,7 @@ func TestSmallTableAnalyzeV2(t *testing.T) {
644653
tk.MustExec("use test")
645654
tk.MustExec("set @@session.tidb_analyze_version = 2")
646655
tk.MustExec("create table small_table_inject_pd(a int)")
656+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "small_table_inject_pd", "a")
647657
tk.MustExec("insert into small_table_inject_pd values(1), (2), (3), (4), (5)")
648658
tk.MustExec("analyze table small_table_inject_pd")
649659
tk.MustQuery("show warnings").Check(testkit.Rows("Note 1105 Analyze use auto adjusted sample rate 1.000000 for table test.small_table_inject_pd, reason to use this rate is \"use min(1, 110000/10000) as the sample-rate=1\""))
@@ -656,6 +666,7 @@ create table small_table_inject_pd_with_partition(
656666
partition p2 values less than (15)
657667
)`)
658668
tk.MustExec("insert into small_table_inject_pd_with_partition values(1), (6), (11)")
669+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "small_table_inject_pd_with_partition", "a")
659670
tk.MustExec("analyze table small_table_inject_pd_with_partition")
660671
tk.MustQuery("show warnings").Check(testkit.Rows(
661672
"Note 1105 Analyze use auto adjusted sample rate 1.000000 for table test.small_table_inject_pd_with_partition's partition p0, reason to use this rate is \"use min(1, 110000/10000) as the sample-rate=1\"",
@@ -703,6 +714,7 @@ func TestSavedAnalyzeOptions(t *testing.T) {
703714
tk.MustExec("set @@session.tidb_stats_load_sync_wait = 20000") // to stabilise test
704715
tk.MustExec("create table t(a int, b int, c int, primary key(a), key idx(b))")
705716
tk.MustExec("insert into t values (1,1,1),(2,1,2),(3,1,3),(4,1,4),(5,1,5),(6,1,6),(7,7,7),(8,8,8),(9,9,9)")
717+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "c")
706718

707719
h := dom.StatsHandle()
708720
oriLease := h.Lease()
@@ -1726,7 +1738,7 @@ func TestAnalyzeColumnsAfterAnalyzeAll(t *testing.T) {
17261738
require.NoError(t, err)
17271739
tblID := tbl.Meta().ID
17281740

1729-
tk.MustExec("analyze table t with 2 topn, 2 buckets")
1741+
tk.MustExec("analyze table t all columns with 2 topn, 2 buckets")
17301742
tk.MustQuery(fmt.Sprintf("select modify_count, count from mysql.stats_meta where table_id = %d", tblID)).Sort().Check(
17311743
testkit.Rows("0 6"))
17321744
tk.MustQuery("show stats_topn where db_name = 'test' and table_name = 't'").Sort().Check(
@@ -1750,10 +1762,6 @@ func TestAnalyzeColumnsAfterAnalyzeAll(t *testing.T) {
17501762
case model.ColumnList:
17511763
tk.MustExec("analyze table t columns b with 2 topn, 2 buckets")
17521764
case model.PredicateColumns:
1753-
originalVal := tk.MustQuery("select @@tidb_enable_column_tracking").Rows()[0][0].(string)
1754-
defer func() {
1755-
tk.MustExec(fmt.Sprintf("set global tidb_enable_column_tracking = %v", originalVal))
1756-
}()
17571765
tk.MustExec("select * from t where b > 1")
17581766
require.NoError(t, h.DumpColStatsUsageToKV())
17591767
rows := tk.MustQuery("show column_stats_usage where db_name = 'test' and table_name = 't' and last_used_at is not null").Rows()
@@ -1792,6 +1800,7 @@ func TestAnalyzeSampleRateReason(t *testing.T) {
17921800
tk.MustExec("drop table if exists t")
17931801
tk.MustExec("create table t (a int, b int)")
17941802
require.NoError(t, dom.StatsHandle().DumpStatsDeltaToKV(true))
1803+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "a", "b")
17951804

17961805
tk.MustExec(`analyze table t`)
17971806
tk.MustQuery(`show warnings`).Sort().Check(testkit.Rows(
@@ -1890,6 +1899,7 @@ func testKillAutoAnalyze(t *testing.T, ver int) {
18901899
tk.MustExec("drop table if exists t")
18911900
tk.MustExec("create table t (a int, b int)")
18921901
tk.MustExec("insert into t values (1,2), (3,4)")
1902+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "a", "b")
18931903
is := dom.InfoSchema()
18941904
h := dom.StatsHandle()
18951905
require.NoError(t, h.DumpStatsDeltaToKV(true))
@@ -1973,6 +1983,7 @@ func TestKillAutoAnalyzeIndex(t *testing.T) {
19731983
tk.MustExec("drop table if exists t")
19741984
tk.MustExec("create table t (a int, b int)")
19751985
tk.MustExec("insert into t values (1,2), (3,4)")
1986+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "a", "b")
19761987
is := dom.InfoSchema()
19771988
h := dom.StatsHandle()
19781989
require.NoError(t, h.DumpStatsDeltaToKV(true))
@@ -2420,6 +2431,7 @@ PARTITION BY RANGE ( a ) (
24202431
tk.MustExec(createTable)
24212432
tk.MustExec("insert into t values (1,1,1,1),(2,1,2,2),(3,1,3,3),(4,1,4,4),(5,1,5,5),(6,1,6,6),(7,7,7,7),(8,8,8,8),(9,9,9,9)")
24222433
tk.MustExec("insert into t values (10,10,10,10),(11,11,11,11),(12,12,12,12),(13,13,13,13),(14,14,14,14)")
2434+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "a", "b", "c", "d")
24232435
h := dom.StatsHandle()
24242436
oriLease := h.Lease()
24252437
h.SetLease(1)
@@ -2476,6 +2488,7 @@ PARTITION BY RANGE ( a ) (
24762488
tk.MustExec(createTable)
24772489
tk.MustExec("insert into t values (1,1,1,1),(2,1,2,2),(3,1,3,3),(4,1,4,4),(5,1,5,5),(6,1,6,6),(7,7,7,7),(8,8,8,8),(9,9,9,9)")
24782490
tk.MustExec("insert into t values (10,10,10,10),(11,11,11,11),(12,12,12,12),(13,13,13,13),(14,14,14,14)")
2491+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "a", "b", "c", "d")
24792492
h := dom.StatsHandle()
24802493
oriLease := h.Lease()
24812494
h.SetLease(1)
@@ -2705,6 +2718,7 @@ func TestAutoAnalyzeAwareGlobalVariableChange(t *testing.T) {
27052718
tk.MustExec("set @@global.tidb_enable_analyze_snapshot = 1")
27062719
tk.MustExec("set @@global.tidb_analyze_version = 2")
27072720
tk.MustExec("create table t(a int)")
2721+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "a")
27082722
h := dom.StatsHandle()
27092723
require.NoError(t, h.HandleDDLEvent(<-h.DDLEventCh()))
27102724
tbl, err := dom.InfoSchema().TableByName(context.Background(), model.NewCIStr("test"), model.NewCIStr("t"))
@@ -3094,6 +3108,7 @@ func TestAnalyzePartitionVerify(t *testing.T) {
30943108
}
30953109
insertStr += ";"
30963110
tk.MustExec(insertStr)
3111+
analyzehelper.TriggerPredicateColumnsCollection(t, tk, store, "t", "a", "b", "c")
30973112
tk.MustExec("analyze table t")
30983113

30993114
result := tk.MustQuery("show stats_histograms where Db_name='test'").Sort()

0 commit comments

Comments
 (0)