Skip to content

Commit

Permalink
planner: temporarily disable analyze mv index for the release | tidb-…
Browse files Browse the repository at this point in the history
…test=pr/2223 (#47529)

ref #46539
  • Loading branch information
time-and-fate authored Oct 12, 2023
1 parent 656b96b commit 8dbfdfb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 5 additions & 7 deletions executor/test/analyzetest/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2859,12 +2859,9 @@ func TestAnalyzeColumnsSkipMVIndexJsonCol(t *testing.T) {
tk.MustQuery("show warnings").Sort().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/10000) as the sample-rate=1\"",
"Warning 1105 Columns b are missing in ANALYZE but their stats are needed for calculating stats for indexes/primary key/extended stats",
))
tk.MustQuery("select job_info from mysql.analyze_jobs where table_schema = 'test' and table_name = 't'").Sort().Check(
testkit.Rows(
"analyze index idx_c",
"analyze table columns a, b with 256 buckets, 500 topn, 1 samplerate",
))
"Warning 1105 analyzing multi-valued indexes is not supported, skip idx_c"))
tk.MustQuery("select job_info from mysql.analyze_jobs where table_schema = 'test' and table_name = 't'").Check(testkit.Rows(
"analyze table columns a, b with 256 buckets, 500 topn, 1 samplerate"))

is := dom.InfoSchema()
tbl, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("t"))
Expand All @@ -2875,7 +2872,7 @@ func TestAnalyzeColumnsSkipMVIndexJsonCol(t *testing.T) {
require.True(t, stats.Columns[tblInfo.Columns[1].ID].IsStatsInitialized())
require.False(t, stats.Columns[tblInfo.Columns[2].ID].IsStatsInitialized())
require.True(t, stats.Indices[tblInfo.Indices[0].ID].IsStatsInitialized())
require.True(t, stats.Indices[tblInfo.Indices[1].ID].IsStatsInitialized())
require.False(t, stats.Indices[tblInfo.Indices[1].ID].IsStatsInitialized())
}

func TestManualAnalyzeSkipColumnTypes(t *testing.T) {
Expand All @@ -2894,6 +2891,7 @@ func TestManualAnalyzeSkipColumnTypes(t *testing.T) {
// TestAnalyzeMVIndex tests analyzing the mv index use some real data in the table.
// It checks the analyze jobs, async loading and the stats content in the memory.
func TestAnalyzeMVIndex(t *testing.T) {
t.Skip()
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/executor/DebugAnalyzeJobOperations", "return(true)"))
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/statistics/handle/DebugAnalyzeJobOperations", "return(true)"))
defer func() {
Expand Down
6 changes: 3 additions & 3 deletions planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2440,15 +2440,15 @@ func getColOffsetForAnalyze(colsInfo []*model.ColumnInfo, colID int64) int {
// TODO: find a better way to find indexed columns in ANALYZE rather than use IndexColumn.Offset
// For multi-valued index, we need to collect it separately here and analyze it as independent index analyze task.
// See comments for AnalyzeResults.ForMVIndex for more details.
func getModifiedIndexesInfoForAnalyze(tblInfo *model.TableInfo, allColumns bool, colsInfo []*model.ColumnInfo) ([]*model.IndexInfo, []*model.IndexInfo) {
func getModifiedIndexesInfoForAnalyze(sctx sessionctx.Context, tblInfo *model.TableInfo, allColumns bool, colsInfo []*model.ColumnInfo) ([]*model.IndexInfo, []*model.IndexInfo) {
idxsInfo := make([]*model.IndexInfo, 0, len(tblInfo.Indices))
independentIdxsInfo := make([]*model.IndexInfo, 0)
for _, originIdx := range tblInfo.Indices {
if originIdx.State != model.StatePublic {
continue
}
if originIdx.MVIndex {
independentIdxsInfo = append(independentIdxsInfo, originIdx)
sctx.GetSessionVars().StmtCtx.AppendWarning(errors.Errorf("analyzing multi-valued indexes is not supported, skip %s", originIdx.Name.L))
continue
}
if allColumns {
Expand Down Expand Up @@ -2567,7 +2567,7 @@ func (b *PlanBuilder) buildAnalyzeFullSamplingTask(
}
execColsInfo = b.filterSkipColumnTypes(execColsInfo, tbl, &mustAnalyzedCols)
allColumns := len(tbl.TableInfo.Columns) == len(execColsInfo)
indexes, independentIndexes := getModifiedIndexesInfoForAnalyze(tbl.TableInfo, allColumns, execColsInfo)
indexes, independentIndexes := getModifiedIndexesInfoForAnalyze(b.ctx, tbl.TableInfo, allColumns, execColsInfo)
handleCols := BuildHandleColsForAnalyze(b.ctx, tbl.TableInfo, allColumns, execColsInfo)
newTask := AnalyzeColumnsTask{
HandleCols: handleCols,
Expand Down
4 changes: 4 additions & 0 deletions tests/integrationtest/r/planner/core/indexmerge_path.result
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ set tidb_analyze_version=2;
analyze table t;
Level Code Message
Note 1105 Analyze use auto adjusted sample rate 1.000000 for table planner__core__indexmerge_path.t, reason to use this rate is "use min(1, 110000/10000) as the sample-rate=1"
Warning 1105 analyzing multi-valued indexes is not supported, skip idx
Warning 1105 analyzing multi-valued indexes is not supported, skip idx2
analyze table t index idx;
Level Code Message
Note 1105 Analyze use auto adjusted sample rate 1.000000 for table planner__core__indexmerge_path.t, reason to use this rate is "TiDB assumes that the table is empty, use sample-rate=1"
Warning 1105 The version 2 would collect all statistics not only the selected indexes
Warning 1105 analyzing multi-valued indexes is not supported, skip idx
Warning 1105 analyzing multi-valued indexes is not supported, skip idx2
set tidb_analyze_version=1;
analyze table t;
Level Code Message
Expand Down

0 comments on commit 8dbfdfb

Please sign in to comment.