Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/statistics/handle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ go_test(
embed = [":handle"],
flaky = True,
race = "on",
shard_count = 10,
shard_count = 11,
deps = [
"//pkg/config",
"//pkg/parser/model",
Expand Down
15 changes: 15 additions & 0 deletions pkg/statistics/handle/handle_hist.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/stmtctx"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/statistics"
"github.com/pingcap/tidb/pkg/statistics/handle/storage"
utilstats "github.com/pingcap/tidb/pkg/statistics/handle/util"
Expand Down Expand Up @@ -285,6 +286,13 @@ func (h *Handle) handleOneItemTask(task *NeededItemTask) (err error) {
h.SPool().Put(se)
}
}()
var skipTypes map[string]struct{}
val, err := sctx.GetSessionVars().GlobalVarsAccessor.GetGlobalSysVar(variable.TiDBAnalyzeSkipColumnTypes)
if err != nil {
logutil.BgLogger().Warn("failed to get global variable", zap.Error(err))
} else {
skipTypes = variable.ParseAnalyzeSkipColumnTypes(val)
}

item := task.TableItemID
tbl, ok := h.Get(item.TableID)
Expand All @@ -305,7 +313,14 @@ func (h *Handle) handleOneItemTask(task *NeededItemTask) (err error) {
} else {
wrapper.col = col
}
if skipTypes != nil && wrapper.col != nil && wrapper.col.Info != nil {
_, skip := skipTypes[types.TypeToStr(wrapper.col.Info.FieldType.GetType(), wrapper.col.Info.FieldType.GetCharset())]
if skip {
return nil
}
}
}
failpoint.Inject("handleOneItemTaskPanic", nil)
t := time.Now()
needUpdate := false
wrapper, err = h.readStatsForOneItem(sctx, item, wrapper)
Expand Down
16 changes: 16 additions & 0 deletions pkg/statistics/handle/handle_hist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ func TestSyncLoadSkipUnAnalyzedItems(t *testing.T) {
failpoint.Disable("github.com/pingcap/tidb/pkg/statistics/handle/assertSyncLoadItems")
}

func TestSyncLoadSkipAnalyzSkipColumnItems(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(`id` bigint(20) NOT NULL AUTO_INCREMENT,content text,PRIMARY KEY (`id`))")
h := dom.StatsHandle()
h.SetLease(1)

tk.MustExec("analyze table t")
tk.MustExec("set @@session.tidb_analyze_skip_column_types = 'json, text, blob'") // text is not default.
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/statistics/handle/syncload/handleOneItemTaskPanic", `panic`))
tk.MustQuery("trace plan select * from t where content ='ab'")
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/statistics/handle/syncload/handleOneItemTaskPanic"))
}

func TestConcurrentLoadHist(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)

Expand Down