diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 357c07294e487..73c313540b4ac 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -1,6 +1,6 @@ --- name: "\U0001F41B Bug Report" -about: Something isn't working as expected +about: As a User, I want to report a Bug. labels: type/bug --- @@ -8,17 +8,12 @@ labels: type/bug Please answer these questions before submitting your issue. Thanks! -1. What did you do? - +### 1. What did you do? + -2. What did you expect to see? +### 2. What did you expect to see? +### 3. What did you see instead? - -3. What did you see instead? - - - -4. What version of TiDB are you using (`tidb-server -V` or run `select tidb_version();` on TiDB)? - +### 4. What version of TiDB are you using? (`tidb-server -V` or run `select tidb_version();` on TiDB) diff --git a/.github/ISSUE_TEMPLATE/challenge-program.md b/.github/ISSUE_TEMPLATE/challenge-program.md index e1cb2e58a94db..4995f18a5d5a8 100644 --- a/.github/ISSUE_TEMPLATE/challenge-program.md +++ b/.github/ISSUE_TEMPLATE/challenge-program.md @@ -1,6 +1,6 @@ --- -name: "\U0001F947 Challenge Program" -about: Challenge Program issues +name: "\U0001F947 Propose a Challenge Program task" +about: As a developer, I want to propose a Challenge Program task. labels: challenge-program-2 --- diff --git a/.github/ISSUE_TEMPLATE/development-task.md b/.github/ISSUE_TEMPLATE/development-task.md new file mode 100644 index 0000000000000..4f9547e25a01b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/development-task.md @@ -0,0 +1,7 @@ +--- +name: "\U0001F680 Development Task" +about: As a TiDB developer, I want to record a development task. +labels: type/enhancement +--- + +## Development Task diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md index 47fca73625d64..62b5a45b48968 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.md +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -1,7 +1,7 @@ --- name: "\U0001F680 Feature Request" -about: I have a suggestion -labels: type/enhancement +about: As a user, I want to request a New Feature on the product. +labels: type/feature-request --- ## Feature Request @@ -16,4 +16,4 @@ labels: type/enhancement **Teachability, Documentation, Adoption, Migration Strategy:** - \ No newline at end of file + diff --git a/.github/ISSUE_TEMPLATE/general-question.md b/.github/ISSUE_TEMPLATE/general-question.md index 87d424d51779a..02534c6f6e2bd 100644 --- a/.github/ISSUE_TEMPLATE/general-question.md +++ b/.github/ISSUE_TEMPLATE/general-question.md @@ -1,11 +1,13 @@ --- -name: "\U0001F914 General Question" -about: Usage question that isn't answered in docs or discussion -labels: question +name: "\U0001F914 Ask a Question" +about: I want to ask a question. +labels: type/question --- ## General Question + diff --git a/.github/ISSUE_TEMPLATE/performance-questions.md b/.github/ISSUE_TEMPLATE/performance-questions.md index 9eb5551161544..e4d853087542c 100644 --- a/.github/ISSUE_TEMPLATE/performance-questions.md +++ b/.github/ISSUE_TEMPLATE/performance-questions.md @@ -1,7 +1,7 @@ --- -name: "\U0001F947 Performance Questions" -about: Performance question about TiDB which is not caused by bug. -labels: question, type/performance +name: "\U0001F947 Ask a Database Performance Question" +about: I want to ask a database performance question. +labels: type/question, type/performance --- ## Performance Questions diff --git a/.github/workflows/assign_project.yml b/.github/workflows/assign_project.yml index 14607d15e953a..c1d2477b06211 100644 --- a/.github/workflows/assign_project.yml +++ b/.github/workflows/assign_project.yml @@ -27,3 +27,32 @@ jobs: with: project: 'https://github.com/pingcap/tidb/projects/39' column_name: 'Issue Backlog: Need Triage' + - name: Run issues assignment to Question and Bug Reports Kanban + uses: srggrs/assign-one-project-github-action@1.2.0 + if: | + contains(github.event.issue.labels.*.name, 'type/question') || + contains(github.event.issue.labels.*.name, 'type/bug') + with: + project: 'https://github.com/pingcap/tidb/projects/36' + column_name: 'Need Triage' + - name: Run issues assignment to Feature Request Kanban + uses: srggrs/assign-one-project-github-action@1.2.0 + if: | + contains(github.event.issue.labels.*.name, 'type/feature-request') + with: + project: 'https://github.com/pingcap/tidb/projects/41' + column_name: 'Need Triage' + - name: Run issues assignment to Robust test + uses: srggrs/assign-one-project-github-action@1.2.0 + if: | + contains(github.event.issue.labels.*.name, 'component/test') + with: + project: 'https://github.com/pingcap/tidb/projects/32' + column_name: 'TODO/Help Wanted' + - name: Run issues assignment to project UT Coverage + uses: srggrs/assign-one-project-github-action@1.2.0 + if: | + contains(github.event.issue.labels.*.name, 'type/UT-coverage') + with: + project: 'https://github.com/pingcap/tidb/projects/44' + column_name: 'To do' diff --git a/bindinfo/bind.go b/bindinfo/bind.go index 8b4fb7df75c30..4eda780818a9f 100644 --- a/bindinfo/bind.go +++ b/bindinfo/bind.go @@ -13,7 +13,10 @@ package bindinfo -import "github.com/pingcap/parser/ast" +import ( + "github.com/pingcap/parser" + "github.com/pingcap/parser/ast" +) // HintsSet contains all hints of a query. type HintsSet struct { @@ -82,3 +85,12 @@ func BindHint(stmt ast.StmtNode, hintsSet *HintsSet) ast.StmtNode { stmt.Accept(&hp) return stmt } + +// ParseHintsSet parses a SQL string and collect HintsSet. +func ParseHintsSet(p *parser.Parser, sql, charset, collation string) (*HintsSet, error) { + stmtNode, err := p.ParseOneStmt(sql, charset, collation) + if err != nil { + return nil, err + } + return CollectHint(stmtNode), nil +} diff --git a/bindinfo/bind_test.go b/bindinfo/bind_test.go index de0988abf9ab0..26a8175692333 100644 --- a/bindinfo/bind_test.go +++ b/bindinfo/bind_test.go @@ -334,7 +334,7 @@ func (s *testSuite) TestGlobalAndSessionBindingBothExist(c *C) { tk.MustExec("drop table if exists t2") tk.MustExec("create table t1(id int)") tk.MustExec("create table t2(id int)") - c.Assert(tk.HasPlan("SELECT * from t1,t2 where t1.id = t2.id", "HashLeftJoin"), IsTrue) + c.Assert(tk.HasPlan("SELECT * from t1,t2 where t1.id = t2.id", "HashJoin"), IsTrue) c.Assert(tk.HasPlan("SELECT /*+ TIDB_SMJ(t1, t2) */ * from t1,t2 where t1.id = t2.id", "MergeJoin"), IsTrue) tk.MustExec("create global binding for SELECT * from t1,t2 where t1.id = t2.id using SELECT /*+ TIDB_SMJ(t1, t2) */ * from t1,t2 where t1.id = t2.id") @@ -345,11 +345,11 @@ func (s *testSuite) TestGlobalAndSessionBindingBothExist(c *C) { metrics.BindUsageCounter.WithLabelValues(metrics.ScopeGlobal).Write(pb) c.Assert(pb.GetCounter().GetValue(), Equals, float64(1)) tk.MustExec("set @@tidb_use_plan_baselines = 0") - c.Assert(tk.HasPlan("SELECT * from t1,t2 where t1.id = t2.id", "HashLeftJoin"), IsTrue) + c.Assert(tk.HasPlan("SELECT * from t1,t2 where t1.id = t2.id", "HashJoin"), IsTrue) tk.MustExec("drop global binding for SELECT * from t1,t2 where t1.id = t2.id") tk.MustExec("set @@tidb_use_plan_baselines = 1") - c.Assert(tk.HasPlan("SELECT * from t1,t2 where t1.id = t2.id", "HashLeftJoin"), IsTrue) + c.Assert(tk.HasPlan("SELECT * from t1,t2 where t1.id = t2.id", "HashJoin"), IsTrue) } func (s *testSuite) TestExplain(c *C) { @@ -361,7 +361,7 @@ func (s *testSuite) TestExplain(c *C) { tk.MustExec("create table t1(id int)") tk.MustExec("create table t2(id int)") - c.Assert(tk.HasPlan("SELECT * from t1,t2 where t1.id = t2.id", "HashLeftJoin"), IsTrue) + c.Assert(tk.HasPlan("SELECT * from t1,t2 where t1.id = t2.id", "HashJoin"), IsTrue) c.Assert(tk.HasPlan("SELECT /*+ TIDB_SMJ(t1, t2) */ * from t1,t2 where t1.id = t2.id", "MergeJoin"), IsTrue) tk.MustExec("create global binding for SELECT * from t1,t2 where t1.id = t2.id using SELECT /*+ TIDB_SMJ(t1, t2) */ * from t1,t2 where t1.id = t2.id") @@ -383,14 +383,14 @@ func (s *testSuite) TestBindingSymbolList(c *C) { // before binding tk.MustQuery("select a, b from t where a = 3 limit 1, 100") c.Assert(tk.Se.GetSessionVars().StmtCtx.IndexNames[0], Equals, "t:ia") - c.Assert(tk.MustUseIndex("select a, b from t where a = 3 limit 1, 100", "a"), IsTrue) + c.Assert(tk.MustUseIndex("select a, b from t where a = 3 limit 1, 100", "ia(a)"), IsTrue) tk.MustExec(`create global binding for select a, b from t where a = 1 limit 0, 1 using select a, b from t use index (ib) where a = 1 limit 0, 1`) // after binding tk.MustQuery("select a, b from t where a = 3 limit 1, 100") c.Assert(tk.Se.GetSessionVars().StmtCtx.IndexNames[0], Equals, "t:ib") - c.Assert(tk.MustUseIndex("select a, b from t where a = 3 limit 1, 100", "b"), IsTrue) + c.Assert(tk.MustUseIndex("select a, b from t where a = 3 limit 1, 100", "ib(b)"), IsTrue) // Normalize sql, hash := parser.NormalizeDigest("select a, b from t where a = 1 limit 0, 1") @@ -707,3 +707,26 @@ func (s *testSuite) TestPrivileges(c *C) { rows = tk.MustQuery("show global bindings").Rows() c.Assert(len(rows), Equals, 0) } + +func (s *testSuite) TestHintsSetEvolveTask(c *C) { + tk := testkit.NewTestKit(c, s.store) + s.cleanBindingEnv(tk) + tk.MustExec("use test") + tk.MustExec("drop table if exists t") + tk.MustExec("create table t(a int, index idx_a(a))") + tk.MustExec("create global binding for select * from t where a > 10 using select * from t ignore index(idx_a) where a > 10") + tk.MustExec("set @@tidb_evolve_plan_baselines=1") + tk.MustQuery("select * from t use index(idx_a) where a > 0") + bindHandle := s.domain.BindHandle() + bindHandle.SaveEvolveTasksToStore() + // Verify the added Binding for evolution contains valid ID and Hint, otherwise, panic may happen. + sql, hash := parser.NormalizeDigest("select * from t where a > ?") + bindData := bindHandle.GetBindRecord(hash, sql, "test") + c.Check(bindData, NotNil) + c.Check(bindData.OriginalSQL, Equals, "select * from t where a > ?") + c.Assert(len(bindData.Bindings), Equals, 2) + bind := bindData.Bindings[1] + c.Assert(bind.Status, Equals, bindinfo.PendingVerify) + c.Assert(bind.ID, Not(Equals), "") + c.Assert(bind.Hint, NotNil) +} diff --git a/bindinfo/cache.go b/bindinfo/cache.go index 5487135969f8c..878caecc49d28 100644 --- a/bindinfo/cache.go +++ b/bindinfo/cache.go @@ -50,16 +50,16 @@ type Binding struct { Collation string // Hint is the parsed hints, it is used to bind hints to stmt node. Hint *HintsSet - // id is the string form of all hints. It is used to uniquely identify different hints. + // ID is the string form of all hints. It is used to uniquely identify different hints. // It would be non-empty only when the status is `Using` or `PendingVerify`. - id string + ID string } func (b *Binding) isSame(rb *Binding) bool { - if b.id != "" && rb.id != "" { - return b.id == rb.id + if b.ID != "" && rb.ID != "" { + return b.ID == rb.ID } - // Sometimes we cannot construct `id` because of the changed schema, so we need to compare by bind sql. + // Sometimes we cannot construct `ID` because of the changed schema, so we need to compare by bind sql. return b.BindSQL == rb.BindSQL } @@ -96,7 +96,7 @@ func (br *BindRecord) HasUsingBinding() bool { // FindBinding find bindings in BindRecord. func (br *BindRecord) FindBinding(hint string) *Binding { for _, binding := range br.Bindings { - if binding.id == hint { + if binding.ID == hint { return &binding } } @@ -106,10 +106,10 @@ func (br *BindRecord) FindBinding(hint string) *Binding { func (br *BindRecord) prepareHints(sctx sessionctx.Context) error { p := parser.New() for i, bind := range br.Bindings { - if bind.Hint != nil || bind.id != "" || bind.Status == deleted { + if (bind.Hint != nil && bind.ID != "") || bind.Status == deleted { continue } - stmtNode, err := p.ParseOneStmt(bind.BindSQL, bind.Charset, bind.Collation) + hintsSet, err := ParseHintsSet(p, bind.BindSQL, bind.Charset, bind.Collation) if err != nil { return err } @@ -117,8 +117,8 @@ func (br *BindRecord) prepareHints(sctx sessionctx.Context) error { if err != nil { return err } - br.Bindings[i].Hint = CollectHint(stmtNode) - br.Bindings[i].id = hints + br.Bindings[i].Hint = hintsSet + br.Bindings[i].ID = hints } return nil } diff --git a/bindinfo/handle.go b/bindinfo/handle.go index 5b3ad758a1e5f..86cb1f282cdb4 100644 --- a/bindinfo/handle.go +++ b/bindinfo/handle.go @@ -178,7 +178,7 @@ func (h *BindHandle) AddBindRecord(sctx sessionctx.Context, record *BindRecord) br := h.GetBindRecord(parser.DigestNormalized(record.OriginalSQL), record.OriginalSQL, record.Db) var duplicateBinding *Binding if br != nil { - binding := br.FindBinding(record.Bindings[0].id) + binding := br.FindBinding(record.Bindings[0].ID) if binding != nil { // There is already a binding with status `Using`, `PendingVerify` or `Rejected`, we could directly cancel the job. if record.Bindings[0].Status == PendingVerify { @@ -191,7 +191,7 @@ func (h *BindHandle) AddBindRecord(sctx sessionctx.Context, record *BindRecord) exec, _ := h.sctx.Context.(sqlexec.SQLExecutor) h.sctx.Lock() - _, err = exec.Execute(context.TODO(), "BEGIN") + _, err = exec.ExecuteInternal(context.TODO(), "BEGIN") if err != nil { h.sctx.Unlock() return @@ -199,13 +199,13 @@ func (h *BindHandle) AddBindRecord(sctx sessionctx.Context, record *BindRecord) defer func() { if err != nil { - _, err1 := exec.Execute(context.TODO(), "ROLLBACK") + _, err1 := exec.ExecuteInternal(context.TODO(), "ROLLBACK") h.sctx.Unlock() terror.Log(err1) return } - _, err = exec.Execute(context.TODO(), "COMMIT") + _, err = exec.ExecuteInternal(context.TODO(), "COMMIT") h.sctx.Unlock() if err != nil { return @@ -224,7 +224,7 @@ func (h *BindHandle) AddBindRecord(sctx sessionctx.Context, record *BindRecord) } if duplicateBinding != nil { - _, err = exec.Execute(context.TODO(), h.deleteBindInfoSQL(record.OriginalSQL, record.Db, duplicateBinding.BindSQL)) + _, err = exec.ExecuteInternal(context.TODO(), h.deleteBindInfoSQL(record.OriginalSQL, record.Db, duplicateBinding.BindSQL)) if err != nil { return err } @@ -240,7 +240,7 @@ func (h *BindHandle) AddBindRecord(sctx sessionctx.Context, record *BindRecord) record.Bindings[i].UpdateTime = now // insert the BindRecord to the storage. - _, err = exec.Execute(context.TODO(), h.insertBindInfoSQL(record.OriginalSQL, record.Db, record.Bindings[i])) + _, err = exec.ExecuteInternal(context.TODO(), h.insertBindInfoSQL(record.OriginalSQL, record.Db, record.Bindings[i])) if err != nil { return err } @@ -253,7 +253,7 @@ func (h *BindHandle) DropBindRecord(originalSQL, db string, binding *Binding) (e h.sctx.Lock() exec, _ := h.sctx.Context.(sqlexec.SQLExecutor) - _, err = exec.Execute(context.TODO(), "BEGIN") + _, err = exec.ExecuteInternal(context.TODO(), "BEGIN") if err != nil { h.sctx.Unlock() return @@ -261,13 +261,13 @@ func (h *BindHandle) DropBindRecord(originalSQL, db string, binding *Binding) (e defer func() { if err != nil { - _, err1 := exec.Execute(context.TODO(), "ROLLBACK") + _, err1 := exec.ExecuteInternal(context.TODO(), "ROLLBACK") h.sctx.Unlock() terror.Log(err1) return } - _, err = exec.Execute(context.TODO(), "COMMIT") + _, err = exec.ExecuteInternal(context.TODO(), "COMMIT") h.sctx.Unlock() if err != nil { return @@ -292,7 +292,7 @@ func (h *BindHandle) DropBindRecord(originalSQL, db string, binding *Binding) (e bindSQL = binding.BindSQL } - _, err = exec.Execute(context.TODO(), h.logicalDeleteBindInfoSQL(originalSQL, db, updateTs, bindSQL)) + _, err = exec.ExecuteInternal(context.TODO(), h.logicalDeleteBindInfoSQL(originalSQL, db, updateTs, bindSQL)) return err } @@ -325,7 +325,7 @@ func (tmpMap *tmpBindRecordMap) flushToStore() { } func (tmpMap *tmpBindRecordMap) saveToCache(bindRecord *BindRecord) { - key := bindRecord.OriginalSQL + ":" + bindRecord.Db + ":" + bindRecord.Bindings[0].id + key := bindRecord.OriginalSQL + ":" + bindRecord.Db + ":" + bindRecord.Bindings[0].ID if _, ok := tmpMap.Load().(map[string]*bindRecordUpdate)[key]; ok { return } @@ -545,11 +545,16 @@ func (h *BindHandle) CaptureBaselines() { continue } charset, collation := h.sctx.GetSessionVars().GetCharsetInfo() + hintsSet, err := ParseHintsSet(parser4Capture, bindSQL, charset, collation) + if err != nil { + logutil.BgLogger().Debug("parse BindSQL failed", zap.String("SQL", bindSQL), zap.Error(err)) + continue + } binding := Binding{ BindSQL: bindSQL, Status: Using, - Hint: CollectHint(stmt), - id: hints, + Hint: hintsSet, + ID: hints, Charset: charset, Collation: collation, } @@ -564,7 +569,7 @@ func (h *BindHandle) CaptureBaselines() { func getHintsForSQL(sctx sessionctx.Context, sql string) (string, error) { oriVals := sctx.GetSessionVars().UsePlanBaselines sctx.GetSessionVars().UsePlanBaselines = false - recordSets, err := sctx.(sqlexec.SQLExecutor).Execute(context.TODO(), fmt.Sprintf("explain format='hint' %s", sql)) + recordSets, err := sctx.(sqlexec.SQLExecutor).ExecuteInternal(context.TODO(), fmt.Sprintf("explain format='hint' %s", sql)) sctx.GetSessionVars().UsePlanBaselines = oriVals if len(recordSets) > 0 { defer terror.Log(recordSets[0].Close()) @@ -626,8 +631,7 @@ func (e *paramMarkerChecker) Leave(in ast.Node) (ast.Node, bool) { } // AddEvolvePlanTask adds the evolve plan task into memory cache. It would be flushed to store periodically. -func (h *BindHandle) AddEvolvePlanTask(originalSQL, DB string, binding Binding, planHint string) { - binding.id = planHint +func (h *BindHandle) AddEvolvePlanTask(originalSQL, DB string, binding Binding) { br := &BindRecord{ OriginalSQL: originalSQL, Db: DB, @@ -711,7 +715,7 @@ func (h *BindHandle) getOnePendingVerifyJob() (string, string, Binding) { func (h *BindHandle) getRunningDuration(sctx sessionctx.Context, db, sql string, maxTime time.Duration) (time.Duration, error) { ctx := context.TODO() if db != "" { - _, err := sctx.(sqlexec.SQLExecutor).Execute(ctx, fmt.Sprintf("use `%s`", db)) + _, err := sctx.(sqlexec.SQLExecutor).ExecuteInternal(ctx, fmt.Sprintf("use `%s`", db)) if err != nil { return 0, err } @@ -744,7 +748,7 @@ func runSQL(ctx context.Context, sctx sessionctx.Context, sql string, resultChan resultChan <- fmt.Errorf("run sql panicked: %v", string(buf)) } }() - recordSets, err := sctx.(sqlexec.SQLExecutor).Execute(ctx, sql) + recordSets, err := sctx.(sqlexec.SQLExecutor).ExecuteInternal(ctx, sql) if err != nil { if len(recordSets) > 0 { terror.Call(recordSets[0].Close) diff --git a/bindinfo/session_handle.go b/bindinfo/session_handle.go index 11ae9b27fe3ee..f690063edbd23 100644 --- a/bindinfo/session_handle.go +++ b/bindinfo/session_handle.go @@ -55,7 +55,7 @@ func (h *SessionHandle) AddBindRecord(sctx sessionctx.Context, record *BindRecor br := h.GetBindRecord(record.OriginalSQL, record.Db) var duplicateBinding *Binding if br != nil { - binding := br.FindBinding(record.Bindings[0].id) + binding := br.FindBinding(record.Bindings[0].ID) if binding != nil { duplicateBinding = binding } diff --git a/cmd/explaintest/config.toml b/cmd/explaintest/config.toml index 87d7e937dabc1..680422494f85b 100644 --- a/cmd/explaintest/config.toml +++ b/cmd/explaintest/config.toml @@ -7,3 +7,6 @@ status-port = 10081 [performance] stats-lease = "0" + +[experimental] +allow-expression-index = true diff --git a/cmd/explaintest/r/access_path_selection.result b/cmd/explaintest/r/access_path_selection.result index 95404db94f2c9..5b569d0a8e528 100644 --- a/cmd/explaintest/r/access_path_selection.result +++ b/cmd/explaintest/r/access_path_selection.result @@ -6,39 +6,39 @@ KEY `IDX_b` (`b`), KEY `IDX_ab` (`a`, `b`) ); explain select a from access_path_selection where a < 3; -id estRows task operator info -IndexReader_6 3323.33 root index:IndexRangeScan_5 -└─IndexRangeScan_5 3323.33 cop[tikv] table:access_path_selection, index:a, range:[-inf,3), keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 3323.33 root index:IndexRangeScan_5 +└─IndexRangeScan_5 3323.33 cop[tikv] table:access_path_selection, index:IDX_a(a) range:[-inf,3), keep order:false, stats:pseudo explain select a, b from access_path_selection where a < 3; -id estRows task operator info -IndexReader_6 3323.33 root index:IndexRangeScan_5 -└─IndexRangeScan_5 3323.33 cop[tikv] table:access_path_selection, index:a, b, range:[-inf,3), keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 3323.33 root index:IndexRangeScan_5 +└─IndexRangeScan_5 3323.33 cop[tikv] table:access_path_selection, index:IDX_ab(a, b) range:[-inf,3), keep order:false, stats:pseudo explain select a, b from access_path_selection where b < 3; -id estRows task operator info -TableReader_7 3323.33 root data:Selection_6 -└─Selection_6 3323.33 cop[tikv] lt(test.access_path_selection.b, 3) - └─TableFullScan_5 10000.00 cop[tikv] table:access_path_selection, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3323.33 root data:Selection_6 +└─Selection_6 3323.33 cop[tikv] lt(test.access_path_selection.b, 3) + └─TableFullScan_5 10000.00 cop[tikv] table:access_path_selection keep order:false, stats:pseudo explain select a, b from access_path_selection where a < 3 and b < 3; -id estRows task operator info -IndexReader_11 1104.45 root index:Selection_10 -└─Selection_10 1104.45 cop[tikv] lt(test.access_path_selection.b, 3) - └─IndexRangeScan_9 3323.33 cop[tikv] table:access_path_selection, index:a, b, range:[-inf,3), keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 1104.45 root index:Selection_10 +└─Selection_10 1104.45 cop[tikv] lt(test.access_path_selection.b, 3) + └─IndexRangeScan_9 3323.33 cop[tikv] table:access_path_selection, index:IDX_ab(a, b) range:[-inf,3), keep order:false, stats:pseudo explain select a, b from access_path_selection where a > 10 order by _tidb_rowid; -id estRows task operator info -Projection_6 3333.33 root test.access_path_selection.a, test.access_path_selection.b -└─TableReader_13 3333.33 root data:Selection_12 - └─Selection_12 3333.33 cop[tikv] gt(test.access_path_selection.a, 10) - └─TableFullScan_11 10000.00 cop[tikv] table:access_path_selection, keep order:true, stats:pseudo +id estRows task access object operator info +Projection_6 3333.33 root test.access_path_selection.a, test.access_path_selection.b +└─TableReader_13 3333.33 root data:Selection_12 + └─Selection_12 3333.33 cop[tikv] gt(test.access_path_selection.a, 10) + └─TableFullScan_11 10000.00 cop[tikv] table:access_path_selection keep order:true, stats:pseudo explain select max(_tidb_rowid) from access_path_selection; -id estRows task operator info -StreamAgg_13 1.00 root funcs:max(test.access_path_selection._tidb_rowid)->Column#4 -└─Limit_17 1.00 root offset:0, count:1 - └─TableReader_27 1.00 root data:Limit_26 - └─Limit_26 1.00 cop[tikv] offset:0, count:1 - └─TableFullScan_25 1.25 cop[tikv] table:access_path_selection, keep order:true, desc, stats:pseudo +id estRows task access object operator info +StreamAgg_13 1.00 root funcs:max(test.access_path_selection._tidb_rowid)->Column#4 +└─Limit_17 1.00 root offset:0, count:1 + └─TableReader_27 1.00 root data:Limit_26 + └─Limit_26 1.00 cop[tikv] offset:0, count:1 + └─TableFullScan_25 1.25 cop[tikv] table:access_path_selection keep order:true, desc, stats:pseudo explain select count(1) from access_path_selection; -id estRows task operator info -StreamAgg_28 1.00 root funcs:count(Column#18)->Column#4 -└─TableReader_29 1.00 root data:StreamAgg_8 - └─StreamAgg_8 1.00 cop[tikv] funcs:count(1)->Column#18 - └─TableFullScan_24 10000.00 cop[tikv] table:access_path_selection, keep order:false, stats:pseudo +id estRows task access object operator info +StreamAgg_28 1.00 root funcs:count(Column#18)->Column#4 +└─TableReader_29 1.00 root data:StreamAgg_8 + └─StreamAgg_8 1.00 cop[tikv] funcs:count(1)->Column#18 + └─TableFullScan_24 10000.00 cop[tikv] table:access_path_selection keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/black_list.result b/cmd/explaintest/r/black_list.result index fd32b1981a56e..9408bc9f44230 100644 --- a/cmd/explaintest/r/black_list.result +++ b/cmd/explaintest/r/black_list.result @@ -2,55 +2,55 @@ use test; drop table if exists t; create table t (a int); explain select * from t where a < 1; -id estRows task operator info -TableReader_7 3323.33 root data:Selection_6 -└─Selection_6 3323.33 cop[tikv] lt(test.t.a, 1) - └─TableFullScan_5 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3323.33 root data:Selection_6 +└─Selection_6 3323.33 cop[tikv] lt(test.t.a, 1) + └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo insert into mysql.opt_rule_blacklist values('predicate_push_down'); admin reload opt_rule_blacklist; explain select * from t where a < 1; -id estRows task operator info -Selection_5 8000.00 root lt(test.t.a, 1) -└─TableReader_7 10000.00 root data:TableFullScan_6 - └─TableFullScan_6 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Selection_5 8000.00 root lt(test.t.a, 1) +└─TableReader_7 10000.00 root data:TableFullScan_6 + └─TableFullScan_6 10000.00 cop[tikv] table:t keep order:false, stats:pseudo delete from mysql.opt_rule_blacklist where name='predicate_push_down'; admin reload opt_rule_blacklist; explain select * from t where a < 1; -id estRows task operator info -TableReader_7 3323.33 root data:Selection_6 -└─Selection_6 3323.33 cop[tikv] lt(test.t.a, 1) - └─TableFullScan_5 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3323.33 root data:Selection_6 +└─Selection_6 3323.33 cop[tikv] lt(test.t.a, 1) + └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo insert into mysql.expr_pushdown_blacklist values('<'); admin reload expr_pushdown_blacklist; explain select * from t where a < 1; -id estRows task operator info -Selection_5 8000.00 root lt(test.t.a, 1) -└─TableReader_7 10000.00 root data:TableFullScan_6 - └─TableFullScan_6 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Selection_5 8000.00 root lt(test.t.a, 1) +└─TableReader_7 10000.00 root data:TableFullScan_6 + └─TableFullScan_6 10000.00 cop[tikv] table:t keep order:false, stats:pseudo delete from mysql.expr_pushdown_blacklist where name='<'; admin reload expr_pushdown_blacklist; explain select * from t where a < 1; -id estRows task operator info -TableReader_7 3323.33 root data:Selection_6 -└─Selection_6 3323.33 cop[tikv] lt(test.t.a, 1) - └─TableFullScan_5 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3323.33 root data:Selection_6 +└─Selection_6 3323.33 cop[tikv] lt(test.t.a, 1) + └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo insert into mysql.expr_pushdown_blacklist values('lt'); admin reload expr_pushdown_blacklist; explain select * from t where a < 1; -id estRows task operator info -Selection_5 8000.00 root lt(test.t.a, 1) -└─TableReader_7 10000.00 root data:TableFullScan_6 - └─TableFullScan_6 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Selection_5 8000.00 root lt(test.t.a, 1) +└─TableReader_7 10000.00 root data:TableFullScan_6 + └─TableFullScan_6 10000.00 cop[tikv] table:t keep order:false, stats:pseudo delete from mysql.expr_pushdown_blacklist where name='lt'; admin reload expr_pushdown_blacklist; explain select * from t where a < 1; -id estRows task operator info -TableReader_7 3323.33 root data:Selection_6 -└─Selection_6 3323.33 cop[tikv] lt(test.t.a, 1) - └─TableFullScan_5 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3323.33 root data:Selection_6 +└─Selection_6 3323.33 cop[tikv] lt(test.t.a, 1) + └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/explain-non-select-stmt.result b/cmd/explaintest/r/explain-non-select-stmt.result index 98b9dd697c76f..51337c7b18aa0 100644 --- a/cmd/explaintest/r/explain-non-select-stmt.result +++ b/cmd/explaintest/r/explain-non-select-stmt.result @@ -2,30 +2,28 @@ use test; drop table if exists t; create table t(a bigint, b bigint); explain insert into t values(1, 1); -id estRows task operator info -Insert_1 N/A root N/A +id estRows task access object operator info +Insert_1 N/A root N/A explain insert into t select * from t; -id estRows task operator info -Insert_1 N/A root N/A -└─TableReader_7 10000.00 root data:TableFullScan_6 - └─TableFullScan_6 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Insert_1 N/A root N/A +└─TableReader_7 10000.00 root data:TableFullScan_6 + └─TableFullScan_6 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain delete from t where a > 100; -id estRows task operator info -Delete_5 N/A root N/A -└─SelectLock_7 3333.33 root for update - └─TableReader_10 3333.33 root data:Selection_9 - └─Selection_9 3333.33 cop[tikv] gt(test.t.a, 100) - └─TableFullScan_8 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Delete_4 N/A root N/A +└─TableReader_8 3333.33 root data:Selection_7 + └─Selection_7 3333.33 cop[tikv] gt(test.t.a, 100) + └─TableFullScan_6 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain update t set b = 100 where a = 200; -id estRows task operator info -Update_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─TableReader_10 10.00 root data:Selection_9 - └─Selection_9 10.00 cop[tikv] eq(test.t.a, 200) - └─TableFullScan_8 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Update_4 N/A root N/A +└─TableReader_8 10.00 root data:Selection_7 + └─Selection_7 10.00 cop[tikv] eq(test.t.a, 200) + └─TableFullScan_6 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain replace into t select a, 100 from t; -id estRows task operator info -Insert_1 N/A root N/A -└─Projection_5 10000.00 root test.t.a, 100->Column#6 - └─TableReader_7 10000.00 root data:TableFullScan_6 - └─TableFullScan_6 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Insert_1 N/A root N/A +└─Projection_5 10000.00 root test.t.a, 100->Column#6 + └─TableReader_7 10000.00 root data:TableFullScan_6 + └─TableFullScan_6 10000.00 cop[tikv] table:t keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/explain.result b/cmd/explaintest/r/explain.result index 9da11bde53000..ed55753b0ac4e 100644 --- a/cmd/explaintest/r/explain.result +++ b/cmd/explaintest/r/explain.result @@ -27,15 +27,15 @@ create table t(id int primary key, a int, b int); set session tidb_hashagg_partial_concurrency = 1; set session tidb_hashagg_final_concurrency = 1; explain select group_concat(a) from t group by id; -id estRows task operator info -StreamAgg_8 8000.00 root group by:Column#6, funcs:group_concat(Column#5, ",")->Column#4 -└─Projection_18 10000.00 root cast(test.t.a, var_string(20))->Column#5, test.t.id - └─TableReader_15 10000.00 root data:TableFullScan_14 - └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:true, stats:pseudo +id estRows task access object operator info +StreamAgg_8 8000.00 root group by:Column#6, funcs:group_concat(Column#5, ",")->Column#4 +└─Projection_18 10000.00 root cast(test.t.a, var_string(20))->Column#5, test.t.id + └─TableReader_15 10000.00 root data:TableFullScan_14 + └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:true, stats:pseudo explain select group_concat(a, b) from t group by id; -id estRows task operator info -StreamAgg_8 8000.00 root group by:Column#7, funcs:group_concat(Column#5, Column#6, ",")->Column#4 -└─Projection_18 10000.00 root cast(test.t.a, var_string(20))->Column#5, cast(test.t.b, var_string(20))->Column#6, test.t.id - └─TableReader_15 10000.00 root data:TableFullScan_14 - └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:true, stats:pseudo +id estRows task access object operator info +StreamAgg_8 8000.00 root group by:Column#7, funcs:group_concat(Column#5, Column#6, ",")->Column#4 +└─Projection_18 10000.00 root cast(test.t.a, var_string(20))->Column#5, cast(test.t.b, var_string(20))->Column#6, test.t.id + └─TableReader_15 10000.00 root data:TableFullScan_14 + └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:true, stats:pseudo drop table t; diff --git a/cmd/explaintest/r/explain_complex.result b/cmd/explaintest/r/explain_complex.result index db4a2e4f40dc5..ce7e60ae1e883 100644 --- a/cmd/explaintest/r/explain_complex.result +++ b/cmd/explaintest/r/explain_complex.result @@ -104,71 +104,71 @@ CREATE TABLE `rr` ( PRIMARY KEY (`aid`,`dic`) ); explain SELECT `ds`, `p1`, `p2`, `p3`, `p4`, `p5`, `p6_md5`, `p7_md5`, count(dic) as install_device FROM `dt` use index (cmi) WHERE (`ds` >= '2016-09-01') AND (`ds` <= '2016-11-03') AND (`cm` IN ('1062', '1086', '1423', '1424', '1425', '1426', '1427', '1428', '1429', '1430', '1431', '1432', '1433', '1434', '1435', '1436', '1437', '1438', '1439', '1440', '1441', '1442', '1443', '1444', '1445', '1446', '1447', '1448', '1449', '1450', '1451', '1452', '1488', '1489', '1490', '1491', '1492', '1493', '1494', '1495', '1496', '1497', '1550', '1551', '1552', '1553', '1554', '1555', '1556', '1557', '1558', '1559', '1597', '1598', '1599', '1600', '1601', '1602', '1603', '1604', '1605', '1606', '1607', '1608', '1609', '1610', '1611', '1612', '1613', '1614', '1615', '1616', '1623', '1624', '1625', '1626', '1627', '1628', '1629', '1630', '1631', '1632', '1709', '1719', '1720', '1843', '2813', '2814', '2815', '2816', '2817', '2818', '2819', '2820', '2821', '2822', '2823', '2824', '2825', '2826', '2827', '2828', '2829', '2830', '2831', '2832', '2833', '2834', '2835', '2836', '2837', '2838', '2839', '2840', '2841', '2842', '2843', '2844', '2845', '2846', '2847', '2848', '2849', '2850', '2851', '2852', '2853', '2854', '2855', '2856', '2857', '2858', '2859', '2860', '2861', '2862', '2863', '2864', '2865', '2866', '2867', '2868', '2869', '2870', '2871', '2872', '3139', '3140', '3141', '3142', '3143', '3144', '3145', '3146', '3147', '3148', '3149', '3150', '3151', '3152', '3153', '3154', '3155', '3156', '3157', '3158', '3386', '3387', '3388', '3389', '3390', '3391', '3392', '3393', '3394', '3395', '3664', '3665', '3666', '3667', '3668', '3670', '3671', '3672', '3673', '3674', '3676', '3677', '3678', '3679', '3680', '3681', '3682', '3683', '3684', '3685', '3686', '3687', '3688', '3689', '3690', '3691', '3692', '3693', '3694', '3695', '3696', '3697', '3698', '3699', '3700', '3701', '3702', '3703', '3704', '3705', '3706', '3707', '3708', '3709', '3710', '3711', '3712', '3713', '3714', '3715', '3960', '3961', '3962', '3963', '3964', '3965', '3966', '3967', '3968', '3978', '3979', '3980', '3981', '3982', '3983', '3984', '3985', '3986', '3987', '4208', '4209', '4210', '4211', '4212', '4304', '4305', '4306', '4307', '4308', '4866', '4867', '4868', '4869', '4870', '4871', '4872', '4873', '4874', '4875')) GROUP BY `ds`, `p1`, `p2`, `p3`, `p4`, `p5`, `p6_md5`, `p7_md5` ORDER BY `ds2` DESC; -id estRows task operator info -Projection_7 53.00 root test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, Column#21 -└─Sort_8 53.00 root test.dt.ds2:desc - └─HashAgg_16 53.00 root group by:test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, funcs:count(Column#32)->Column#21, funcs:firstrow(test.dt.ds)->test.dt.ds, funcs:firstrow(Column#34)->test.dt.ds2, funcs:firstrow(test.dt.p1)->test.dt.p1, funcs:firstrow(test.dt.p2)->test.dt.p2, funcs:firstrow(test.dt.p3)->test.dt.p3, funcs:firstrow(test.dt.p4)->test.dt.p4, funcs:firstrow(test.dt.p5)->test.dt.p5, funcs:firstrow(test.dt.p6_md5)->test.dt.p6_md5, funcs:firstrow(test.dt.p7_md5)->test.dt.p7_md5 - └─IndexLookUp_17 53.00 root - ├─IndexRangeScan_13(Build) 2650.00 cop[tikv] table:dt, index:cm, range:[1062,1062], [1086,1086], [1423,1423], [1424,1424], [1425,1425], [1426,1426], [1427,1427], [1428,1428], [1429,1429], [1430,1430], [1431,1431], [1432,1432], [1433,1433], [1434,1434], [1435,1435], [1436,1436], [1437,1437], [1438,1438], [1439,1439], [1440,1440], [1441,1441], [1442,1442], [1443,1443], [1444,1444], [1445,1445], [1446,1446], [1447,1447], [1448,1448], [1449,1449], [1450,1450], [1451,1451], [1452,1452], [1488,1488], [1489,1489], [1490,1490], [1491,1491], [1492,1492], [1493,1493], [1494,1494], [1495,1495], [1496,1496], [1497,1497], [1550,1550], [1551,1551], [1552,1552], [1553,1553], [1554,1554], [1555,1555], [1556,1556], [1557,1557], [1558,1558], [1559,1559], [1597,1597], [1598,1598], [1599,1599], [1600,1600], [1601,1601], [1602,1602], [1603,1603], [1604,1604], [1605,1605], [1606,1606], [1607,1607], [1608,1608], [1609,1609], [1610,1610], [1611,1611], [1612,1612], [1613,1613], [1614,1614], [1615,1615], [1616,1616], [1623,1623], [1624,1624], [1625,1625], [1626,1626], [1627,1627], [1628,1628], [1629,1629], [1630,1630], [1631,1631], [1632,1632], [1709,1709], [1719,1719], [1720,1720], [1843,1843], [2813,2813], [2814,2814], [2815,2815], [2816,2816], [2817,2817], [2818,2818], [2819,2819], [2820,2820], [2821,2821], [2822,2822], [2823,2823], [2824,2824], [2825,2825], [2826,2826], [2827,2827], [2828,2828], [2829,2829], [2830,2830], [2831,2831], [2832,2832], [2833,2833], [2834,2834], [2835,2835], [2836,2836], [2837,2837], [2838,2838], [2839,2839], [2840,2840], [2841,2841], [2842,2842], [2843,2843], [2844,2844], [2845,2845], [2846,2846], [2847,2847], [2848,2848], [2849,2849], [2850,2850], [2851,2851], [2852,2852], [2853,2853], [2854,2854], [2855,2855], [2856,2856], [2857,2857], [2858,2858], [2859,2859], [2860,2860], [2861,2861], [2862,2862], [2863,2863], [2864,2864], [2865,2865], [2866,2866], [2867,2867], [2868,2868], [2869,2869], [2870,2870], [2871,2871], [2872,2872], [3139,3139], [3140,3140], [3141,3141], [3142,3142], [3143,3143], [3144,3144], [3145,3145], [3146,3146], [3147,3147], [3148,3148], [3149,3149], [3150,3150], [3151,3151], [3152,3152], [3153,3153], [3154,3154], [3155,3155], [3156,3156], [3157,3157], [3158,3158], [3386,3386], [3387,3387], [3388,3388], [3389,3389], [3390,3390], [3391,3391], [3392,3392], [3393,3393], [3394,3394], [3395,3395], [3664,3664], [3665,3665], [3666,3666], [3667,3667], [3668,3668], [3670,3670], [3671,3671], [3672,3672], [3673,3673], [3674,3674], [3676,3676], [3677,3677], [3678,3678], [3679,3679], [3680,3680], [3681,3681], [3682,3682], [3683,3683], [3684,3684], [3685,3685], [3686,3686], [3687,3687], [3688,3688], [3689,3689], [3690,3690], [3691,3691], [3692,3692], [3693,3693], [3694,3694], [3695,3695], [3696,3696], [3697,3697], [3698,3698], [3699,3699], [3700,3700], [3701,3701], [3702,3702], [3703,3703], [3704,3704], [3705,3705], [3706,3706], [3707,3707], [3708,3708], [3709,3709], [3710,3710], [3711,3711], [3712,3712], [3713,3713], [3714,3714], [3715,3715], [3960,3960], [3961,3961], [3962,3962], [3963,3963], [3964,3964], [3965,3965], [3966,3966], [3967,3967], [3968,3968], [3978,3978], [3979,3979], [3980,3980], [3981,3981], [3982,3982], [3983,3983], [3984,3984], [3985,3985], [3986,3986], [3987,3987], [4208,4208], [4209,4209], [4210,4210], [4211,4211], [4212,4212], [4304,4304], [4305,4305], [4306,4306], [4307,4307], [4308,4308], [4866,4866], [4867,4867], [4868,4868], [4869,4869], [4870,4870], [4871,4871], [4872,4872], [4873,4873], [4874,4874], [4875,4875], keep order:false, stats:pseudo - └─HashAgg_11(Probe) 53.00 cop[tikv] group by:test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, funcs:count(test.dt.dic)->Column#32, funcs:firstrow(test.dt.ds2)->Column#34 - └─Selection_15 66.25 cop[tikv] ge(test.dt.ds, 2016-09-01 00:00:00.000000), le(test.dt.ds, 2016-11-03 00:00:00.000000) - └─TableRowIDScan_14 2650.00 cop[tikv] table:dt, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 53.00 root test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, Column#21 +└─Sort_8 53.00 root test.dt.ds2:desc + └─HashAgg_16 53.00 root group by:test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, funcs:count(Column#32)->Column#21, funcs:firstrow(test.dt.ds)->test.dt.ds, funcs:firstrow(Column#34)->test.dt.ds2, funcs:firstrow(test.dt.p1)->test.dt.p1, funcs:firstrow(test.dt.p2)->test.dt.p2, funcs:firstrow(test.dt.p3)->test.dt.p3, funcs:firstrow(test.dt.p4)->test.dt.p4, funcs:firstrow(test.dt.p5)->test.dt.p5, funcs:firstrow(test.dt.p6_md5)->test.dt.p6_md5, funcs:firstrow(test.dt.p7_md5)->test.dt.p7_md5 + └─IndexLookUp_17 53.00 root + ├─IndexRangeScan_13(Build) 2650.00 cop[tikv] table:dt, index:cmi(cm) range:[1062,1062], [1086,1086], [1423,1423], [1424,1424], [1425,1425], [1426,1426], [1427,1427], [1428,1428], [1429,1429], [1430,1430], [1431,1431], [1432,1432], [1433,1433], [1434,1434], [1435,1435], [1436,1436], [1437,1437], [1438,1438], [1439,1439], [1440,1440], [1441,1441], [1442,1442], [1443,1443], [1444,1444], [1445,1445], [1446,1446], [1447,1447], [1448,1448], [1449,1449], [1450,1450], [1451,1451], [1452,1452], [1488,1488], [1489,1489], [1490,1490], [1491,1491], [1492,1492], [1493,1493], [1494,1494], [1495,1495], [1496,1496], [1497,1497], [1550,1550], [1551,1551], [1552,1552], [1553,1553], [1554,1554], [1555,1555], [1556,1556], [1557,1557], [1558,1558], [1559,1559], [1597,1597], [1598,1598], [1599,1599], [1600,1600], [1601,1601], [1602,1602], [1603,1603], [1604,1604], [1605,1605], [1606,1606], [1607,1607], [1608,1608], [1609,1609], [1610,1610], [1611,1611], [1612,1612], [1613,1613], [1614,1614], [1615,1615], [1616,1616], [1623,1623], [1624,1624], [1625,1625], [1626,1626], [1627,1627], [1628,1628], [1629,1629], [1630,1630], [1631,1631], [1632,1632], [1709,1709], [1719,1719], [1720,1720], [1843,1843], [2813,2813], [2814,2814], [2815,2815], [2816,2816], [2817,2817], [2818,2818], [2819,2819], [2820,2820], [2821,2821], [2822,2822], [2823,2823], [2824,2824], [2825,2825], [2826,2826], [2827,2827], [2828,2828], [2829,2829], [2830,2830], [2831,2831], [2832,2832], [2833,2833], [2834,2834], [2835,2835], [2836,2836], [2837,2837], [2838,2838], [2839,2839], [2840,2840], [2841,2841], [2842,2842], [2843,2843], [2844,2844], [2845,2845], [2846,2846], [2847,2847], [2848,2848], [2849,2849], [2850,2850], [2851,2851], [2852,2852], [2853,2853], [2854,2854], [2855,2855], [2856,2856], [2857,2857], [2858,2858], [2859,2859], [2860,2860], [2861,2861], [2862,2862], [2863,2863], [2864,2864], [2865,2865], [2866,2866], [2867,2867], [2868,2868], [2869,2869], [2870,2870], [2871,2871], [2872,2872], [3139,3139], [3140,3140], [3141,3141], [3142,3142], [3143,3143], [3144,3144], [3145,3145], [3146,3146], [3147,3147], [3148,3148], [3149,3149], [3150,3150], [3151,3151], [3152,3152], [3153,3153], [3154,3154], [3155,3155], [3156,3156], [3157,3157], [3158,3158], [3386,3386], [3387,3387], [3388,3388], [3389,3389], [3390,3390], [3391,3391], [3392,3392], [3393,3393], [3394,3394], [3395,3395], [3664,3664], [3665,3665], [3666,3666], [3667,3667], [3668,3668], [3670,3670], [3671,3671], [3672,3672], [3673,3673], [3674,3674], [3676,3676], [3677,3677], [3678,3678], [3679,3679], [3680,3680], [3681,3681], [3682,3682], [3683,3683], [3684,3684], [3685,3685], [3686,3686], [3687,3687], [3688,3688], [3689,3689], [3690,3690], [3691,3691], [3692,3692], [3693,3693], [3694,3694], [3695,3695], [3696,3696], [3697,3697], [3698,3698], [3699,3699], [3700,3700], [3701,3701], [3702,3702], [3703,3703], [3704,3704], [3705,3705], [3706,3706], [3707,3707], [3708,3708], [3709,3709], [3710,3710], [3711,3711], [3712,3712], [3713,3713], [3714,3714], [3715,3715], [3960,3960], [3961,3961], [3962,3962], [3963,3963], [3964,3964], [3965,3965], [3966,3966], [3967,3967], [3968,3968], [3978,3978], [3979,3979], [3980,3980], [3981,3981], [3982,3982], [3983,3983], [3984,3984], [3985,3985], [3986,3986], [3987,3987], [4208,4208], [4209,4209], [4210,4210], [4211,4211], [4212,4212], [4304,4304], [4305,4305], [4306,4306], [4307,4307], [4308,4308], [4866,4866], [4867,4867], [4868,4868], [4869,4869], [4870,4870], [4871,4871], [4872,4872], [4873,4873], [4874,4874], [4875,4875], keep order:false, stats:pseudo + └─HashAgg_11(Probe) 53.00 cop[tikv] group by:test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, funcs:count(test.dt.dic)->Column#32, funcs:firstrow(test.dt.ds2)->Column#34 + └─Selection_15 66.25 cop[tikv] ge(test.dt.ds, 2016-09-01 00:00:00.000000), le(test.dt.ds, 2016-11-03 00:00:00.000000) + └─TableRowIDScan_14 2650.00 cop[tikv] table:dt keep order:false, stats:pseudo explain select gad.id as gid,sdk.id as sid,gad.aid as aid,gad.cm as cm,sdk.dic as dic,sdk.ip as ip, sdk.t as t, gad.p1 as p1, gad.p2 as p2, gad.p3 as p3, gad.p4 as p4, gad.p5 as p5, gad.p6_md5 as p6, gad.p7_md5 as p7, gad.ext as ext, gad.t as gtime from st gad join (select id, aid, pt, dic, ip, t from dd where pt = 'android' and bm = 0 and t > 1478143908) sdk on gad.aid = sdk.aid and gad.ip = sdk.ip and sdk.t > gad.t where gad.t > 1478143908 and gad.pt = 'android' group by gad.aid, sdk.dic limit 2500; -id estRows task operator info -Projection_13 1.00 root test.st.id, test.dd.id, test.st.aid, test.st.cm, test.dd.dic, test.dd.ip, test.dd.t, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, test.st.ext, test.st.t -└─Limit_16 1.00 root offset:0, count:2500 - └─HashAgg_19 1.00 root group by:test.dd.dic, test.st.aid, funcs:firstrow(test.st.id)->test.st.id, funcs:firstrow(test.st.aid)->test.st.aid, funcs:firstrow(test.st.cm)->test.st.cm, funcs:firstrow(test.st.p1)->test.st.p1, funcs:firstrow(test.st.p2)->test.st.p2, funcs:firstrow(test.st.p3)->test.st.p3, funcs:firstrow(test.st.p4)->test.st.p4, funcs:firstrow(test.st.p5)->test.st.p5, funcs:firstrow(test.st.p6_md5)->test.st.p6_md5, funcs:firstrow(test.st.p7_md5)->test.st.p7_md5, funcs:firstrow(test.st.ext)->test.st.ext, funcs:firstrow(test.st.t)->test.st.t, funcs:firstrow(test.dd.id)->test.dd.id, funcs:firstrow(test.dd.dic)->test.dd.dic, funcs:firstrow(test.dd.ip)->test.dd.ip, funcs:firstrow(test.dd.t)->test.dd.t - └─HashRightJoin_34 0.00 root inner join, equal:[eq(test.dd.aid, test.st.aid) eq(test.dd.ip, test.st.ip)], other cond:gt(test.dd.t, test.st.t) - ├─IndexLookUp_52(Build) 0.00 root - │ ├─IndexRangeScan_49(Build) 3333.33 cop[tikv] table:dd, index:t, range:(1478143908,+inf], keep order:false, stats:pseudo - │ └─Selection_51(Probe) 0.00 cop[tikv] eq(test.dd.bm, 0), eq(test.dd.pt, "android"), not(isnull(test.dd.ip)) - │ └─TableRowIDScan_50 3333.33 cop[tikv] table:dd, keep order:false, stats:pseudo - └─IndexLookUp_41(Probe) 3.33 root - ├─IndexRangeScan_38(Build) 3333.33 cop[tikv] table:gad, index:t, range:(1478143908,+inf], keep order:false, stats:pseudo - └─Selection_40(Probe) 3.33 cop[tikv] eq(test.st.pt, "android"), not(isnull(test.st.ip)) - └─TableRowIDScan_39 3333.33 cop[tikv] table:gad, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_13 1.00 root test.st.id, test.dd.id, test.st.aid, test.st.cm, test.dd.dic, test.dd.ip, test.dd.t, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, test.st.ext, test.st.t +└─Limit_16 1.00 root offset:0, count:2500 + └─HashAgg_19 1.00 root group by:test.dd.dic, test.st.aid, funcs:firstrow(test.st.id)->test.st.id, funcs:firstrow(test.st.aid)->test.st.aid, funcs:firstrow(test.st.cm)->test.st.cm, funcs:firstrow(test.st.p1)->test.st.p1, funcs:firstrow(test.st.p2)->test.st.p2, funcs:firstrow(test.st.p3)->test.st.p3, funcs:firstrow(test.st.p4)->test.st.p4, funcs:firstrow(test.st.p5)->test.st.p5, funcs:firstrow(test.st.p6_md5)->test.st.p6_md5, funcs:firstrow(test.st.p7_md5)->test.st.p7_md5, funcs:firstrow(test.st.ext)->test.st.ext, funcs:firstrow(test.st.t)->test.st.t, funcs:firstrow(test.dd.id)->test.dd.id, funcs:firstrow(test.dd.dic)->test.dd.dic, funcs:firstrow(test.dd.ip)->test.dd.ip, funcs:firstrow(test.dd.t)->test.dd.t + └─HashJoin_34 0.00 root inner join, equal:[eq(test.dd.aid, test.st.aid) eq(test.dd.ip, test.st.ip)], other cond:gt(test.dd.t, test.st.t) + ├─IndexLookUp_52(Build) 0.00 root + │ ├─IndexRangeScan_49(Build) 3333.33 cop[tikv] table:dd, index:t(t) range:(1478143908,+inf], keep order:false, stats:pseudo + │ └─Selection_51(Probe) 0.00 cop[tikv] eq(test.dd.bm, 0), eq(test.dd.pt, "android"), not(isnull(test.dd.ip)) + │ └─TableRowIDScan_50 3333.33 cop[tikv] table:dd keep order:false, stats:pseudo + └─IndexLookUp_41(Probe) 3.33 root + ├─IndexRangeScan_38(Build) 3333.33 cop[tikv] table:gad, index:t(t) range:(1478143908,+inf], keep order:false, stats:pseudo + └─Selection_40(Probe) 3.33 cop[tikv] eq(test.st.pt, "android"), not(isnull(test.st.ip)) + └─TableRowIDScan_39 3333.33 cop[tikv] table:gad keep order:false, stats:pseudo explain select gad.id as gid,sdk.id as sid,gad.aid as aid,gad.cm as cm,sdk.dic as dic,sdk.ip as ip, sdk.t as t, gad.p1 as p1, gad.p2 as p2, gad.p3 as p3, gad.p4 as p4, gad.p5 as p5, gad.p6_md5 as p6, gad.p7_md5 as p7, gad.ext as ext from st gad join dd sdk on gad.aid = sdk.aid and gad.dic = sdk.mac and gad.t < sdk.t where gad.t > 1477971479 and gad.bm = 0 and gad.pt = 'ios' and gad.dit = 'mac' and sdk.t > 1477971479 and sdk.bm = 0 and sdk.pt = 'ios' limit 3000; -id estRows task operator info -Projection_10 0.00 root test.st.id, test.dd.id, test.st.aid, test.st.cm, test.dd.dic, test.dd.ip, test.dd.t, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, test.st.ext -└─Limit_13 0.00 root offset:0, count:3000 - └─IndexMergeJoin_24 0.00 root inner join, inner:IndexLookUp_22, outer key:test.st.aid, inner key:test.dd.aid, other cond:eq(test.st.dic, test.dd.mac), lt(test.st.t, test.dd.t) - ├─IndexLookUp_35(Build) 0.00 root - │ ├─IndexRangeScan_32(Build) 3333.33 cop[tikv] table:gad, index:t, range:(1477971479,+inf], keep order:false, stats:pseudo - │ └─Selection_34(Probe) 0.00 cop[tikv] eq(test.st.bm, 0), eq(test.st.dit, "mac"), eq(test.st.pt, "ios"), not(isnull(test.st.dic)) - │ └─TableRowIDScan_33 3333.33 cop[tikv] table:gad, keep order:false, stats:pseudo - └─IndexLookUp_22(Probe) 0.00 root - ├─IndexRangeScan_19(Build) 10000.00 cop[tikv] table:sdk, index:aid, dic, range: decided by [eq(test.dd.aid, test.st.aid)], keep order:true, stats:pseudo - └─Selection_21(Probe) 0.00 cop[tikv] eq(test.dd.bm, 0), eq(test.dd.pt, "ios"), gt(test.dd.t, 1477971479), not(isnull(test.dd.mac)), not(isnull(test.dd.t)) - └─TableRowIDScan_20 10000.00 cop[tikv] table:sdk, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_10 0.00 root test.st.id, test.dd.id, test.st.aid, test.st.cm, test.dd.dic, test.dd.ip, test.dd.t, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, test.st.ext +└─Limit_13 0.00 root offset:0, count:3000 + └─IndexMergeJoin_24 0.00 root inner join, inner:IndexLookUp_22, outer key:test.st.aid, inner key:test.dd.aid, other cond:eq(test.st.dic, test.dd.mac), lt(test.st.t, test.dd.t) + ├─IndexLookUp_35(Build) 0.00 root + │ ├─IndexRangeScan_32(Build) 3333.33 cop[tikv] table:gad, index:t(t) range:(1477971479,+inf], keep order:false, stats:pseudo + │ └─Selection_34(Probe) 0.00 cop[tikv] eq(test.st.bm, 0), eq(test.st.dit, "mac"), eq(test.st.pt, "ios"), not(isnull(test.st.dic)) + │ └─TableRowIDScan_33 3333.33 cop[tikv] table:gad keep order:false, stats:pseudo + └─IndexLookUp_22(Probe) 0.00 root + ├─IndexRangeScan_19(Build) 10000.00 cop[tikv] table:sdk, index:aid(aid, dic) range: decided by [eq(test.dd.aid, test.st.aid)], keep order:true, stats:pseudo + └─Selection_21(Probe) 0.00 cop[tikv] eq(test.dd.bm, 0), eq(test.dd.pt, "ios"), gt(test.dd.t, 1477971479), not(isnull(test.dd.mac)), not(isnull(test.dd.t)) + └─TableRowIDScan_20 10000.00 cop[tikv] table:sdk keep order:false, stats:pseudo explain SELECT cm, p1, p2, p3, p4, p5, p6_md5, p7_md5, count(1) as click_pv, count(DISTINCT ip) as click_ip FROM st WHERE (t between 1478188800 and 1478275200) and aid='cn.sbkcq' and pt='android' GROUP BY cm, p1, p2, p3, p4, p5, p6_md5, p7_md5; -id estRows task operator info -Projection_5 1.00 root test.st.cm, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, Column#20, Column#21 -└─HashAgg_7 1.00 root group by:test.st.cm, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, funcs:count(1)->Column#20, funcs:count(distinct test.st.ip)->Column#21, funcs:firstrow(test.st.cm)->test.st.cm, funcs:firstrow(test.st.p1)->test.st.p1, funcs:firstrow(test.st.p2)->test.st.p2, funcs:firstrow(test.st.p3)->test.st.p3, funcs:firstrow(test.st.p4)->test.st.p4, funcs:firstrow(test.st.p5)->test.st.p5, funcs:firstrow(test.st.p6_md5)->test.st.p6_md5, funcs:firstrow(test.st.p7_md5)->test.st.p7_md5 - └─IndexLookUp_15 0.00 root - ├─IndexRangeScan_12(Build) 250.00 cop[tikv] table:st, index:t, range:[1478188800,1478275200], keep order:false, stats:pseudo - └─Selection_14(Probe) 0.00 cop[tikv] eq(test.st.aid, "cn.sbkcq"), eq(test.st.pt, "android") - └─TableRowIDScan_13 250.00 cop[tikv] table:st, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_5 1.00 root test.st.cm, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, Column#20, Column#21 +└─HashAgg_7 1.00 root group by:test.st.cm, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, funcs:count(1)->Column#20, funcs:count(distinct test.st.ip)->Column#21, funcs:firstrow(test.st.cm)->test.st.cm, funcs:firstrow(test.st.p1)->test.st.p1, funcs:firstrow(test.st.p2)->test.st.p2, funcs:firstrow(test.st.p3)->test.st.p3, funcs:firstrow(test.st.p4)->test.st.p4, funcs:firstrow(test.st.p5)->test.st.p5, funcs:firstrow(test.st.p6_md5)->test.st.p6_md5, funcs:firstrow(test.st.p7_md5)->test.st.p7_md5 + └─IndexLookUp_15 0.00 root + ├─IndexRangeScan_12(Build) 250.00 cop[tikv] table:st, index:t(t) range:[1478188800,1478275200], keep order:false, stats:pseudo + └─Selection_14(Probe) 0.00 cop[tikv] eq(test.st.aid, "cn.sbkcq"), eq(test.st.pt, "android") + └─TableRowIDScan_13 250.00 cop[tikv] table:st keep order:false, stats:pseudo explain select dt.id as id, dt.aid as aid, dt.pt as pt, dt.dic as dic, dt.cm as cm, rr.gid as gid, rr.acd as acd, rr.t as t,dt.p1 as p1, dt.p2 as p2, dt.p3 as p3, dt.p4 as p4, dt.p5 as p5, dt.p6_md5 as p6, dt.p7_md5 as p7 from dt dt join rr rr on (rr.pt = 'ios' and rr.t > 1478185592 and dt.aid = rr.aid and dt.dic = rr.dic) where dt.pt = 'ios' and dt.t > 1478185592 and dt.bm = 0 limit 2000; -id estRows task operator info -Projection_10 0.00 root test.dt.id, test.dt.aid, test.dt.pt, test.dt.dic, test.dt.cm, test.rr.gid, test.rr.acd, test.rr.t, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5 -└─Limit_13 0.00 root offset:0, count:2000 - └─IndexMergeJoin_41 0.00 root inner join, inner:IndexLookUp_39, outer key:test.rr.aid, test.rr.dic, inner key:test.dt.aid, test.dt.dic - ├─TableReader_61(Build) 3.33 root data:Selection_60 - │ └─Selection_60 3.33 cop[tikv] eq(test.rr.pt, "ios"), gt(test.rr.t, 1478185592) - │ └─TableFullScan_59 10000.00 cop[tikv] table:rr, keep order:false, stats:pseudo - └─IndexLookUp_39(Probe) 0.00 root - ├─Selection_37(Build) 1.00 cop[tikv] not(isnull(test.dt.dic)) - │ └─IndexRangeScan_35 1.00 cop[tikv] table:dt, index:aid, dic, range: decided by [eq(test.dt.aid, test.rr.aid) eq(test.dt.dic, test.rr.dic)], keep order:true, stats:pseudo - └─Selection_38(Probe) 0.00 cop[tikv] eq(test.dt.bm, 0), eq(test.dt.pt, "ios"), gt(test.dt.t, 1478185592) - └─TableRowIDScan_36 1.00 cop[tikv] table:dt, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_10 0.00 root test.dt.id, test.dt.aid, test.dt.pt, test.dt.dic, test.dt.cm, test.rr.gid, test.rr.acd, test.rr.t, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5 +└─Limit_13 0.00 root offset:0, count:2000 + └─IndexMergeJoin_41 0.00 root inner join, inner:IndexLookUp_39, outer key:test.rr.aid, test.rr.dic, inner key:test.dt.aid, test.dt.dic + ├─TableReader_61(Build) 3.33 root data:Selection_60 + │ └─Selection_60 3.33 cop[tikv] eq(test.rr.pt, "ios"), gt(test.rr.t, 1478185592) + │ └─TableFullScan_59 10000.00 cop[tikv] table:rr keep order:false, stats:pseudo + └─IndexLookUp_39(Probe) 0.00 root + ├─Selection_37(Build) 1.00 cop[tikv] not(isnull(test.dt.dic)) + │ └─IndexRangeScan_35 1.00 cop[tikv] table:dt, index:aid(aid, dic) range: decided by [eq(test.dt.aid, test.rr.aid) eq(test.dt.dic, test.rr.dic)], keep order:true, stats:pseudo + └─Selection_38(Probe) 0.00 cop[tikv] eq(test.dt.bm, 0), eq(test.dt.pt, "ios"), gt(test.dt.t, 1478185592) + └─TableRowIDScan_36 1.00 cop[tikv] table:dt keep order:false, stats:pseudo explain select pc,cr,count(DISTINCT uid) as pay_users,count(oid) as pay_times,sum(am) as am from pp where ps=2 and ppt>=1478188800 and ppt<1478275200 and pi in ('510017','520017') and uid in ('18089709','18090780') group by pc,cr; -id estRows task operator info -Projection_5 1.00 root test.pp.pc, test.pp.cr, Column#22, Column#23, Column#24 -└─HashAgg_7 1.00 root group by:test.pp.cr, test.pp.pc, funcs:count(distinct test.pp.uid)->Column#22, funcs:count(test.pp.oid)->Column#23, funcs:sum(test.pp.am)->Column#24, funcs:firstrow(test.pp.pc)->test.pp.pc, funcs:firstrow(test.pp.cr)->test.pp.cr - └─IndexLookUp_21 0.00 root - ├─IndexRangeScan_18(Build) 0.40 cop[tikv] table:pp, index:uid, pi, range:[18089709 510017,18089709 510017], [18089709 520017,18089709 520017], [18090780 510017,18090780 510017], [18090780 520017,18090780 520017], keep order:false, stats:pseudo - └─Selection_20(Probe) 0.00 cop[tikv] eq(test.pp.ps, 2), ge(test.pp.ppt, 1478188800), lt(test.pp.ppt, 1478275200) - └─TableRowIDScan_19 0.40 cop[tikv] table:pp, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_5 1.00 root test.pp.pc, test.pp.cr, Column#22, Column#23, Column#24 +└─HashAgg_7 1.00 root group by:test.pp.cr, test.pp.pc, funcs:count(distinct test.pp.uid)->Column#22, funcs:count(test.pp.oid)->Column#23, funcs:sum(test.pp.am)->Column#24, funcs:firstrow(test.pp.pc)->test.pp.pc, funcs:firstrow(test.pp.cr)->test.pp.cr + └─IndexLookUp_21 0.00 root + ├─IndexRangeScan_18(Build) 0.40 cop[tikv] table:pp, index:sp(uid, pi) range:[18089709 510017,18089709 510017], [18089709 520017,18089709 520017], [18090780 510017,18090780 510017], [18090780 520017,18090780 520017], keep order:false, stats:pseudo + └─Selection_20(Probe) 0.00 cop[tikv] eq(test.pp.ps, 2), ge(test.pp.ppt, 1478188800), lt(test.pp.ppt, 1478275200) + └─TableRowIDScan_19 0.40 cop[tikv] table:pp keep order:false, stats:pseudo CREATE TABLE `tbl_001` (`a` int, `b` int); CREATE TABLE `tbl_002` (`a` int, `b` int); CREATE TABLE `tbl_003` (`a` int, `b` int); @@ -179,28 +179,28 @@ CREATE TABLE `tbl_007` (`a` int, `b` int); CREATE TABLE `tbl_008` (`a` int, `b` int); CREATE TABLE `tbl_009` (`a` int, `b` int); explain select sum(a) from (select * from tbl_001 union all select * from tbl_002 union all select * from tbl_003 union all select * from tbl_004 union all select * from tbl_005 union all select * from tbl_006 union all select * from tbl_007 union all select * from tbl_008 union all select * from tbl_009) x group by b; -id estRows task operator info -HashAgg_34 72000.00 root group by:Column#32, funcs:sum(Column#31)->Column#30 -└─Projection_63 90000.00 root cast(Column#28, decimal(65,0) BINARY)->Column#31, Column#29 - └─Union_35 90000.00 root - ├─TableReader_38 10000.00 root data:TableFullScan_37 - │ └─TableFullScan_37 10000.00 cop[tikv] table:tbl_001, keep order:false, stats:pseudo - ├─TableReader_41 10000.00 root data:TableFullScan_40 - │ └─TableFullScan_40 10000.00 cop[tikv] table:tbl_002, keep order:false, stats:pseudo - ├─TableReader_44 10000.00 root data:TableFullScan_43 - │ └─TableFullScan_43 10000.00 cop[tikv] table:tbl_003, keep order:false, stats:pseudo - ├─TableReader_47 10000.00 root data:TableFullScan_46 - │ └─TableFullScan_46 10000.00 cop[tikv] table:tbl_004, keep order:false, stats:pseudo - ├─TableReader_50 10000.00 root data:TableFullScan_49 - │ └─TableFullScan_49 10000.00 cop[tikv] table:tbl_005, keep order:false, stats:pseudo - ├─TableReader_53 10000.00 root data:TableFullScan_52 - │ └─TableFullScan_52 10000.00 cop[tikv] table:tbl_006, keep order:false, stats:pseudo - ├─TableReader_56 10000.00 root data:TableFullScan_55 - │ └─TableFullScan_55 10000.00 cop[tikv] table:tbl_007, keep order:false, stats:pseudo - ├─TableReader_59 10000.00 root data:TableFullScan_58 - │ └─TableFullScan_58 10000.00 cop[tikv] table:tbl_008, keep order:false, stats:pseudo - └─TableReader_62 10000.00 root data:TableFullScan_61 - └─TableFullScan_61 10000.00 cop[tikv] table:tbl_009, keep order:false, stats:pseudo +id estRows task access object operator info +HashAgg_34 72000.00 root group by:Column#32, funcs:sum(Column#31)->Column#30 +└─Projection_63 90000.00 root cast(Column#28, decimal(65,0) BINARY)->Column#31, Column#29 + └─Union_35 90000.00 root + ├─TableReader_38 10000.00 root data:TableFullScan_37 + │ └─TableFullScan_37 10000.00 cop[tikv] table:tbl_001 keep order:false, stats:pseudo + ├─TableReader_41 10000.00 root data:TableFullScan_40 + │ └─TableFullScan_40 10000.00 cop[tikv] table:tbl_002 keep order:false, stats:pseudo + ├─TableReader_44 10000.00 root data:TableFullScan_43 + │ └─TableFullScan_43 10000.00 cop[tikv] table:tbl_003 keep order:false, stats:pseudo + ├─TableReader_47 10000.00 root data:TableFullScan_46 + │ └─TableFullScan_46 10000.00 cop[tikv] table:tbl_004 keep order:false, stats:pseudo + ├─TableReader_50 10000.00 root data:TableFullScan_49 + │ └─TableFullScan_49 10000.00 cop[tikv] table:tbl_005 keep order:false, stats:pseudo + ├─TableReader_53 10000.00 root data:TableFullScan_52 + │ └─TableFullScan_52 10000.00 cop[tikv] table:tbl_006 keep order:false, stats:pseudo + ├─TableReader_56 10000.00 root data:TableFullScan_55 + │ └─TableFullScan_55 10000.00 cop[tikv] table:tbl_007 keep order:false, stats:pseudo + ├─TableReader_59 10000.00 root data:TableFullScan_58 + │ └─TableFullScan_58 10000.00 cop[tikv] table:tbl_008 keep order:false, stats:pseudo + └─TableReader_62 10000.00 root data:TableFullScan_61 + └─TableFullScan_61 10000.00 cop[tikv] table:tbl_009 keep order:false, stats:pseudo CREATE TABLE org_department ( id int(11) NOT NULL AUTO_INCREMENT, ctx int(11) DEFAULT '0' COMMENT 'organization id', @@ -242,21 +242,21 @@ updated_on datetime DEFAULT NULL, UNIQUE KEY org_employee_position_pk (hotel_id,user_id,position_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; explain SELECT d.id, d.ctx, d.name, d.left_value, d.right_value, d.depth, d.leader_id, d.status, d.created_on, d.updated_on FROM org_department AS d LEFT JOIN org_position AS p ON p.department_id = d.id AND p.status = 1000 LEFT JOIN org_employee_position AS ep ON ep.position_id = p.id AND ep.status = 1000 WHERE (d.ctx = 1 AND (ep.user_id = 62 OR d.id = 20 OR d.id = 20) AND d.status = 1000) GROUP BY d.id ORDER BY d.left_value; -id estRows task operator info -Sort_10 1.00 root test.org_department.left_value:asc -└─HashAgg_15 1.00 root group by:test.org_department.id, funcs:firstrow(test.org_department.id)->test.org_department.id, funcs:firstrow(test.org_department.ctx)->test.org_department.ctx, funcs:firstrow(test.org_department.name)->test.org_department.name, funcs:firstrow(test.org_department.left_value)->test.org_department.left_value, funcs:firstrow(test.org_department.right_value)->test.org_department.right_value, funcs:firstrow(test.org_department.depth)->test.org_department.depth, funcs:firstrow(test.org_department.leader_id)->test.org_department.leader_id, funcs:firstrow(test.org_department.status)->test.org_department.status, funcs:firstrow(test.org_department.created_on)->test.org_department.created_on, funcs:firstrow(test.org_department.updated_on)->test.org_department.updated_on - └─Selection_22 0.01 root or(eq(test.org_employee_position.user_id, 62), or(eq(test.org_department.id, 20), eq(test.org_department.id, 20))) - └─HashLeftJoin_24 0.02 root left outer join, equal:[eq(test.org_position.id, test.org_employee_position.position_id)] - ├─IndexMergeJoin_40(Build) 0.01 root left outer join, inner:IndexLookUp_38, outer key:test.org_department.id, inner key:test.org_position.department_id - │ ├─IndexLookUp_62(Build) 0.01 root - │ │ ├─IndexRangeScan_59(Build) 10.00 cop[tikv] table:d, index:ctx, range:[1,1], keep order:false, stats:pseudo - │ │ └─Selection_61(Probe) 0.01 cop[tikv] eq(test.org_department.status, 1000) - │ │ └─TableRowIDScan_60 10.00 cop[tikv] table:d, keep order:false, stats:pseudo - │ └─IndexLookUp_38(Probe) 1.25 root - │ ├─Selection_36(Build) 1250.00 cop[tikv] not(isnull(test.org_position.department_id)) - │ │ └─IndexRangeScan_34 1251.25 cop[tikv] table:p, index:department_id, range: decided by [eq(test.org_position.department_id, test.org_department.id)], keep order:true, stats:pseudo - │ └─Selection_37(Probe) 1.25 cop[tikv] eq(test.org_position.status, 1000) - │ └─TableRowIDScan_35 1250.00 cop[tikv] table:p, keep order:false, stats:pseudo - └─TableReader_72(Probe) 9.99 root data:Selection_71 - └─Selection_71 9.99 cop[tikv] eq(test.org_employee_position.status, 1000), not(isnull(test.org_employee_position.position_id)) - └─TableFullScan_70 10000.00 cop[tikv] table:ep, keep order:false, stats:pseudo +id estRows task access object operator info +Sort_10 1.00 root test.org_department.left_value:asc +└─HashAgg_15 1.00 root group by:test.org_department.id, funcs:firstrow(test.org_department.id)->test.org_department.id, funcs:firstrow(test.org_department.ctx)->test.org_department.ctx, funcs:firstrow(test.org_department.name)->test.org_department.name, funcs:firstrow(test.org_department.left_value)->test.org_department.left_value, funcs:firstrow(test.org_department.right_value)->test.org_department.right_value, funcs:firstrow(test.org_department.depth)->test.org_department.depth, funcs:firstrow(test.org_department.leader_id)->test.org_department.leader_id, funcs:firstrow(test.org_department.status)->test.org_department.status, funcs:firstrow(test.org_department.created_on)->test.org_department.created_on, funcs:firstrow(test.org_department.updated_on)->test.org_department.updated_on + └─Selection_22 0.01 root or(eq(test.org_employee_position.user_id, 62), or(eq(test.org_department.id, 20), eq(test.org_department.id, 20))) + └─HashJoin_24 0.02 root left outer join, equal:[eq(test.org_position.id, test.org_employee_position.position_id)] + ├─IndexMergeJoin_40(Build) 0.01 root left outer join, inner:IndexLookUp_38, outer key:test.org_department.id, inner key:test.org_position.department_id + │ ├─IndexLookUp_62(Build) 0.01 root + │ │ ├─IndexRangeScan_59(Build) 10.00 cop[tikv] table:d, index:org_department_ctx_index(ctx) range:[1,1], keep order:false, stats:pseudo + │ │ └─Selection_61(Probe) 0.01 cop[tikv] eq(test.org_department.status, 1000) + │ │ └─TableRowIDScan_60 10.00 cop[tikv] table:d keep order:false, stats:pseudo + │ └─IndexLookUp_38(Probe) 1.25 root + │ ├─Selection_36(Build) 1250.00 cop[tikv] not(isnull(test.org_position.department_id)) + │ │ └─IndexRangeScan_34 1251.25 cop[tikv] table:p, index:org_position_department_id_index(department_id) range: decided by [eq(test.org_position.department_id, test.org_department.id)], keep order:true, stats:pseudo + │ └─Selection_37(Probe) 1.25 cop[tikv] eq(test.org_position.status, 1000) + │ └─TableRowIDScan_35 1250.00 cop[tikv] table:p keep order:false, stats:pseudo + └─TableReader_72(Probe) 9.99 root data:Selection_71 + └─Selection_71 9.99 cop[tikv] eq(test.org_employee_position.status, 1000), not(isnull(test.org_employee_position.position_id)) + └─TableFullScan_70 10000.00 cop[tikv] table:ep keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/explain_complex_stats.result b/cmd/explaintest/r/explain_complex_stats.result index 3600f9759b2f3..0574103bd6d59 100644 --- a/cmd/explaintest/r/explain_complex_stats.result +++ b/cmd/explaintest/r/explain_complex_stats.result @@ -114,68 +114,68 @@ PRIMARY KEY (aid,dic) ); load stats 's/explain_complex_stats_rr.json'; explain SELECT ds, p1, p2, p3, p4, p5, p6_md5, p7_md5, count(dic) as install_device FROM dt use index (cm) WHERE (ds >= '2016-09-01') AND (ds <= '2016-11-03') AND (cm IN ('1062', '1086', '1423', '1424', '1425', '1426', '1427', '1428', '1429', '1430', '1431', '1432', '1433', '1434', '1435', '1436', '1437', '1438', '1439', '1440', '1441', '1442', '1443', '1444', '1445', '1446', '1447', '1448', '1449', '1450', '1451', '1452', '1488', '1489', '1490', '1491', '1492', '1493', '1494', '1495', '1496', '1497', '1550', '1551', '1552', '1553', '1554', '1555', '1556', '1557', '1558', '1559', '1597', '1598', '1599', '1600', '1601', '1602', '1603', '1604', '1605', '1606', '1607', '1608', '1609', '1610', '1611', '1612', '1613', '1614', '1615', '1616', '1623', '1624', '1625', '1626', '1627', '1628', '1629', '1630', '1631', '1632', '1709', '1719', '1720', '1843', '2813', '2814', '2815', '2816', '2817', '2818', '2819', '2820', '2821', '2822', '2823', '2824', '2825', '2826', '2827', '2828', '2829', '2830', '2831', '2832', '2833', '2834', '2835', '2836', '2837', '2838', '2839', '2840', '2841', '2842', '2843', '2844', '2845', '2846', '2847', '2848', '2849', '2850', '2851', '2852', '2853', '2854', '2855', '2856', '2857', '2858', '2859', '2860', '2861', '2862', '2863', '2864', '2865', '2866', '2867', '2868', '2869', '2870', '2871', '2872', '3139', '3140', '3141', '3142', '3143', '3144', '3145', '3146', '3147', '3148', '3149', '3150', '3151', '3152', '3153', '3154', '3155', '3156', '3157', '3158', '3386', '3387', '3388', '3389', '3390', '3391', '3392', '3393', '3394', '3395', '3664', '3665', '3666', '3667', '3668', '3670', '3671', '3672', '3673', '3674', '3676', '3677', '3678', '3679', '3680', '3681', '3682', '3683', '3684', '3685', '3686', '3687', '3688', '3689', '3690', '3691', '3692', '3693', '3694', '3695', '3696', '3697', '3698', '3699', '3700', '3701', '3702', '3703', '3704', '3705', '3706', '3707', '3708', '3709', '3710', '3711', '3712', '3713', '3714', '3715', '3960', '3961', '3962', '3963', '3964', '3965', '3966', '3967', '3968', '3978', '3979', '3980', '3981', '3982', '3983', '3984', '3985', '3986', '3987', '4208', '4209', '4210', '4211', '4212', '4304', '4305', '4306', '4307', '4308', '4866', '4867', '4868', '4869', '4870', '4871', '4872', '4873', '4874', '4875')) GROUP BY ds, p1, p2, p3, p4, p5, p6_md5, p7_md5 ORDER BY ds2 DESC; -id estRows task operator info -Projection_7 21.53 root test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, Column#21 -└─Sort_8 21.53 root test.dt.ds2:desc - └─HashAgg_16 21.53 root group by:test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, funcs:count(Column#32)->Column#21, funcs:firstrow(test.dt.ds)->test.dt.ds, funcs:firstrow(Column#34)->test.dt.ds2, funcs:firstrow(test.dt.p1)->test.dt.p1, funcs:firstrow(test.dt.p2)->test.dt.p2, funcs:firstrow(test.dt.p3)->test.dt.p3, funcs:firstrow(test.dt.p4)->test.dt.p4, funcs:firstrow(test.dt.p5)->test.dt.p5, funcs:firstrow(test.dt.p6_md5)->test.dt.p6_md5, funcs:firstrow(test.dt.p7_md5)->test.dt.p7_md5 - └─IndexLookUp_17 21.53 root - ├─IndexRangeScan_13(Build) 128.32 cop[tikv] table:dt, index:cm, range:[1062,1062], [1086,1086], [1423,1423], [1424,1424], [1425,1425], [1426,1426], [1427,1427], [1428,1428], [1429,1429], [1430,1430], [1431,1431], [1432,1432], [1433,1433], [1434,1434], [1435,1435], [1436,1436], [1437,1437], [1438,1438], [1439,1439], [1440,1440], [1441,1441], [1442,1442], [1443,1443], [1444,1444], [1445,1445], [1446,1446], [1447,1447], [1448,1448], [1449,1449], [1450,1450], [1451,1451], [1452,1452], [1488,1488], [1489,1489], [1490,1490], [1491,1491], [1492,1492], [1493,1493], [1494,1494], [1495,1495], [1496,1496], [1497,1497], [1550,1550], [1551,1551], [1552,1552], [1553,1553], [1554,1554], [1555,1555], [1556,1556], [1557,1557], [1558,1558], [1559,1559], [1597,1597], [1598,1598], [1599,1599], [1600,1600], [1601,1601], [1602,1602], [1603,1603], [1604,1604], [1605,1605], [1606,1606], [1607,1607], [1608,1608], [1609,1609], [1610,1610], [1611,1611], [1612,1612], [1613,1613], [1614,1614], [1615,1615], [1616,1616], [1623,1623], [1624,1624], [1625,1625], [1626,1626], [1627,1627], [1628,1628], [1629,1629], [1630,1630], [1631,1631], [1632,1632], [1709,1709], [1719,1719], [1720,1720], [1843,1843], [2813,2813], [2814,2814], [2815,2815], [2816,2816], [2817,2817], [2818,2818], [2819,2819], [2820,2820], [2821,2821], [2822,2822], [2823,2823], [2824,2824], [2825,2825], [2826,2826], [2827,2827], [2828,2828], [2829,2829], [2830,2830], [2831,2831], [2832,2832], [2833,2833], [2834,2834], [2835,2835], [2836,2836], [2837,2837], [2838,2838], [2839,2839], [2840,2840], [2841,2841], [2842,2842], [2843,2843], [2844,2844], [2845,2845], [2846,2846], [2847,2847], [2848,2848], [2849,2849], [2850,2850], [2851,2851], [2852,2852], [2853,2853], [2854,2854], [2855,2855], [2856,2856], [2857,2857], [2858,2858], [2859,2859], [2860,2860], [2861,2861], [2862,2862], [2863,2863], [2864,2864], [2865,2865], [2866,2866], [2867,2867], [2868,2868], [2869,2869], [2870,2870], [2871,2871], [2872,2872], [3139,3139], [3140,3140], [3141,3141], [3142,3142], [3143,3143], [3144,3144], [3145,3145], [3146,3146], [3147,3147], [3148,3148], [3149,3149], [3150,3150], [3151,3151], [3152,3152], [3153,3153], [3154,3154], [3155,3155], [3156,3156], [3157,3157], [3158,3158], [3386,3386], [3387,3387], [3388,3388], [3389,3389], [3390,3390], [3391,3391], [3392,3392], [3393,3393], [3394,3394], [3395,3395], [3664,3664], [3665,3665], [3666,3666], [3667,3667], [3668,3668], [3670,3670], [3671,3671], [3672,3672], [3673,3673], [3674,3674], [3676,3676], [3677,3677], [3678,3678], [3679,3679], [3680,3680], [3681,3681], [3682,3682], [3683,3683], [3684,3684], [3685,3685], [3686,3686], [3687,3687], [3688,3688], [3689,3689], [3690,3690], [3691,3691], [3692,3692], [3693,3693], [3694,3694], [3695,3695], [3696,3696], [3697,3697], [3698,3698], [3699,3699], [3700,3700], [3701,3701], [3702,3702], [3703,3703], [3704,3704], [3705,3705], [3706,3706], [3707,3707], [3708,3708], [3709,3709], [3710,3710], [3711,3711], [3712,3712], [3713,3713], [3714,3714], [3715,3715], [3960,3960], [3961,3961], [3962,3962], [3963,3963], [3964,3964], [3965,3965], [3966,3966], [3967,3967], [3968,3968], [3978,3978], [3979,3979], [3980,3980], [3981,3981], [3982,3982], [3983,3983], [3984,3984], [3985,3985], [3986,3986], [3987,3987], [4208,4208], [4209,4209], [4210,4210], [4211,4211], [4212,4212], [4304,4304], [4305,4305], [4306,4306], [4307,4307], [4308,4308], [4866,4866], [4867,4867], [4868,4868], [4869,4869], [4870,4870], [4871,4871], [4872,4872], [4873,4873], [4874,4874], [4875,4875], keep order:false - └─HashAgg_11(Probe) 21.53 cop[tikv] group by:test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, funcs:count(test.dt.dic)->Column#32, funcs:firstrow(test.dt.ds2)->Column#34 - └─Selection_15 21.56 cop[tikv] ge(test.dt.ds, 2016-09-01 00:00:00.000000), le(test.dt.ds, 2016-11-03 00:00:00.000000) - └─TableRowIDScan_14 128.32 cop[tikv] table:dt, keep order:false +id estRows task access object operator info +Projection_7 21.53 root test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, Column#21 +└─Sort_8 21.53 root test.dt.ds2:desc + └─HashAgg_16 21.53 root group by:test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, funcs:count(Column#32)->Column#21, funcs:firstrow(test.dt.ds)->test.dt.ds, funcs:firstrow(Column#34)->test.dt.ds2, funcs:firstrow(test.dt.p1)->test.dt.p1, funcs:firstrow(test.dt.p2)->test.dt.p2, funcs:firstrow(test.dt.p3)->test.dt.p3, funcs:firstrow(test.dt.p4)->test.dt.p4, funcs:firstrow(test.dt.p5)->test.dt.p5, funcs:firstrow(test.dt.p6_md5)->test.dt.p6_md5, funcs:firstrow(test.dt.p7_md5)->test.dt.p7_md5 + └─IndexLookUp_17 21.53 root + ├─IndexRangeScan_13(Build) 128.32 cop[tikv] table:dt, index:cm(cm) range:[1062,1062], [1086,1086], [1423,1423], [1424,1424], [1425,1425], [1426,1426], [1427,1427], [1428,1428], [1429,1429], [1430,1430], [1431,1431], [1432,1432], [1433,1433], [1434,1434], [1435,1435], [1436,1436], [1437,1437], [1438,1438], [1439,1439], [1440,1440], [1441,1441], [1442,1442], [1443,1443], [1444,1444], [1445,1445], [1446,1446], [1447,1447], [1448,1448], [1449,1449], [1450,1450], [1451,1451], [1452,1452], [1488,1488], [1489,1489], [1490,1490], [1491,1491], [1492,1492], [1493,1493], [1494,1494], [1495,1495], [1496,1496], [1497,1497], [1550,1550], [1551,1551], [1552,1552], [1553,1553], [1554,1554], [1555,1555], [1556,1556], [1557,1557], [1558,1558], [1559,1559], [1597,1597], [1598,1598], [1599,1599], [1600,1600], [1601,1601], [1602,1602], [1603,1603], [1604,1604], [1605,1605], [1606,1606], [1607,1607], [1608,1608], [1609,1609], [1610,1610], [1611,1611], [1612,1612], [1613,1613], [1614,1614], [1615,1615], [1616,1616], [1623,1623], [1624,1624], [1625,1625], [1626,1626], [1627,1627], [1628,1628], [1629,1629], [1630,1630], [1631,1631], [1632,1632], [1709,1709], [1719,1719], [1720,1720], [1843,1843], [2813,2813], [2814,2814], [2815,2815], [2816,2816], [2817,2817], [2818,2818], [2819,2819], [2820,2820], [2821,2821], [2822,2822], [2823,2823], [2824,2824], [2825,2825], [2826,2826], [2827,2827], [2828,2828], [2829,2829], [2830,2830], [2831,2831], [2832,2832], [2833,2833], [2834,2834], [2835,2835], [2836,2836], [2837,2837], [2838,2838], [2839,2839], [2840,2840], [2841,2841], [2842,2842], [2843,2843], [2844,2844], [2845,2845], [2846,2846], [2847,2847], [2848,2848], [2849,2849], [2850,2850], [2851,2851], [2852,2852], [2853,2853], [2854,2854], [2855,2855], [2856,2856], [2857,2857], [2858,2858], [2859,2859], [2860,2860], [2861,2861], [2862,2862], [2863,2863], [2864,2864], [2865,2865], [2866,2866], [2867,2867], [2868,2868], [2869,2869], [2870,2870], [2871,2871], [2872,2872], [3139,3139], [3140,3140], [3141,3141], [3142,3142], [3143,3143], [3144,3144], [3145,3145], [3146,3146], [3147,3147], [3148,3148], [3149,3149], [3150,3150], [3151,3151], [3152,3152], [3153,3153], [3154,3154], [3155,3155], [3156,3156], [3157,3157], [3158,3158], [3386,3386], [3387,3387], [3388,3388], [3389,3389], [3390,3390], [3391,3391], [3392,3392], [3393,3393], [3394,3394], [3395,3395], [3664,3664], [3665,3665], [3666,3666], [3667,3667], [3668,3668], [3670,3670], [3671,3671], [3672,3672], [3673,3673], [3674,3674], [3676,3676], [3677,3677], [3678,3678], [3679,3679], [3680,3680], [3681,3681], [3682,3682], [3683,3683], [3684,3684], [3685,3685], [3686,3686], [3687,3687], [3688,3688], [3689,3689], [3690,3690], [3691,3691], [3692,3692], [3693,3693], [3694,3694], [3695,3695], [3696,3696], [3697,3697], [3698,3698], [3699,3699], [3700,3700], [3701,3701], [3702,3702], [3703,3703], [3704,3704], [3705,3705], [3706,3706], [3707,3707], [3708,3708], [3709,3709], [3710,3710], [3711,3711], [3712,3712], [3713,3713], [3714,3714], [3715,3715], [3960,3960], [3961,3961], [3962,3962], [3963,3963], [3964,3964], [3965,3965], [3966,3966], [3967,3967], [3968,3968], [3978,3978], [3979,3979], [3980,3980], [3981,3981], [3982,3982], [3983,3983], [3984,3984], [3985,3985], [3986,3986], [3987,3987], [4208,4208], [4209,4209], [4210,4210], [4211,4211], [4212,4212], [4304,4304], [4305,4305], [4306,4306], [4307,4307], [4308,4308], [4866,4866], [4867,4867], [4868,4868], [4869,4869], [4870,4870], [4871,4871], [4872,4872], [4873,4873], [4874,4874], [4875,4875], keep order:false + └─HashAgg_11(Probe) 21.53 cop[tikv] group by:test.dt.ds, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5, funcs:count(test.dt.dic)->Column#32, funcs:firstrow(test.dt.ds2)->Column#34 + └─Selection_15 21.56 cop[tikv] ge(test.dt.ds, 2016-09-01 00:00:00.000000), le(test.dt.ds, 2016-11-03 00:00:00.000000) + └─TableRowIDScan_14 128.32 cop[tikv] table:dt keep order:false explain select gad.id as gid,sdk.id as sid,gad.aid as aid,gad.cm as cm,sdk.dic as dic,sdk.ip as ip, sdk.t as t, gad.p1 as p1, gad.p2 as p2, gad.p3 as p3, gad.p4 as p4, gad.p5 as p5, gad.p6_md5 as p6, gad.p7_md5 as p7, gad.ext as ext, gad.t as gtime from st gad join (select id, aid, pt, dic, ip, t from dd where pt = 'android' and bm = 0 and t > 1478143908) sdk on gad.aid = sdk.aid and gad.ip = sdk.ip and sdk.t > gad.t where gad.t > 1478143908 and gad.bm = 0 and gad.pt = 'android' group by gad.aid, sdk.dic limit 2500; -id estRows task operator info -Projection_13 424.00 root test.st.id, test.dd.id, test.st.aid, test.st.cm, test.dd.dic, test.dd.ip, test.dd.t, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, test.st.ext, test.st.t -└─Limit_16 424.00 root offset:0, count:2500 - └─HashAgg_19 424.00 root group by:test.dd.dic, test.st.aid, funcs:firstrow(test.st.id)->test.st.id, funcs:firstrow(test.st.aid)->test.st.aid, funcs:firstrow(test.st.cm)->test.st.cm, funcs:firstrow(test.st.p1)->test.st.p1, funcs:firstrow(test.st.p2)->test.st.p2, funcs:firstrow(test.st.p3)->test.st.p3, funcs:firstrow(test.st.p4)->test.st.p4, funcs:firstrow(test.st.p5)->test.st.p5, funcs:firstrow(test.st.p6_md5)->test.st.p6_md5, funcs:firstrow(test.st.p7_md5)->test.st.p7_md5, funcs:firstrow(test.st.ext)->test.st.ext, funcs:firstrow(test.st.t)->test.st.t, funcs:firstrow(test.dd.id)->test.dd.id, funcs:firstrow(test.dd.dic)->test.dd.dic, funcs:firstrow(test.dd.ip)->test.dd.ip, funcs:firstrow(test.dd.t)->test.dd.t - └─HashRightJoin_34 424.00 root inner join, equal:[eq(test.st.aid, test.dd.aid) eq(test.st.ip, test.dd.ip)], other cond:gt(test.dd.t, test.st.t) - ├─TableReader_37(Build) 424.00 root data:Selection_36 - │ └─Selection_36 424.00 cop[tikv] eq(test.st.bm, 0), eq(test.st.pt, "android"), gt(test.st.t, 1478143908), not(isnull(test.st.ip)) - │ └─TableRangeScan_35 1999.00 cop[tikv] table:gad, range:[0,+inf], keep order:false - └─TableReader_44(Probe) 455.80 root data:Selection_43 - └─Selection_43 455.80 cop[tikv] eq(test.dd.bm, 0), eq(test.dd.pt, "android"), gt(test.dd.t, 1478143908), not(isnull(test.dd.ip)), not(isnull(test.dd.t)) - └─TableRangeScan_42 2000.00 cop[tikv] table:dd, range:[0,+inf], keep order:false +id estRows task access object operator info +Projection_13 424.00 root test.st.id, test.dd.id, test.st.aid, test.st.cm, test.dd.dic, test.dd.ip, test.dd.t, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, test.st.ext, test.st.t +└─Limit_16 424.00 root offset:0, count:2500 + └─HashAgg_19 424.00 root group by:test.dd.dic, test.st.aid, funcs:firstrow(test.st.id)->test.st.id, funcs:firstrow(test.st.aid)->test.st.aid, funcs:firstrow(test.st.cm)->test.st.cm, funcs:firstrow(test.st.p1)->test.st.p1, funcs:firstrow(test.st.p2)->test.st.p2, funcs:firstrow(test.st.p3)->test.st.p3, funcs:firstrow(test.st.p4)->test.st.p4, funcs:firstrow(test.st.p5)->test.st.p5, funcs:firstrow(test.st.p6_md5)->test.st.p6_md5, funcs:firstrow(test.st.p7_md5)->test.st.p7_md5, funcs:firstrow(test.st.ext)->test.st.ext, funcs:firstrow(test.st.t)->test.st.t, funcs:firstrow(test.dd.id)->test.dd.id, funcs:firstrow(test.dd.dic)->test.dd.dic, funcs:firstrow(test.dd.ip)->test.dd.ip, funcs:firstrow(test.dd.t)->test.dd.t + └─HashJoin_34 424.00 root inner join, equal:[eq(test.st.aid, test.dd.aid) eq(test.st.ip, test.dd.ip)], other cond:gt(test.dd.t, test.st.t) + ├─TableReader_37(Build) 424.00 root data:Selection_36 + │ └─Selection_36 424.00 cop[tikv] eq(test.st.bm, 0), eq(test.st.pt, "android"), gt(test.st.t, 1478143908), not(isnull(test.st.ip)) + │ └─TableRangeScan_35 1999.00 cop[tikv] table:gad range:[0,+inf], keep order:false + └─TableReader_44(Probe) 455.80 root data:Selection_43 + └─Selection_43 455.80 cop[tikv] eq(test.dd.bm, 0), eq(test.dd.pt, "android"), gt(test.dd.t, 1478143908), not(isnull(test.dd.ip)), not(isnull(test.dd.t)) + └─TableRangeScan_42 2000.00 cop[tikv] table:dd range:[0,+inf], keep order:false explain select gad.id as gid,sdk.id as sid,gad.aid as aid,gad.cm as cm,sdk.dic as dic,sdk.ip as ip, sdk.t as t, gad.p1 as p1, gad.p2 as p2, gad.p3 as p3, gad.p4 as p4, gad.p5 as p5, gad.p6_md5 as p6, gad.p7_md5 as p7, gad.ext as ext from st gad join dd sdk on gad.aid = sdk.aid and gad.dic = sdk.mac and gad.t < sdk.t where gad.t > 1477971479 and gad.bm = 0 and gad.pt = 'ios' and gad.dit = 'mac' and sdk.t > 1477971479 and sdk.bm = 0 and sdk.pt = 'ios' limit 3000; -id estRows task operator info -Projection_10 170.34 root test.st.id, test.dd.id, test.st.aid, test.st.cm, test.dd.dic, test.dd.ip, test.dd.t, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, test.st.ext -└─Limit_13 170.34 root offset:0, count:3000 - └─IndexMergeJoin_24 170.34 root inner join, inner:IndexLookUp_22, outer key:test.st.aid, inner key:test.dd.aid, other cond:eq(test.st.dic, test.dd.mac), lt(test.st.t, test.dd.t) - ├─TableReader_31(Build) 170.34 root data:Selection_30 - │ └─Selection_30 170.34 cop[tikv] eq(test.st.bm, 0), eq(test.st.dit, "mac"), eq(test.st.pt, "ios"), gt(test.st.t, 1477971479), not(isnull(test.st.dic)) - │ └─TableRangeScan_29 1999.00 cop[tikv] table:gad, range:[0,+inf], keep order:false - └─IndexLookUp_22(Probe) 1.00 root - ├─IndexRangeScan_19(Build) 3.93 cop[tikv] table:sdk, index:aid, dic, range: decided by [eq(test.dd.aid, test.st.aid)], keep order:true - └─Selection_21(Probe) 1.00 cop[tikv] eq(test.dd.bm, 0), eq(test.dd.pt, "ios"), gt(test.dd.t, 1477971479), not(isnull(test.dd.mac)), not(isnull(test.dd.t)) - └─TableRowIDScan_20 3.93 cop[tikv] table:sdk, keep order:false +id estRows task access object operator info +Projection_10 170.34 root test.st.id, test.dd.id, test.st.aid, test.st.cm, test.dd.dic, test.dd.ip, test.dd.t, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, test.st.ext +└─Limit_13 170.34 root offset:0, count:3000 + └─IndexMergeJoin_24 170.34 root inner join, inner:IndexLookUp_22, outer key:test.st.aid, inner key:test.dd.aid, other cond:eq(test.st.dic, test.dd.mac), lt(test.st.t, test.dd.t) + ├─TableReader_31(Build) 170.34 root data:Selection_30 + │ └─Selection_30 170.34 cop[tikv] eq(test.st.bm, 0), eq(test.st.dit, "mac"), eq(test.st.pt, "ios"), gt(test.st.t, 1477971479), not(isnull(test.st.dic)) + │ └─TableRangeScan_29 1999.00 cop[tikv] table:gad range:[0,+inf], keep order:false + └─IndexLookUp_22(Probe) 1.00 root + ├─IndexRangeScan_19(Build) 3.93 cop[tikv] table:sdk, index:aid(aid, dic) range: decided by [eq(test.dd.aid, test.st.aid)], keep order:true + └─Selection_21(Probe) 1.00 cop[tikv] eq(test.dd.bm, 0), eq(test.dd.pt, "ios"), gt(test.dd.t, 1477971479), not(isnull(test.dd.mac)), not(isnull(test.dd.t)) + └─TableRowIDScan_20 3.93 cop[tikv] table:sdk keep order:false explain SELECT cm, p1, p2, p3, p4, p5, p6_md5, p7_md5, count(1) as click_pv, count(DISTINCT ip) as click_ip FROM st WHERE (t between 1478188800 and 1478275200) and aid='cn.sbkcq' and pt='android' GROUP BY cm, p1, p2, p3, p4, p5, p6_md5, p7_md5; -id estRows task operator info -Projection_5 39.28 root test.st.cm, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, Column#20, Column#21 -└─HashAgg_7 39.28 root group by:test.st.cm, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, funcs:count(1)->Column#20, funcs:count(distinct test.st.ip)->Column#21, funcs:firstrow(test.st.cm)->test.st.cm, funcs:firstrow(test.st.p1)->test.st.p1, funcs:firstrow(test.st.p2)->test.st.p2, funcs:firstrow(test.st.p3)->test.st.p3, funcs:firstrow(test.st.p4)->test.st.p4, funcs:firstrow(test.st.p5)->test.st.p5, funcs:firstrow(test.st.p6_md5)->test.st.p6_md5, funcs:firstrow(test.st.p7_md5)->test.st.p7_md5 - └─IndexLookUp_15 39.38 root - ├─IndexRangeScan_12(Build) 160.23 cop[tikv] table:st, index:t, range:[1478188800,1478275200], keep order:false - └─Selection_14(Probe) 39.38 cop[tikv] eq(test.st.aid, "cn.sbkcq"), eq(test.st.pt, "android") - └─TableRowIDScan_13 160.23 cop[tikv] table:st, keep order:false +id estRows task access object operator info +Projection_5 39.28 root test.st.cm, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, Column#20, Column#21 +└─HashAgg_7 39.28 root group by:test.st.cm, test.st.p1, test.st.p2, test.st.p3, test.st.p4, test.st.p5, test.st.p6_md5, test.st.p7_md5, funcs:count(1)->Column#20, funcs:count(distinct test.st.ip)->Column#21, funcs:firstrow(test.st.cm)->test.st.cm, funcs:firstrow(test.st.p1)->test.st.p1, funcs:firstrow(test.st.p2)->test.st.p2, funcs:firstrow(test.st.p3)->test.st.p3, funcs:firstrow(test.st.p4)->test.st.p4, funcs:firstrow(test.st.p5)->test.st.p5, funcs:firstrow(test.st.p6_md5)->test.st.p6_md5, funcs:firstrow(test.st.p7_md5)->test.st.p7_md5 + └─IndexLookUp_15 39.38 root + ├─IndexRangeScan_12(Build) 160.23 cop[tikv] table:st, index:t(t) range:[1478188800,1478275200], keep order:false + └─Selection_14(Probe) 39.38 cop[tikv] eq(test.st.aid, "cn.sbkcq"), eq(test.st.pt, "android") + └─TableRowIDScan_13 160.23 cop[tikv] table:st keep order:false explain select dt.id as id, dt.aid as aid, dt.pt as pt, dt.dic as dic, dt.cm as cm, rr.gid as gid, rr.acd as acd, rr.t as t,dt.p1 as p1, dt.p2 as p2, dt.p3 as p3, dt.p4 as p4, dt.p5 as p5, dt.p6_md5 as p6, dt.p7_md5 as p7 from dt dt join rr rr on (rr.pt = 'ios' and rr.t > 1478185592 and dt.aid = rr.aid and dt.dic = rr.dic) where dt.pt = 'ios' and dt.t > 1478185592 and dt.bm = 0 limit 2000; -id estRows task operator info -Projection_10 428.32 root test.dt.id, test.dt.aid, test.dt.pt, test.dt.dic, test.dt.cm, test.rr.gid, test.rr.acd, test.rr.t, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5 -└─Limit_13 428.32 root offset:0, count:2000 - └─IndexMergeJoin_26 428.32 root inner join, inner:Projection_24, outer key:test.dt.aid, test.dt.dic, inner key:test.rr.aid, test.rr.dic - ├─TableReader_58(Build) 428.32 root data:Selection_57 - │ └─Selection_57 428.32 cop[tikv] eq(test.dt.bm, 0), eq(test.dt.pt, "ios"), gt(test.dt.t, 1478185592), not(isnull(test.dt.dic)) - │ └─TableRangeScan_56 2000.00 cop[tikv] table:dt, range:[0,+inf], keep order:false - └─Projection_24(Probe) 1.00 root test.rr.aid, test.rr.pt, test.rr.dic, test.rr.gid, test.rr.acd, test.rr.t - └─IndexLookUp_23 1.00 root - ├─IndexRangeScan_20(Build) 1.00 cop[tikv] table:rr, index:aid, dic, range: decided by [eq(test.rr.aid, test.dt.aid) eq(test.rr.dic, test.dt.dic)], keep order:true - └─Selection_22(Probe) 1.00 cop[tikv] eq(test.rr.pt, "ios"), gt(test.rr.t, 1478185592) - └─TableRowIDScan_21 1.00 cop[tikv] table:rr, keep order:false +id estRows task access object operator info +Projection_10 428.32 root test.dt.id, test.dt.aid, test.dt.pt, test.dt.dic, test.dt.cm, test.rr.gid, test.rr.acd, test.rr.t, test.dt.p1, test.dt.p2, test.dt.p3, test.dt.p4, test.dt.p5, test.dt.p6_md5, test.dt.p7_md5 +└─Limit_13 428.32 root offset:0, count:2000 + └─IndexMergeJoin_26 428.32 root inner join, inner:Projection_24, outer key:test.dt.aid, test.dt.dic, inner key:test.rr.aid, test.rr.dic + ├─TableReader_58(Build) 428.32 root data:Selection_57 + │ └─Selection_57 428.32 cop[tikv] eq(test.dt.bm, 0), eq(test.dt.pt, "ios"), gt(test.dt.t, 1478185592), not(isnull(test.dt.dic)) + │ └─TableRangeScan_56 2000.00 cop[tikv] table:dt range:[0,+inf], keep order:false + └─Projection_24(Probe) 1.00 root test.rr.aid, test.rr.pt, test.rr.dic, test.rr.gid, test.rr.acd, test.rr.t + └─IndexLookUp_23 1.00 root + ├─IndexRangeScan_20(Build) 1.00 cop[tikv] table:rr, index:PRIMARY(aid, dic) range: decided by [eq(test.rr.aid, test.dt.aid) eq(test.rr.dic, test.dt.dic)], keep order:true + └─Selection_22(Probe) 1.00 cop[tikv] eq(test.rr.pt, "ios"), gt(test.rr.t, 1478185592) + └─TableRowIDScan_21 1.00 cop[tikv] table:rr keep order:false explain select pc,cr,count(DISTINCT uid) as pay_users,count(oid) as pay_times,sum(am) as am from pp where ps=2 and ppt>=1478188800 and ppt<1478275200 and pi in ('510017','520017') and uid in ('18089709','18090780') group by pc,cr; -id estRows task operator info -Projection_5 207.86 root test.pp.pc, test.pp.cr, Column#22, Column#23, Column#24 -└─HashAgg_7 207.86 root group by:test.pp.cr, test.pp.pc, funcs:count(distinct test.pp.uid)->Column#22, funcs:count(test.pp.oid)->Column#23, funcs:sum(test.pp.am)->Column#24, funcs:firstrow(test.pp.pc)->test.pp.pc, funcs:firstrow(test.pp.cr)->test.pp.cr - └─IndexLookUp_21 207.86 root - ├─IndexRangeScan_15(Build) 627.00 cop[tikv] table:pp, index:ps, range:[2,2], keep order:false - └─Selection_17(Probe) 207.86 cop[tikv] ge(test.pp.ppt, 1478188800), in(test.pp.pi, 510017, 520017), in(test.pp.uid, 18089709, 18090780), lt(test.pp.ppt, 1478275200) - └─TableRowIDScan_16 627.00 cop[tikv] table:pp, keep order:false +id estRows task access object operator info +Projection_5 207.86 root test.pp.pc, test.pp.cr, Column#22, Column#23, Column#24 +└─HashAgg_7 207.86 root group by:test.pp.cr, test.pp.pc, funcs:count(distinct test.pp.uid)->Column#22, funcs:count(test.pp.oid)->Column#23, funcs:sum(test.pp.am)->Column#24, funcs:firstrow(test.pp.pc)->test.pp.pc, funcs:firstrow(test.pp.cr)->test.pp.cr + └─IndexLookUp_21 207.86 root + ├─IndexRangeScan_15(Build) 627.00 cop[tikv] table:pp, index:ps(ps) range:[2,2], keep order:false + └─Selection_17(Probe) 207.86 cop[tikv] ge(test.pp.ppt, 1478188800), in(test.pp.pi, 510017, 520017), in(test.pp.uid, 18089709, 18090780), lt(test.pp.ppt, 1478275200) + └─TableRowIDScan_16 627.00 cop[tikv] table:pp keep order:false drop table if exists tbl_001; CREATE TABLE tbl_001 (a int, b int); load stats 's/explain_complex_stats_tbl_001.json'; @@ -204,25 +204,25 @@ drop table if exists tbl_009; CREATE TABLE tbl_009 (a int, b int); load stats 's/explain_complex_stats_tbl_009.json'; explain select sum(a) from (select * from tbl_001 union all select * from tbl_002 union all select * from tbl_003 union all select * from tbl_004 union all select * from tbl_005 union all select * from tbl_006 union all select * from tbl_007 union all select * from tbl_008 union all select * from tbl_009) x group by b; -id estRows task operator info -HashAgg_34 18000.00 root group by:Column#32, funcs:sum(Column#31)->Column#30 -└─Projection_63 18000.00 root cast(Column#28, decimal(65,0) BINARY)->Column#31, Column#29 - └─Union_35 18000.00 root - ├─TableReader_38 2000.00 root data:TableFullScan_37 - │ └─TableFullScan_37 2000.00 cop[tikv] table:tbl_001, keep order:false - ├─TableReader_41 2000.00 root data:TableFullScan_40 - │ └─TableFullScan_40 2000.00 cop[tikv] table:tbl_002, keep order:false - ├─TableReader_44 2000.00 root data:TableFullScan_43 - │ └─TableFullScan_43 2000.00 cop[tikv] table:tbl_003, keep order:false - ├─TableReader_47 2000.00 root data:TableFullScan_46 - │ └─TableFullScan_46 2000.00 cop[tikv] table:tbl_004, keep order:false - ├─TableReader_50 2000.00 root data:TableFullScan_49 - │ └─TableFullScan_49 2000.00 cop[tikv] table:tbl_005, keep order:false - ├─TableReader_53 2000.00 root data:TableFullScan_52 - │ └─TableFullScan_52 2000.00 cop[tikv] table:tbl_006, keep order:false - ├─TableReader_56 2000.00 root data:TableFullScan_55 - │ └─TableFullScan_55 2000.00 cop[tikv] table:tbl_007, keep order:false - ├─TableReader_59 2000.00 root data:TableFullScan_58 - │ └─TableFullScan_58 2000.00 cop[tikv] table:tbl_008, keep order:false - └─TableReader_62 2000.00 root data:TableFullScan_61 - └─TableFullScan_61 2000.00 cop[tikv] table:tbl_009, keep order:false +id estRows task access object operator info +HashAgg_34 18000.00 root group by:Column#32, funcs:sum(Column#31)->Column#30 +└─Projection_63 18000.00 root cast(Column#28, decimal(65,0) BINARY)->Column#31, Column#29 + └─Union_35 18000.00 root + ├─TableReader_38 2000.00 root data:TableFullScan_37 + │ └─TableFullScan_37 2000.00 cop[tikv] table:tbl_001 keep order:false + ├─TableReader_41 2000.00 root data:TableFullScan_40 + │ └─TableFullScan_40 2000.00 cop[tikv] table:tbl_002 keep order:false + ├─TableReader_44 2000.00 root data:TableFullScan_43 + │ └─TableFullScan_43 2000.00 cop[tikv] table:tbl_003 keep order:false + ├─TableReader_47 2000.00 root data:TableFullScan_46 + │ └─TableFullScan_46 2000.00 cop[tikv] table:tbl_004 keep order:false + ├─TableReader_50 2000.00 root data:TableFullScan_49 + │ └─TableFullScan_49 2000.00 cop[tikv] table:tbl_005 keep order:false + ├─TableReader_53 2000.00 root data:TableFullScan_52 + │ └─TableFullScan_52 2000.00 cop[tikv] table:tbl_006 keep order:false + ├─TableReader_56 2000.00 root data:TableFullScan_55 + │ └─TableFullScan_55 2000.00 cop[tikv] table:tbl_007 keep order:false + ├─TableReader_59 2000.00 root data:TableFullScan_58 + │ └─TableFullScan_58 2000.00 cop[tikv] table:tbl_008 keep order:false + └─TableReader_62 2000.00 root data:TableFullScan_61 + └─TableFullScan_61 2000.00 cop[tikv] table:tbl_009 keep order:false diff --git a/cmd/explaintest/r/explain_easy.result b/cmd/explaintest/r/explain_easy.result index 06d5452a9df83..231d5782c3e7c 100644 --- a/cmd/explaintest/r/explain_easy.result +++ b/cmd/explaintest/r/explain_easy.result @@ -12,180 +12,179 @@ set @@session.tidb_hashagg_partial_concurrency = 1; set @@session.tidb_hashagg_final_concurrency = 1; set @@session.tidb_window_concurrency = 1; explain select * from t3 where exists (select s.a from t3 s having sum(s.a) = t3.a ); -id estRows task operator info -HashLeftJoin_12 8000.00 root semi join, equal:[eq(Column#13, Column#11)] -├─StreamAgg_27(Build) 1.00 root funcs:sum(Column#16)->Column#11 -│ └─TableReader_28 1.00 root data:StreamAgg_19 -│ └─StreamAgg_19 1.00 cop[tikv] funcs:sum(test.t3.a)->Column#16 -│ └─TableFullScan_26 10000.00 cop[tikv] table:s, keep order:false, stats:pseudo -└─Projection_13(Probe) 10000.00 root test.t3.a, test.t3.b, test.t3.c, test.t3.d, cast(test.t3.a, decimal(20,0) BINARY)->Column#13 - └─TableReader_15 10000.00 root data:TableFullScan_14 - └─TableFullScan_14 10000.00 cop[tikv] table:t3, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_12 8000.00 root semi join, equal:[eq(Column#13, Column#11)] +├─StreamAgg_27(Build) 1.00 root funcs:sum(Column#16)->Column#11 +│ └─TableReader_28 1.00 root data:StreamAgg_19 +│ └─StreamAgg_19 1.00 cop[tikv] funcs:sum(test.t3.a)->Column#16 +│ └─TableFullScan_26 10000.00 cop[tikv] table:s keep order:false, stats:pseudo +└─Projection_13(Probe) 10000.00 root test.t3.a, test.t3.b, test.t3.c, test.t3.d, cast(test.t3.a, decimal(20,0) BINARY)->Column#13 + └─TableReader_15 10000.00 root data:TableFullScan_14 + └─TableFullScan_14 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo explain select * from t1; -id estRows task operator info -TableReader_5 10000.00 root data:TableFullScan_4 -└─TableFullScan_4 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_5 10000.00 root data:TableFullScan_4 +└─TableFullScan_4 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select * from t1 order by c2; -id estRows task operator info -IndexLookUp_12 10000.00 root -├─IndexFullScan_10(Build) 10000.00 cop[tikv] table:t1, index:c2, keep order:true, stats:pseudo -└─TableRowIDScan_11(Probe) 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +IndexLookUp_12 10000.00 root +├─IndexFullScan_10(Build) 10000.00 cop[tikv] table:t1, index:c2(c2) keep order:true, stats:pseudo +└─TableRowIDScan_11(Probe) 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select * from t2 order by c2; -id estRows task operator info -Sort_4 10000.00 root test.t2.c2:asc -└─TableReader_8 10000.00 root data:TableFullScan_7 - └─TableFullScan_7 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo +id estRows task access object operator info +Sort_4 10000.00 root test.t2.c2:asc +└─TableReader_8 10000.00 root data:TableFullScan_7 + └─TableFullScan_7 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo explain select * from t1 where t1.c1 > 0; -id estRows task operator info -TableReader_6 3333.33 root data:TableRangeScan_5 -└─TableRangeScan_5 3333.33 cop[tikv] table:t1, range:(0,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_6 3333.33 root data:TableRangeScan_5 +└─TableRangeScan_5 3333.33 cop[tikv] table:t1 range:(0,+inf], keep order:false, stats:pseudo explain select t1.c1, t1.c2 from t1 where t1.c2 = 1; -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t1, index:c2, range:[1,1], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t1, index:c2(c2) range:[1,1], keep order:false, stats:pseudo explain select * from t1 left join t2 on t1.c2 = t2.c1 where t1.c1 > 1; -id estRows task operator info -HashLeftJoin_23 4166.67 root left outer join, equal:[eq(test.t1.c2, test.t2.c1)] -├─TableReader_33(Build) 3333.33 root data:TableRangeScan_32 -│ └─TableRangeScan_32 3333.33 cop[tikv] table:t1, range:(1,+inf], keep order:false, stats:pseudo -└─TableReader_36(Probe) 9990.00 root data:Selection_35 - └─Selection_35 9990.00 cop[tikv] not(isnull(test.t2.c1)) - └─TableFullScan_34 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_23 4166.67 root left outer join, equal:[eq(test.t1.c2, test.t2.c1)] +├─TableReader_33(Build) 3333.33 root data:TableRangeScan_32 +│ └─TableRangeScan_32 3333.33 cop[tikv] table:t1 range:(1,+inf], keep order:false, stats:pseudo +└─TableReader_36(Probe) 9990.00 root data:Selection_35 + └─Selection_35 9990.00 cop[tikv] not(isnull(test.t2.c1)) + └─TableFullScan_34 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo explain update t1 set t1.c2 = 2 where t1.c1 = 1; -id estRows task operator info -Update_2 N/A root N/A -└─Point_Get_1 1.00 root table:t1, handle:1 +id estRows task access object operator info +Update_2 N/A root N/A +└─Point_Get_1 1.00 root table:t1 handle:1 explain delete from t1 where t1.c2 = 1; -id estRows task operator info -Delete_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─IndexLookUp_13 10.00 root - ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t1, index:c2, range:[1,1], keep order:false, stats:pseudo - └─TableRowIDScan_12(Probe) 10.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +Delete_4 N/A root N/A +└─IndexLookUp_11 10.00 root + ├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t1, index:c2(c2) range:[1,1], keep order:false, stats:pseudo + └─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select count(b.c2) from t1 a, t2 b where a.c1 = b.c2 group by a.c1; -id estRows task operator info -Projection_11 9990.00 root cast(Column#8, bigint(21) BINARY)->Column#7 -└─HashLeftJoin_21 9990.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] - ├─HashAgg_28(Build) 7992.00 root group by:test.t2.c2, funcs:count(Column#9)->Column#8, funcs:firstrow(test.t2.c2)->test.t2.c2 - │ └─TableReader_29 7992.00 root data:HashAgg_23 - │ └─HashAgg_23 7992.00 cop[tikv] group by:test.t2.c2, funcs:count(test.t2.c2)->Column#9 - │ └─Selection_27 9990.00 cop[tikv] not(isnull(test.t2.c2)) - │ └─TableFullScan_26 10000.00 cop[tikv] table:b, keep order:false, stats:pseudo - └─TableReader_34(Probe) 10000.00 root data:TableFullScan_33 - └─TableFullScan_33 10000.00 cop[tikv] table:a, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_11 9990.00 root cast(Column#8, bigint(21) BINARY)->Column#7 +└─HashJoin_21 9990.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] + ├─HashAgg_28(Build) 7992.00 root group by:test.t2.c2, funcs:count(Column#9)->Column#8, funcs:firstrow(test.t2.c2)->test.t2.c2 + │ └─TableReader_29 7992.00 root data:HashAgg_23 + │ └─HashAgg_23 7992.00 cop[tikv] group by:test.t2.c2, funcs:count(test.t2.c2)->Column#9 + │ └─Selection_27 9990.00 cop[tikv] not(isnull(test.t2.c2)) + │ └─TableFullScan_26 10000.00 cop[tikv] table:b keep order:false, stats:pseudo + └─TableReader_34(Probe) 10000.00 root data:TableFullScan_33 + └─TableFullScan_33 10000.00 cop[tikv] table:a keep order:false, stats:pseudo explain select * from t2 order by t2.c2 limit 0, 1; -id estRows task operator info -TopN_7 1.00 root test.t2.c2:asc, offset:0, count:1 -└─TableReader_15 1.00 root data:TopN_14 - └─TopN_14 1.00 cop[tikv] test.t2.c2:asc, offset:0, count:1 - └─TableFullScan_13 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo +id estRows task access object operator info +TopN_7 1.00 root test.t2.c2:asc, offset:0, count:1 +└─TableReader_15 1.00 root data:TopN_14 + └─TopN_14 1.00 cop[tikv] test.t2.c2:asc, offset:0, count:1 + └─TableFullScan_13 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo explain select * from t1 where c1 > 1 and c2 = 1 and c3 < 1; -id estRows task operator info -IndexLookUp_11 11.08 root -├─IndexRangeScan_8(Build) 33.33 cop[tikv] table:t1, index:c2, range:(1 1,1 +inf], keep order:false, stats:pseudo -└─Selection_10(Probe) 11.08 cop[tikv] lt(test.t1.c3, 1) - └─TableRowIDScan_9 33.33 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +IndexLookUp_11 11.08 root +├─IndexRangeScan_8(Build) 33.33 cop[tikv] table:t1, index:c2(c2) range:(1 1,1 +inf], keep order:false, stats:pseudo +└─Selection_10(Probe) 11.08 cop[tikv] lt(test.t1.c3, 1) + └─TableRowIDScan_9 33.33 cop[tikv] table:t1 keep order:false, stats:pseudo explain select * from t1 where c1 = 1 and c2 > 1; -id estRows task operator info -Selection_6 0.33 root gt(test.t1.c2, 1) -└─Point_Get_5 1.00 root table:t1, handle:1 +id estRows task access object operator info +Selection_6 0.33 root gt(test.t1.c2, 1) +└─Point_Get_5 1.00 root table:t1 handle:1 explain select sum(t1.c1 in (select c1 from t2)) from t1; -id estRows task operator info -StreamAgg_12 1.00 root funcs:sum(Column#10)->Column#8 -└─Projection_23 10000.00 root cast(Column#7, decimal(65,0) BINARY)->Column#10 - └─HashLeftJoin_22 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.c1, test.t2.c1) - ├─IndexReader_21(Build) 10000.00 root index:IndexFullScan_20 - │ └─IndexFullScan_20 10000.00 cop[tikv] table:t2, index:c1, keep order:false, stats:pseudo - └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 - └─TableFullScan_14 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +StreamAgg_12 1.00 root funcs:sum(Column#10)->Column#8 +└─Projection_23 10000.00 root cast(Column#7, decimal(65,0) BINARY)->Column#10 + └─HashJoin_22 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.c1, test.t2.c1) + ├─IndexReader_21(Build) 10000.00 root index:IndexFullScan_20 + │ └─IndexFullScan_20 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo + └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 + └─TableFullScan_14 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select c1 from t1 where c1 in (select c2 from t2); -id estRows task operator info -HashLeftJoin_19 9990.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] -├─HashAgg_23(Build) 7992.00 root group by:test.t2.c2, funcs:firstrow(test.t2.c2)->test.t2.c2 -│ └─TableReader_30 9990.00 root data:Selection_29 -│ └─Selection_29 9990.00 cop[tikv] not(isnull(test.t2.c2)) -│ └─TableFullScan_28 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo -└─TableReader_32(Probe) 10000.00 root data:TableFullScan_31 - └─TableFullScan_31 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_19 9990.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] +├─HashAgg_23(Build) 7992.00 root group by:test.t2.c2, funcs:firstrow(test.t2.c2)->test.t2.c2 +│ └─TableReader_30 9990.00 root data:Selection_29 +│ └─Selection_29 9990.00 cop[tikv] not(isnull(test.t2.c2)) +│ └─TableFullScan_28 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader_32(Probe) 10000.00 root data:TableFullScan_31 + └─TableFullScan_31 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select (select count(1) k from t1 s where s.c1 = t1.c1 having k != 0) from t1; -id estRows task operator info -Projection_12 10000.00 root ifnull(Column#7, 0)->Column#7 -└─MergeJoin_13 10000.00 root left outer join, left key:test.t1.c1, right key:test.t1.c1 - ├─Projection_18(Build) 8000.00 root 1->Column#7, test.t1.c1 - │ └─TableReader_20 10000.00 root data:TableFullScan_19 - │ └─TableFullScan_19 10000.00 cop[tikv] table:s, keep order:true, stats:pseudo - └─TableReader_17(Probe) 10000.00 root data:TableFullScan_16 - └─TableFullScan_16 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo +id estRows task access object operator info +Projection_12 10000.00 root ifnull(Column#7, 0)->Column#7 +└─MergeJoin_13 10000.00 root left outer join, left key:test.t1.c1, right key:test.t1.c1 + ├─Projection_18(Build) 8000.00 root 1->Column#7, test.t1.c1 + │ └─TableReader_20 10000.00 root data:TableFullScan_19 + │ └─TableFullScan_19 10000.00 cop[tikv] table:s keep order:true, stats:pseudo + └─TableReader_17(Probe) 10000.00 root data:TableFullScan_16 + └─TableFullScan_16 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo explain select * from information_schema.columns; -id estRows task operator info -MemTableScan_4 10000.00 root table:COLUMNS +id estRows task access object operator info +MemTableScan_4 10000.00 root table:COLUMNS explain select c2 = (select c2 from t2 where t1.c1 = t2.c1 order by c1 limit 1) from t1; -id estRows task operator info -Projection_12 10000.00 root eq(test.t1.c2, test.t2.c2)->Column#8 -└─Apply_14 10000.00 root CARTESIAN left outer join - ├─TableReader_16(Build) 10000.00 root data:TableFullScan_15 - │ └─TableFullScan_15 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo - └─Projection_43(Probe) 1.00 root test.t2.c1, test.t2.c2 - └─IndexLookUp_42 1.00 root limit embedded(offset:0, count:1) - ├─Limit_41(Build) 1.00 cop[tikv] offset:0, count:1 - │ └─IndexRangeScan_39 1.00 cop[tikv] table:t2, index:c1, range: decided by [eq(test.t1.c1, test.t2.c1)], keep order:true, stats:pseudo - └─TableRowIDScan_40(Probe) 1.00 cop[tikv] table:t2, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_12 10000.00 root eq(test.t1.c2, test.t2.c2)->Column#8 +└─Apply_14 10000.00 root CARTESIAN left outer join + ├─TableReader_16(Build) 10000.00 root data:TableFullScan_15 + │ └─TableFullScan_15 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─Projection_43(Probe) 1.00 root test.t2.c1, test.t2.c2 + └─IndexLookUp_42 1.00 root limit embedded(offset:0, count:1) + ├─Limit_41(Build) 1.00 cop[tikv] offset:0, count:1 + │ └─IndexRangeScan_39 1.00 cop[tikv] table:t2, index:c1(c1) range: decided by [eq(test.t1.c1, test.t2.c1)], keep order:true, stats:pseudo + └─TableRowIDScan_40(Probe) 1.00 cop[tikv] table:t2 keep order:false, stats:pseudo explain select * from t1 order by c1 desc limit 1; -id estRows task operator info -Limit_10 1.00 root offset:0, count:1 -└─TableReader_20 1.00 root data:Limit_19 - └─Limit_19 1.00 cop[tikv] offset:0, count:1 - └─TableFullScan_18 1.00 cop[tikv] table:t1, keep order:true, desc, stats:pseudo +id estRows task access object operator info +Limit_10 1.00 root offset:0, count:1 +└─TableReader_20 1.00 root data:Limit_19 + └─Limit_19 1.00 cop[tikv] offset:0, count:1 + └─TableFullScan_18 1.00 cop[tikv] table:t1 keep order:true, desc, stats:pseudo explain select * from t4 use index(idx) where a > 1 and b > 1 and c > 1 limit 1; -id estRows task operator info -Limit_9 1.00 root offset:0, count:1 -└─IndexLookUp_16 1.00 root - ├─Selection_13(Build) 3.00 cop[tikv] gt(test.t4.b, 1) - │ └─IndexRangeScan_11 9.00 cop[tikv] table:t4, index:a, b, range:(1,+inf], keep order:false, stats:pseudo - └─Limit_15(Probe) 1.00 cop[tikv] offset:0, count:1 - └─Selection_14 1.00 cop[tikv] gt(test.t4.c, 1) - └─TableRowIDScan_12 3.00 cop[tikv] table:t4, keep order:false, stats:pseudo +id estRows task access object operator info +Limit_9 1.00 root offset:0, count:1 +└─IndexLookUp_16 1.00 root + ├─Selection_13(Build) 3.00 cop[tikv] gt(test.t4.b, 1) + │ └─IndexRangeScan_11 9.00 cop[tikv] table:t4, index:idx(a, b) range:(1,+inf], keep order:false, stats:pseudo + └─Limit_15(Probe) 1.00 cop[tikv] offset:0, count:1 + └─Selection_14 1.00 cop[tikv] gt(test.t4.c, 1) + └─TableRowIDScan_12 3.00 cop[tikv] table:t4 keep order:false, stats:pseudo explain select * from t4 where a > 1 and c > 1 limit 1; -id estRows task operator info -Limit_8 1.00 root offset:0, count:1 -└─TableReader_14 1.00 root data:Limit_13 - └─Limit_13 1.00 cop[tikv] offset:0, count:1 - └─Selection_12 1.00 cop[tikv] gt(test.t4.c, 1) - └─TableRangeScan_11 3.00 cop[tikv] table:t4, range:(1,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Limit_8 1.00 root offset:0, count:1 +└─TableReader_14 1.00 root data:Limit_13 + └─Limit_13 1.00 cop[tikv] offset:0, count:1 + └─Selection_12 1.00 cop[tikv] gt(test.t4.c, 1) + └─TableRangeScan_11 3.00 cop[tikv] table:t4 range:(1,+inf], keep order:false, stats:pseudo explain select ifnull(null, t1.c1) from t1; -id estRows task operator info -TableReader_5 10000.00 root data:TableFullScan_4 -└─TableFullScan_4 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_5 10000.00 root data:TableFullScan_4 +└─TableFullScan_4 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select if(10, t1.c1, t1.c2) from t1; -id estRows task operator info -TableReader_5 10000.00 root data:TableFullScan_4 -└─TableFullScan_4 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_5 10000.00 root data:TableFullScan_4 +└─TableFullScan_4 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select c1 from t2 union select c1 from t2 union all select c1 from t2; -id estRows task operator info -Union_17 26000.00 root -├─HashAgg_21 16000.00 root group by:Column#10, funcs:firstrow(Column#12)->Column#10 -│ └─Union_22 16000.00 root -│ ├─StreamAgg_27 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#12, funcs:firstrow(test.t2.c1)->Column#10 -│ │ └─IndexReader_40 10000.00 root index:IndexFullScan_39 -│ │ └─IndexFullScan_39 10000.00 cop[tikv] table:t2, index:c1, keep order:true, stats:pseudo -│ └─StreamAgg_45 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#12, funcs:firstrow(test.t2.c1)->Column#10 -│ └─IndexReader_58 10000.00 root index:IndexFullScan_57 -│ └─IndexFullScan_57 10000.00 cop[tikv] table:t2, index:c1, keep order:true, stats:pseudo -└─IndexReader_63 10000.00 root index:IndexFullScan_62 - └─IndexFullScan_62 10000.00 cop[tikv] table:t2, index:c1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_17 26000.00 root +├─HashAgg_21 16000.00 root group by:Column#10, funcs:firstrow(Column#12)->Column#10 +│ └─Union_22 16000.00 root +│ ├─StreamAgg_27 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#12, funcs:firstrow(test.t2.c1)->Column#10 +│ │ └─IndexReader_40 10000.00 root index:IndexFullScan_39 +│ │ └─IndexFullScan_39 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo +│ └─StreamAgg_45 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#12, funcs:firstrow(test.t2.c1)->Column#10 +│ └─IndexReader_58 10000.00 root index:IndexFullScan_57 +│ └─IndexFullScan_57 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo +└─IndexReader_63 10000.00 root index:IndexFullScan_62 + └─IndexFullScan_62 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo explain select c1 from t2 union all select c1 from t2 union select c1 from t2; -id estRows task operator info -HashAgg_18 24000.00 root group by:Column#10, funcs:firstrow(Column#11)->Column#10 -└─Union_19 24000.00 root - ├─StreamAgg_24 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10 - │ └─IndexReader_37 10000.00 root index:IndexFullScan_36 - │ └─IndexFullScan_36 10000.00 cop[tikv] table:t2, index:c1, keep order:true, stats:pseudo - ├─StreamAgg_42 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10 - │ └─IndexReader_55 10000.00 root index:IndexFullScan_54 - │ └─IndexFullScan_54 10000.00 cop[tikv] table:t2, index:c1, keep order:true, stats:pseudo - └─StreamAgg_60 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10 - └─IndexReader_73 10000.00 root index:IndexFullScan_72 - └─IndexFullScan_72 10000.00 cop[tikv] table:t2, index:c1, keep order:true, stats:pseudo +id estRows task access object operator info +HashAgg_18 24000.00 root group by:Column#10, funcs:firstrow(Column#11)->Column#10 +└─Union_19 24000.00 root + ├─StreamAgg_24 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10 + │ └─IndexReader_37 10000.00 root index:IndexFullScan_36 + │ └─IndexFullScan_36 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo + ├─StreamAgg_42 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10 + │ └─IndexReader_55 10000.00 root index:IndexFullScan_54 + │ └─IndexFullScan_54 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo + └─StreamAgg_60 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10 + └─IndexReader_73 10000.00 root index:IndexFullScan_72 + └─IndexFullScan_72 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo select * from information_schema.tidb_indexes where table_name='t4'; TABLE_SCHEMA TABLE_NAME NON_UNIQUE KEY_NAME SEQ_IN_INDEX COLUMN_NAME SUB_PART INDEX_COMMENT Expression INDEX_ID test t4 0 PRIMARY 1 a NULL NULL 0 @@ -193,61 +192,61 @@ test t4 1 idx 1 a NULL NULL 1 test t4 1 idx 2 b NULL NULL 1 test t4 1 expr_idx 1 NULL NULL (`a` + `b` + 1) 2 explain select count(1) from (select count(1) from (select * from t1 where c3 = 100) k) k2; -id estRows task operator info -StreamAgg_13 1.00 root funcs:count(1)->Column#5 -└─StreamAgg_28 1.00 root funcs:firstrow(Column#9)->Column#7 - └─TableReader_29 1.00 root data:StreamAgg_17 - └─StreamAgg_17 1.00 cop[tikv] funcs:firstrow(1)->Column#9 - └─Selection_27 10.00 cop[tikv] eq(test.t1.c3, 100) - └─TableFullScan_26 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +StreamAgg_13 1.00 root funcs:count(1)->Column#5 +└─StreamAgg_28 1.00 root funcs:firstrow(Column#9)->Column#7 + └─TableReader_29 1.00 root data:StreamAgg_17 + └─StreamAgg_17 1.00 cop[tikv] funcs:firstrow(1)->Column#9 + └─Selection_27 10.00 cop[tikv] eq(test.t1.c3, 100) + └─TableFullScan_26 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select 1 from (select count(c2), count(c3) from t1) k; -id estRows task operator info -Projection_5 1.00 root 1->Column#6 -└─StreamAgg_21 1.00 root funcs:firstrow(Column#14)->Column#9 - └─TableReader_22 1.00 root data:StreamAgg_9 - └─StreamAgg_9 1.00 cop[tikv] funcs:firstrow(1)->Column#14 - └─TableFullScan_19 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_5 1.00 root 1->Column#6 +└─StreamAgg_21 1.00 root funcs:firstrow(Column#14)->Column#9 + └─TableReader_22 1.00 root data:StreamAgg_9 + └─StreamAgg_9 1.00 cop[tikv] funcs:firstrow(1)->Column#14 + └─TableFullScan_19 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select count(1) from (select max(c2), count(c3) as m from t1) k; -id estRows task operator info -StreamAgg_11 1.00 root funcs:count(1)->Column#6 -└─StreamAgg_27 1.00 root funcs:firstrow(Column#13)->Column#8 - └─TableReader_28 1.00 root data:StreamAgg_15 - └─StreamAgg_15 1.00 cop[tikv] funcs:firstrow(1)->Column#13 - └─TableFullScan_25 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +StreamAgg_11 1.00 root funcs:count(1)->Column#6 +└─StreamAgg_27 1.00 root funcs:firstrow(Column#13)->Column#8 + └─TableReader_28 1.00 root data:StreamAgg_15 + └─StreamAgg_15 1.00 cop[tikv] funcs:firstrow(1)->Column#13 + └─TableFullScan_25 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select count(1) from (select count(c2) from t1 group by c3) k; -id estRows task operator info -StreamAgg_11 1.00 root funcs:count(1)->Column#5 -└─HashAgg_22 8000.00 root group by:test.t1.c3, funcs:firstrow(1)->Column#7 - └─TableReader_19 10000.00 root data:TableFullScan_18 - └─TableFullScan_18 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +StreamAgg_11 1.00 root funcs:count(1)->Column#5 +└─HashAgg_22 8000.00 root group by:test.t1.c3, funcs:firstrow(1)->Column#7 + └─TableReader_19 10000.00 root data:TableFullScan_18 + └─TableFullScan_18 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo set @@session.tidb_opt_insubq_to_join_and_agg=0; explain select sum(t1.c1 in (select c1 from t2)) from t1; -id estRows task operator info -StreamAgg_12 1.00 root funcs:sum(Column#10)->Column#8 -└─Projection_23 10000.00 root cast(Column#7, decimal(65,0) BINARY)->Column#10 - └─HashLeftJoin_22 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.c1, test.t2.c1) - ├─IndexReader_21(Build) 10000.00 root index:IndexFullScan_20 - │ └─IndexFullScan_20 10000.00 cop[tikv] table:t2, index:c1, keep order:false, stats:pseudo - └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 - └─TableFullScan_14 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +StreamAgg_12 1.00 root funcs:sum(Column#10)->Column#8 +└─Projection_23 10000.00 root cast(Column#7, decimal(65,0) BINARY)->Column#10 + └─HashJoin_22 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.c1, test.t2.c1) + ├─IndexReader_21(Build) 10000.00 root index:IndexFullScan_20 + │ └─IndexFullScan_20 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo + └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 + └─TableFullScan_14 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select 1 in (select c2 from t2) from t1; -id estRows task operator info -HashLeftJoin_7 10000.00 root CARTESIAN left outer semi join -├─TableReader_14(Build) 10.00 root data:Selection_13 -│ └─Selection_13 10.00 cop[tikv] eq(1, test.t2.c2) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo -└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8 - └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_7 10000.00 root CARTESIAN left outer semi join +├─TableReader_14(Build) 10.00 root data:Selection_13 +│ └─Selection_13 10.00 cop[tikv] eq(1, test.t2.c2) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8 + └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select sum(6 in (select c2 from t2)) from t1; -id estRows task operator info -StreamAgg_12 1.00 root funcs:sum(Column#10)->Column#8 -└─Projection_22 10000.00 root cast(Column#7, decimal(65,0) BINARY)->Column#10 - └─HashLeftJoin_21 10000.00 root CARTESIAN left outer semi join - ├─TableReader_20(Build) 10.00 root data:Selection_19 - │ └─Selection_19 10.00 cop[tikv] eq(6, test.t2.c2) - │ └─TableFullScan_18 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo - └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 - └─TableFullScan_14 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +StreamAgg_12 1.00 root funcs:sum(Column#10)->Column#8 +└─Projection_22 10000.00 root cast(Column#7, decimal(65,0) BINARY)->Column#10 + └─HashJoin_21 10000.00 root CARTESIAN left outer semi join + ├─TableReader_20(Build) 10.00 root data:Selection_19 + │ └─Selection_19 10.00 cop[tikv] eq(6, test.t2.c2) + │ └─TableFullScan_18 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 + └─TableFullScan_14 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain format="dot" select sum(t1.c1 in (select c1 from t2)) from t1; dot contents @@ -257,9 +256,9 @@ node [style=filled, color=lightgrey] color=black label = "root" "StreamAgg_12" -> "Projection_23" -"Projection_23" -> "HashLeftJoin_22" -"HashLeftJoin_22" -> "TableReader_15" -"HashLeftJoin_22" -> "IndexReader_21" +"Projection_23" -> "HashJoin_22" +"HashJoin_22" -> "TableReader_15" +"HashJoin_22" -> "IndexReader_21" } subgraph cluster14{ node [style=filled, color=lightgrey] @@ -280,13 +279,13 @@ label = "cop" explain format="dot" select 1 in (select c2 from t2) from t1; dot contents -digraph HashLeftJoin_7 { +digraph HashJoin_7 { subgraph cluster7{ node [style=filled, color=lightgrey] color=black label = "root" -"HashLeftJoin_7" -> "TableReader_9" -"HashLeftJoin_7" -> "TableReader_14" +"HashJoin_7" -> "TableReader_9" +"HashJoin_7" -> "TableReader_14" } subgraph cluster8{ node [style=filled, color=lightgrey] @@ -308,182 +307,182 @@ drop table if exists t1, t2, t3, t4; drop table if exists t; create table t(a int primary key, b int, c int, index idx(b)); explain select t.c in (select count(*) from t s ignore index(idx), t t1 where s.a = t.a and s.a = t1.a) from t; -id estRows task operator info -Projection_11 10000.00 root Column#11 -└─Apply_13 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) - ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 - │ └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo - └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#10 - └─MergeJoin_54 12.50 root inner join, left key:test.t.a, right key:test.t.a - ├─TableReader_49(Build) 1.00 root data:TableRangeScan_48 - │ └─TableRangeScan_48 1.00 cop[tikv] table:t1, range: decided by [eq(test.t.a, test.t.a)], keep order:true, stats:pseudo - └─TableReader_47(Probe) 1.00 root data:TableRangeScan_46 - └─TableRangeScan_46 1.00 cop[tikv] table:s, range: decided by [eq(test.t.a, test.t.a)], keep order:true, stats:pseudo +id estRows task access object operator info +Projection_11 10000.00 root Column#11 +└─Apply_13 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) + ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 + │ └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:false, stats:pseudo + └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#10 + └─MergeJoin_54 12.50 root inner join, left key:test.t.a, right key:test.t.a + ├─TableReader_49(Build) 1.00 root data:TableRangeScan_48 + │ └─TableRangeScan_48 1.00 cop[tikv] table:t1 range: decided by [eq(test.t.a, test.t.a)], keep order:true, stats:pseudo + └─TableReader_47(Probe) 1.00 root data:TableRangeScan_46 + └─TableRangeScan_46 1.00 cop[tikv] table:s range: decided by [eq(test.t.a, test.t.a)], keep order:true, stats:pseudo explain select t.c in (select count(*) from t s use index(idx), t t1 where s.b = t.a and s.a = t1.a) from t; -id estRows task operator info -Projection_11 10000.00 root Column#11 -└─Apply_13 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) - ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 - │ └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo - └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#10 - └─IndexMergeJoin_44 12.50 root inner join, inner:TableReader_42, outer key:test.t.a, inner key:test.t.a - ├─IndexReader_33(Build) 10.00 root index:IndexRangeScan_32 - │ └─IndexRangeScan_32 10.00 cop[tikv] table:s, index:b, range: decided by [eq(test.t.b, test.t.a)], keep order:false, stats:pseudo - └─TableReader_42(Probe) 1.00 root data:TableRangeScan_41 - └─TableRangeScan_41 1.00 cop[tikv] table:t1, range: decided by [test.t.a], keep order:true, stats:pseudo +id estRows task access object operator info +Projection_11 10000.00 root Column#11 +└─Apply_13 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) + ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 + │ └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:false, stats:pseudo + └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#10 + └─IndexMergeJoin_44 12.50 root inner join, inner:TableReader_42, outer key:test.t.a, inner key:test.t.a + ├─IndexReader_33(Build) 10.00 root index:IndexRangeScan_32 + │ └─IndexRangeScan_32 10.00 cop[tikv] table:s, index:idx(b) range: decided by [eq(test.t.b, test.t.a)], keep order:false, stats:pseudo + └─TableReader_42(Probe) 1.00 root data:TableRangeScan_41 + └─TableRangeScan_41 1.00 cop[tikv] table:t1 range: decided by [test.t.a], keep order:true, stats:pseudo explain select t.c in (select count(*) from t s use index(idx), t t1 where s.b = t.a and s.c = t1.a) from t; -id estRows task operator info -Projection_11 10000.00 root Column#11 -└─Apply_13 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) - ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 - │ └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo - └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#10 - └─IndexMergeJoin_46 12.49 root inner join, inner:TableReader_44, outer key:test.t.c, inner key:test.t.a - ├─IndexLookUp_35(Build) 9.99 root - │ ├─IndexRangeScan_32(Build) 10.00 cop[tikv] table:s, index:b, range: decided by [eq(test.t.b, test.t.a)], keep order:false, stats:pseudo - │ └─Selection_34(Probe) 9.99 cop[tikv] not(isnull(test.t.c)) - │ └─TableRowIDScan_33 10.00 cop[tikv] table:s, keep order:false, stats:pseudo - └─TableReader_44(Probe) 1.00 root data:TableRangeScan_43 - └─TableRangeScan_43 1.00 cop[tikv] table:t1, range: decided by [test.t.c], keep order:true, stats:pseudo +id estRows task access object operator info +Projection_11 10000.00 root Column#11 +└─Apply_13 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) + ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 + │ └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:false, stats:pseudo + └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#10 + └─IndexMergeJoin_46 12.49 root inner join, inner:TableReader_44, outer key:test.t.c, inner key:test.t.a + ├─IndexLookUp_35(Build) 9.99 root + │ ├─IndexRangeScan_32(Build) 10.00 cop[tikv] table:s, index:idx(b) range: decided by [eq(test.t.b, test.t.a)], keep order:false, stats:pseudo + │ └─Selection_34(Probe) 9.99 cop[tikv] not(isnull(test.t.c)) + │ └─TableRowIDScan_33 10.00 cop[tikv] table:s keep order:false, stats:pseudo + └─TableReader_44(Probe) 1.00 root data:TableRangeScan_43 + └─TableRangeScan_43 1.00 cop[tikv] table:t1 range: decided by [test.t.c], keep order:true, stats:pseudo insert into t values(1, 1, 1), (2, 2 ,2), (3, 3, 3), (4, 3, 4),(5,3,5); analyze table t; explain select t.c in (select count(*) from t s, t t1 where s.b = t.a and s.b = 3 and s.a = t1.a) from t; -id estRows task operator info -Projection_11 5.00 root Column#11 -└─Apply_13 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) - ├─TableReader_15(Build) 5.00 root data:TableFullScan_14 - │ └─TableFullScan_14 5.00 cop[tikv] table:t, keep order:false - └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#10 - └─MergeJoin_62 2.40 root inner join, left key:test.t.a, right key:test.t.a - ├─TableReader_52(Build) 4.00 root data:Selection_51 - │ └─Selection_51 4.00 cop[tikv] eq(3, test.t.a) - │ └─TableFullScan_50 5.00 cop[tikv] table:t1, keep order:true - └─IndexReader_49(Probe) 2.40 root index:Selection_48 - └─Selection_48 2.40 cop[tikv] eq(3, test.t.a) - └─IndexRangeScan_47 3.00 cop[tikv] table:s, index:b, range:[3,3], keep order:true +id estRows task access object operator info +Projection_11 5.00 root Column#11 +└─Apply_13 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) + ├─TableReader_15(Build) 5.00 root data:TableFullScan_14 + │ └─TableFullScan_14 5.00 cop[tikv] table:t keep order:false + └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#10 + └─MergeJoin_62 2.40 root inner join, left key:test.t.a, right key:test.t.a + ├─TableReader_52(Build) 4.00 root data:Selection_51 + │ └─Selection_51 4.00 cop[tikv] eq(3, test.t.a) + │ └─TableFullScan_50 5.00 cop[tikv] table:t1 keep order:true + └─IndexReader_49(Probe) 2.40 root index:Selection_48 + └─Selection_48 2.40 cop[tikv] eq(3, test.t.a) + └─IndexRangeScan_47 3.00 cop[tikv] table:s, index:idx(b) range:[3,3], keep order:true explain select t.c in (select count(*) from t s left join t t1 on s.a = t1.a where 3 = t.a and s.b = 3) from t; -id estRows task operator info -Projection_10 5.00 root Column#11 -└─Apply_12 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) - ├─TableReader_14(Build) 5.00 root data:TableFullScan_13 - │ └─TableFullScan_13 5.00 cop[tikv] table:t, keep order:false - └─StreamAgg_19(Probe) 1.00 root funcs:count(1)->Column#10 - └─MergeJoin_50 2.40 root left outer join, left key:test.t.a, right key:test.t.a - ├─TableReader_40(Build) 4.00 root data:Selection_39 - │ └─Selection_39 4.00 cop[tikv] eq(3, test.t.a) - │ └─TableFullScan_38 5.00 cop[tikv] table:t1, keep order:true - └─IndexReader_37(Probe) 2.40 root index:Selection_36 - └─Selection_36 2.40 cop[tikv] eq(3, test.t.a) - └─IndexRangeScan_35 3.00 cop[tikv] table:s, index:b, range:[3,3], keep order:true +id estRows task access object operator info +Projection_10 5.00 root Column#11 +└─Apply_12 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) + ├─TableReader_14(Build) 5.00 root data:TableFullScan_13 + │ └─TableFullScan_13 5.00 cop[tikv] table:t keep order:false + └─StreamAgg_19(Probe) 1.00 root funcs:count(1)->Column#10 + └─MergeJoin_50 2.40 root left outer join, left key:test.t.a, right key:test.t.a + ├─TableReader_40(Build) 4.00 root data:Selection_39 + │ └─Selection_39 4.00 cop[tikv] eq(3, test.t.a) + │ └─TableFullScan_38 5.00 cop[tikv] table:t1 keep order:true + └─IndexReader_37(Probe) 2.40 root index:Selection_36 + └─Selection_36 2.40 cop[tikv] eq(3, test.t.a) + └─IndexRangeScan_35 3.00 cop[tikv] table:s, index:idx(b) range:[3,3], keep order:true explain select t.c in (select count(*) from t s right join t t1 on s.a = t1.a where 3 = t.a and t1.b = 3) from t; -id estRows task operator info -Projection_10 5.00 root Column#11 -└─Apply_12 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) - ├─TableReader_14(Build) 5.00 root data:TableFullScan_13 - │ └─TableFullScan_13 5.00 cop[tikv] table:t, keep order:false - └─StreamAgg_19(Probe) 1.00 root funcs:count(1)->Column#10 - └─MergeJoin_49 2.40 root right outer join, left key:test.t.a, right key:test.t.a - ├─TableReader_36(Build) 4.00 root data:Selection_35 - │ └─Selection_35 4.00 cop[tikv] eq(3, test.t.a) - │ └─TableFullScan_34 5.00 cop[tikv] table:s, keep order:true - └─IndexReader_39(Probe) 2.40 root index:Selection_38 - └─Selection_38 2.40 cop[tikv] eq(3, test.t.a) - └─IndexRangeScan_37 3.00 cop[tikv] table:t1, index:b, range:[3,3], keep order:true +id estRows task access object operator info +Projection_10 5.00 root Column#11 +└─Apply_12 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#10) + ├─TableReader_14(Build) 5.00 root data:TableFullScan_13 + │ └─TableFullScan_13 5.00 cop[tikv] table:t keep order:false + └─StreamAgg_19(Probe) 1.00 root funcs:count(1)->Column#10 + └─MergeJoin_49 2.40 root right outer join, left key:test.t.a, right key:test.t.a + ├─TableReader_36(Build) 4.00 root data:Selection_35 + │ └─Selection_35 4.00 cop[tikv] eq(3, test.t.a) + │ └─TableFullScan_34 5.00 cop[tikv] table:s keep order:true + └─IndexReader_39(Probe) 2.40 root index:Selection_38 + └─Selection_38 2.40 cop[tikv] eq(3, test.t.a) + └─IndexRangeScan_37 3.00 cop[tikv] table:t1, index:idx(b) range:[3,3], keep order:true drop table if exists t; create table t(a int unsigned); explain select t.a = '123455' from t; -id estRows task operator info -Projection_3 10000.00 root eq(test.t.a, 123455)->Column#3 -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root eq(test.t.a, 123455)->Column#3 +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select t.a > '123455' from t; -id estRows task operator info -Projection_3 10000.00 root gt(test.t.a, 123455)->Column#3 -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root gt(test.t.a, 123455)->Column#3 +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select t.a != '123455' from t; -id estRows task operator info -Projection_3 10000.00 root ne(test.t.a, 123455)->Column#3 -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root ne(test.t.a, 123455)->Column#3 +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select t.a = 12345678912345678998789678687678.111 from t; -id estRows task operator info -Projection_3 10000.00 root 0->Column#3 -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root 0->Column#3 +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo drop table if exists t; create table t(a bigint, b bigint, index idx(a, b)); explain select * from t where a in (1, 2) and a in (1, 3); -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:a, b, range:[1,1], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:idx(a, b) range:[1,1], keep order:false, stats:pseudo explain select * from t where b in (1, 2) and b in (1, 3); -id estRows task operator info -TableReader_7 10.00 root data:Selection_6 -└─Selection_6 10.00 cop[tikv] in(test.t.b, 1, 2), in(test.t.b, 1, 3) - └─TableFullScan_5 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 10.00 root data:Selection_6 +└─Selection_6 10.00 cop[tikv] in(test.t.b, 1, 2), in(test.t.b, 1, 3) + └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select * from t where a = 1 and a = 1; -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:a, b, range:[1,1], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:idx(a, b) range:[1,1], keep order:false, stats:pseudo explain select * from t where a = 1 and a = 2; -id estRows task operator info -TableDual_5 0.00 root rows:0 +id estRows task access object operator info +TableDual_5 0.00 root rows:0 explain select * from t where b = 1 and b = 2; -id estRows task operator info -TableDual_5 0.00 root rows:0 +id estRows task access object operator info +TableDual_5 0.00 root rows:0 explain select * from t t1 join t t2 where t1.b = t2.b and t2.b is null; -id estRows task operator info -Projection_7 0.00 root test.t.a, test.t.b, test.t.a, test.t.b -└─HashRightJoin_9 0.00 root inner join, equal:[eq(test.t.b, test.t.b)] - ├─TableReader_12(Build) 0.00 root data:Selection_11 - │ └─Selection_11 0.00 cop[tikv] isnull(test.t.b), not(isnull(test.t.b)) - │ └─TableFullScan_10 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo - └─TableReader_18(Probe) 9990.00 root data:Selection_17 - └─Selection_17 9990.00 cop[tikv] not(isnull(test.t.b)) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 0.00 root test.t.a, test.t.b, test.t.a, test.t.b +└─HashJoin_9 0.00 root inner join, equal:[eq(test.t.b, test.t.b)] + ├─TableReader_12(Build) 0.00 root data:Selection_11 + │ └─Selection_11 0.00 cop[tikv] isnull(test.t.b), not(isnull(test.t.b)) + │ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader_18(Probe) 9990.00 root data:Selection_17 + └─Selection_17 9990.00 cop[tikv] not(isnull(test.t.b)) + └─TableFullScan_16 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select * from t t1 where not exists (select * from t t2 where t1.b = t2.b); -id estRows task operator info -HashLeftJoin_9 8000.00 root anti semi join, equal:[eq(test.t.b, test.t.b)] -├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 -│ └─TableFullScan_14 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo -└─TableReader_11(Probe) 10000.00 root data:TableFullScan_10 - └─TableFullScan_10 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_9 8000.00 root anti semi join, equal:[eq(test.t.b, test.t.b)] +├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 +│ └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader_11(Probe) 10000.00 root data:TableFullScan_10 + └─TableFullScan_10 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo drop table if exists t; create table t(a bigint primary key); explain select * from t where a = 1 and a = 2; -id estRows task operator info -TableDual_5 0.00 root rows:0 +id estRows task access object operator info +TableDual_5 0.00 root rows:0 explain select null or a > 1 from t; -id estRows task operator info -Projection_3 10000.00 root or(, gt(test.t.a, 1))->Column#2 -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root or(, gt(test.t.a, 1))->Column#2 +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select * from t where a = 1 for update; -id estRows task operator info -Point_Get_1 1.00 root table:t, handle:1, lock +id estRows task access object operator info +Point_Get_1 1.00 root table:t handle:1, lock drop table if exists ta, tb; create table ta (a varchar(20)); create table tb (a varchar(20)); begin; insert tb values ('1'); explain select * from ta where a = 1; -id estRows task operator info -TableReader_7 8000.00 root data:Selection_6 -└─Selection_6 8000.00 cop[tikv] eq(cast(test.ta.a), 1) - └─TableFullScan_5 10000.00 cop[tikv] table:ta, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 8000.00 root data:Selection_6 +└─Selection_6 8000.00 cop[tikv] eq(cast(test.ta.a), 1) + └─TableFullScan_5 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo rollback; drop table if exists t1, t2; create table t1(a int, b int, c int, primary key(a, b)); create table t2(a int, b int, c int, primary key(a)); explain select t1.a, t1.b from t1 left outer join t2 on t1.a = t2.a; -id estRows task operator info -IndexReader_9 10000.00 root index:IndexFullScan_8 -└─IndexFullScan_8 10000.00 cop[tikv] table:t1, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_9 10000.00 root index:IndexFullScan_8 +└─IndexFullScan_8 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo explain select distinct t1.a, t1.b from t1 left outer join t2 on t1.a = t2.a; -id estRows task operator info -IndexReader_11 10000.00 root index:IndexFullScan_10 -└─IndexFullScan_10 10000.00 cop[tikv] table:t1, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10000.00 root index:IndexFullScan_10 +└─IndexFullScan_10 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo CREATE TABLE `test01` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `stat_date` int(11) NOT NULL DEFAULT '0', @@ -499,258 +498,258 @@ CREATE TABLE `test02` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; EXPLAIN SELECT COUNT(1) FROM (SELECT COALESCE(b.region_name, '不详') region_name, SUM(a.registration_num) registration_num FROM (SELECT stat_date, show_date, region_id, 0 registration_num FROM test01 WHERE period = 1 AND stat_date >= 20191202 AND stat_date <= 20191202 UNION ALL SELECT stat_date, show_date, region_id, registration_num registration_num FROM test01 WHERE period = 1 AND stat_date >= 20191202 AND stat_date <= 20191202) a LEFT JOIN test02 b ON a.region_id = b.id WHERE registration_num > 0 AND a.stat_date >= '20191202' AND a.stat_date <= '20191202' GROUP BY a.stat_date , a.show_date , COALESCE(b.region_name, '不详') ) JLS; -id estRows task operator info -StreamAgg_22 1.00 root funcs:count(1)->Column#22 -└─HashAgg_25 1.00 root group by:Column#32, Column#33, Column#34, funcs:firstrow(1)->Column#31 - └─Projection_46 0.01 root Column#14, Column#15, coalesce(test.test02.region_name, 不详)->Column#34 - └─IndexMergeJoin_32 0.01 root left outer join, inner:TableReader_30, outer key:Column#16, inner key:test.test02.id - ├─Union_37(Build) 0.01 root - │ ├─Projection_38 0.00 root test.test01.stat_date, test.test01.show_date, test.test01.region_id - │ │ └─TableDual_39 0.00 root rows:0 - │ └─Projection_40 0.01 root test.test01.stat_date, test.test01.show_date, test.test01.region_id - │ └─TableReader_43 0.01 root data:Selection_42 - │ └─Selection_42 0.01 cop[tikv] eq(test.test01.period, 1), ge(test.test01.stat_date, 20191202), ge(test.test01.stat_date, 20191202), gt(cast(test.test01.registration_num), 0), le(test.test01.stat_date, 20191202), le(test.test01.stat_date, 20191202) - │ └─TableFullScan_41 10000.00 cop[tikv] table:test01, keep order:false, stats:pseudo - └─TableReader_30(Probe) 1.00 root data:TableRangeScan_29 - └─TableRangeScan_29 1.00 cop[tikv] table:b, range: decided by [Column#16], keep order:true, stats:pseudo +id estRows task access object operator info +StreamAgg_22 1.00 root funcs:count(1)->Column#22 +└─HashAgg_25 1.00 root group by:Column#32, Column#33, Column#34, funcs:firstrow(1)->Column#31 + └─Projection_46 0.01 root Column#14, Column#15, coalesce(test.test02.region_name, 不详)->Column#34 + └─IndexMergeJoin_32 0.01 root left outer join, inner:TableReader_30, outer key:Column#16, inner key:test.test02.id + ├─Union_37(Build) 0.01 root + │ ├─Projection_38 0.00 root test.test01.stat_date, test.test01.show_date, test.test01.region_id + │ │ └─TableDual_39 0.00 root rows:0 + │ └─Projection_40 0.01 root test.test01.stat_date, test.test01.show_date, test.test01.region_id + │ └─TableReader_43 0.01 root data:Selection_42 + │ └─Selection_42 0.01 cop[tikv] eq(test.test01.period, 1), ge(test.test01.stat_date, 20191202), ge(test.test01.stat_date, 20191202), gt(cast(test.test01.registration_num), 0), le(test.test01.stat_date, 20191202), le(test.test01.stat_date, 20191202) + │ └─TableFullScan_41 10000.00 cop[tikv] table:test01 keep order:false, stats:pseudo + └─TableReader_30(Probe) 1.00 root data:TableRangeScan_29 + └─TableRangeScan_29 1.00 cop[tikv] table:b range: decided by [Column#16], keep order:true, stats:pseudo drop table if exists t; create table t(a int, nb int not null, nc int not null); explain select ifnull(a, 0) from t; -id estRows task operator info -Projection_3 10000.00 root ifnull(test.t.a, 0)->Column#5 -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root ifnull(test.t.a, 0)->Column#5 +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select ifnull(nb, 0) from t; -id estRows task operator info -TableReader_5 10000.00 root data:TableFullScan_4 -└─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_5 10000.00 root data:TableFullScan_4 +└─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select ifnull(nb, 0), ifnull(nc, 0) from t; -id estRows task operator info -TableReader_5 10000.00 root data:TableFullScan_4 -└─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_5 10000.00 root data:TableFullScan_4 +└─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select ifnull(a, 0), ifnull(nb, 0) from t; -id estRows task operator info -Projection_3 10000.00 root ifnull(test.t.a, 0)->Column#5, test.t.nb -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root ifnull(test.t.a, 0)->Column#5, test.t.nb +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select ifnull(nb, 0), ifnull(nb, 0) from t; -id estRows task operator info -Projection_3 10000.00 root test.t.nb, test.t.nb -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root test.t.nb, test.t.nb +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select 1+ifnull(nb, 0) from t; -id estRows task operator info -Projection_3 10000.00 root plus(1, test.t.nb)->Column#5 -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root plus(1, test.t.nb)->Column#5 +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select 1+ifnull(a, 0) from t; -id estRows task operator info -Projection_3 10000.00 root plus(1, ifnull(test.t.a, 0))->Column#5 -└─TableReader_5 10000.00 root data:TableFullScan_4 - └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_3 10000.00 root plus(1, ifnull(test.t.a, 0))->Column#5 +└─TableReader_5 10000.00 root data:TableFullScan_4 + └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select 1+ifnull(nb, 0) from t where nb=1; -id estRows task operator info -Projection_4 10.00 root plus(1, test.t.nb)->Column#5 -└─TableReader_7 10.00 root data:Selection_6 - └─Selection_6 10.00 cop[tikv] eq(test.t.nb, 1) - └─TableFullScan_5 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 10.00 root plus(1, test.t.nb)->Column#5 +└─TableReader_7 10.00 root data:Selection_6 + └─Selection_6 10.00 cop[tikv] eq(test.t.nb, 1) + └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select * from t ta left outer join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(ta.nb, 1) or ta.nb is null; -id estRows task operator info -HashLeftJoin_7 8320.83 root left outer join, equal:[eq(test.t.nb, test.t.nb)], left cond:[gt(test.t.a, 1)] -├─TableReader_13(Build) 10000.00 root data:TableFullScan_12 -│ └─TableFullScan_12 10000.00 cop[tikv] table:tb, keep order:false, stats:pseudo -└─TableReader_11(Probe) 6656.67 root data:Selection_10 - └─Selection_10 6656.67 cop[tikv] or(test.t.nb, isnull(test.t.nb)) - └─TableFullScan_9 10000.00 cop[tikv] table:ta, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_7 8320.83 root left outer join, equal:[eq(test.t.nb, test.t.nb)], left cond:[gt(test.t.a, 1)] +├─TableReader_13(Build) 10000.00 root data:TableFullScan_12 +│ └─TableFullScan_12 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo +└─TableReader_11(Probe) 6656.67 root data:Selection_10 + └─Selection_10 6656.67 cop[tikv] or(test.t.nb, isnull(test.t.nb)) + └─TableFullScan_9 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo explain select * from t ta right outer join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(tb.nb, 1) or tb.nb is null; -id estRows task operator info -HashRightJoin_7 6656.67 root right outer join, equal:[eq(test.t.nb, test.t.nb)] -├─TableReader_11(Build) 3333.33 root data:Selection_10 -│ └─Selection_10 3333.33 cop[tikv] gt(test.t.a, 1) -│ └─TableFullScan_9 10000.00 cop[tikv] table:ta, keep order:false, stats:pseudo -└─TableReader_14(Probe) 6656.67 root data:Selection_13 - └─Selection_13 6656.67 cop[tikv] or(test.t.nb, isnull(test.t.nb)) - └─TableFullScan_12 10000.00 cop[tikv] table:tb, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_7 6656.67 root right outer join, equal:[eq(test.t.nb, test.t.nb)] +├─TableReader_11(Build) 3333.33 root data:Selection_10 +│ └─Selection_10 3333.33 cop[tikv] gt(test.t.a, 1) +│ └─TableFullScan_9 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo +└─TableReader_14(Probe) 6656.67 root data:Selection_13 + └─Selection_13 6656.67 cop[tikv] or(test.t.nb, isnull(test.t.nb)) + └─TableFullScan_12 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo explain select * from t ta inner join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(tb.nb, 1) or tb.nb is null; -id estRows task operator info -HashRightJoin_9 4166.67 root inner join, equal:[eq(test.t.nb, test.t.nb)] -├─TableReader_12(Build) 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t.a, 1) -│ └─TableFullScan_10 10000.00 cop[tikv] table:ta, keep order:false, stats:pseudo -└─TableReader_15(Probe) 6656.67 root data:Selection_14 - └─Selection_14 6656.67 cop[tikv] or(test.t.nb, isnull(test.t.nb)) - └─TableFullScan_13 10000.00 cop[tikv] table:tb, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_9 4166.67 root inner join, equal:[eq(test.t.nb, test.t.nb)] +├─TableReader_12(Build) 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t.a, 1) +│ └─TableFullScan_10 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo +└─TableReader_15(Probe) 6656.67 root data:Selection_14 + └─Selection_14 6656.67 cop[tikv] or(test.t.nb, isnull(test.t.nb)) + └─TableFullScan_13 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo explain select ifnull(t.nc, 1) in (select count(*) from t s , t t1 where s.a = t.a and s.a = t1.a) from t; -id estRows task operator info -Projection_12 10000.00 root Column#14 -└─Apply_14 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.nc, Column#13) - ├─TableReader_16(Build) 10000.00 root data:TableFullScan_15 - │ └─TableFullScan_15 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo - └─HashAgg_19(Probe) 1.00 root funcs:count(Column#15)->Column#13 - └─HashLeftJoin_20 9.99 root inner join, equal:[eq(test.t.a, test.t.a)] - ├─HashAgg_30(Build) 7.99 root group by:test.t.a, funcs:count(Column#16)->Column#15, funcs:firstrow(test.t.a)->test.t.a - │ └─TableReader_31 7.99 root data:HashAgg_25 - │ └─HashAgg_25 7.99 cop[tikv] group by:test.t.a, funcs:count(1)->Column#16 - │ └─Selection_29 9.99 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a)) - │ └─TableFullScan_28 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo - └─TableReader_24(Probe) 9.99 root data:Selection_23 - └─Selection_23 9.99 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a)) - └─TableFullScan_22 10000.00 cop[tikv] table:s, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_12 10000.00 root Column#14 +└─Apply_14 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.nc, Column#13) + ├─TableReader_16(Build) 10000.00 root data:TableFullScan_15 + │ └─TableFullScan_15 10000.00 cop[tikv] table:t keep order:false, stats:pseudo + └─HashAgg_19(Probe) 1.00 root funcs:count(Column#15)->Column#13 + └─HashJoin_20 9.99 root inner join, equal:[eq(test.t.a, test.t.a)] + ├─HashAgg_30(Build) 7.99 root group by:test.t.a, funcs:count(Column#16)->Column#15, funcs:firstrow(test.t.a)->test.t.a + │ └─TableReader_31 7.99 root data:HashAgg_25 + │ └─HashAgg_25 7.99 cop[tikv] group by:test.t.a, funcs:count(1)->Column#16 + │ └─Selection_29 9.99 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a)) + │ └─TableFullScan_28 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─TableReader_24(Probe) 9.99 root data:Selection_23 + └─Selection_23 9.99 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a)) + └─TableFullScan_22 10000.00 cop[tikv] table:s keep order:false, stats:pseudo explain select * from t ta left outer join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(tb.a, 1) or tb.a is null; -id estRows task operator info -Selection_7 10000.00 root or(ifnull(test.t.a, 1), isnull(test.t.a)) -└─HashLeftJoin_8 12500.00 root left outer join, equal:[eq(test.t.nb, test.t.nb)], left cond:[gt(test.t.a, 1)] - ├─TableReader_13(Build) 10000.00 root data:TableFullScan_12 - │ └─TableFullScan_12 10000.00 cop[tikv] table:tb, keep order:false, stats:pseudo - └─TableReader_11(Probe) 10000.00 root data:TableFullScan_10 - └─TableFullScan_10 10000.00 cop[tikv] table:ta, keep order:false, stats:pseudo +id estRows task access object operator info +Selection_7 10000.00 root or(ifnull(test.t.a, 1), isnull(test.t.a)) +└─HashJoin_8 12500.00 root left outer join, equal:[eq(test.t.nb, test.t.nb)], left cond:[gt(test.t.a, 1)] + ├─TableReader_13(Build) 10000.00 root data:TableFullScan_12 + │ └─TableFullScan_12 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo + └─TableReader_11(Probe) 10000.00 root data:TableFullScan_10 + └─TableFullScan_10 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo explain select * from t ta right outer join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(tb.a, 1) or tb.a is null; -id estRows task operator info -HashRightJoin_7 8000.00 root right outer join, equal:[eq(test.t.nb, test.t.nb)] -├─TableReader_11(Build) 3333.33 root data:Selection_10 -│ └─Selection_10 3333.33 cop[tikv] gt(test.t.a, 1) -│ └─TableFullScan_9 10000.00 cop[tikv] table:ta, keep order:false, stats:pseudo -└─TableReader_14(Probe) 8000.00 root data:Selection_13 - └─Selection_13 8000.00 cop[tikv] or(ifnull(test.t.a, 1), isnull(test.t.a)) - └─TableFullScan_12 10000.00 cop[tikv] table:tb, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_7 8000.00 root right outer join, equal:[eq(test.t.nb, test.t.nb)] +├─TableReader_11(Build) 3333.33 root data:Selection_10 +│ └─Selection_10 3333.33 cop[tikv] gt(test.t.a, 1) +│ └─TableFullScan_9 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo +└─TableReader_14(Probe) 8000.00 root data:Selection_13 + └─Selection_13 8000.00 cop[tikv] or(ifnull(test.t.a, 1), isnull(test.t.a)) + └─TableFullScan_12 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo explain select ifnull(t.a, 1) in (select count(*) from t s , t t1 where s.a = t.a and s.a = t1.a) from t; -id estRows task operator info -Projection_12 10000.00 root Column#14 -└─Apply_14 10000.00 root CARTESIAN left outer semi join, other cond:eq(ifnull(test.t.a, 1), Column#13) - ├─TableReader_16(Build) 10000.00 root data:TableFullScan_15 - │ └─TableFullScan_15 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo - └─HashAgg_19(Probe) 1.00 root funcs:count(Column#15)->Column#13 - └─HashLeftJoin_20 9.99 root inner join, equal:[eq(test.t.a, test.t.a)] - ├─HashAgg_30(Build) 7.99 root group by:test.t.a, funcs:count(Column#16)->Column#15, funcs:firstrow(test.t.a)->test.t.a - │ └─TableReader_31 7.99 root data:HashAgg_25 - │ └─HashAgg_25 7.99 cop[tikv] group by:test.t.a, funcs:count(1)->Column#16 - │ └─Selection_29 9.99 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a)) - │ └─TableFullScan_28 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo - └─TableReader_24(Probe) 9.99 root data:Selection_23 - └─Selection_23 9.99 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a)) - └─TableFullScan_22 10000.00 cop[tikv] table:s, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_12 10000.00 root Column#14 +└─Apply_14 10000.00 root CARTESIAN left outer semi join, other cond:eq(ifnull(test.t.a, 1), Column#13) + ├─TableReader_16(Build) 10000.00 root data:TableFullScan_15 + │ └─TableFullScan_15 10000.00 cop[tikv] table:t keep order:false, stats:pseudo + └─HashAgg_19(Probe) 1.00 root funcs:count(Column#15)->Column#13 + └─HashJoin_20 9.99 root inner join, equal:[eq(test.t.a, test.t.a)] + ├─HashAgg_30(Build) 7.99 root group by:test.t.a, funcs:count(Column#16)->Column#15, funcs:firstrow(test.t.a)->test.t.a + │ └─TableReader_31 7.99 root data:HashAgg_25 + │ └─HashAgg_25 7.99 cop[tikv] group by:test.t.a, funcs:count(1)->Column#16 + │ └─Selection_29 9.99 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a)) + │ └─TableFullScan_28 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─TableReader_24(Probe) 9.99 root data:Selection_23 + └─Selection_23 9.99 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a)) + └─TableFullScan_22 10000.00 cop[tikv] table:s keep order:false, stats:pseudo drop table if exists t; create table t(a int); explain select * from t where _tidb_rowid = 0; -id estRows task operator info -Point_Get_1 1.00 root table:t, handle:0 +id estRows task access object operator info +Point_Get_1 1.00 root table:t handle:0 explain select * from t where _tidb_rowid > 0; -id estRows task operator info -Projection_4 8000.00 root test.t.a -└─TableReader_6 10000.00 root data:TableRangeScan_5 - └─TableRangeScan_5 10000.00 cop[tikv] table:t, range:(0,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 8000.00 root test.t.a +└─TableReader_6 10000.00 root data:TableRangeScan_5 + └─TableRangeScan_5 10000.00 cop[tikv] table:t range:(0,+inf], keep order:false, stats:pseudo explain select a, _tidb_rowid from t where a > 0; -id estRows task operator info -TableReader_7 3333.33 root data:Selection_6 -└─Selection_6 3333.33 cop[tikv] gt(test.t.a, 0) - └─TableFullScan_5 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:Selection_6 +└─Selection_6 3333.33 cop[tikv] gt(test.t.a, 0) + └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select * from t where _tidb_rowid > 0 and a > 0; -id estRows task operator info -Projection_4 2666.67 root test.t.a -└─TableReader_7 2666.67 root data:Selection_6 - └─Selection_6 2666.67 cop[tikv] gt(test.t.a, 0) - └─TableRangeScan_5 3333.33 cop[tikv] table:t, range:(0,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 2666.67 root test.t.a +└─TableReader_7 2666.67 root data:Selection_6 + └─Selection_6 2666.67 cop[tikv] gt(test.t.a, 0) + └─TableRangeScan_5 3333.33 cop[tikv] table:t range:(0,+inf], keep order:false, stats:pseudo drop table if exists t; create table t(a int, b int, c int); explain select * from (select * from t order by (select 2)) t order by a, b; -id estRows task operator info -Sort_12 10000.00 root test.t.a:asc, test.t.b:asc -└─TableReader_18 10000.00 root data:TableFullScan_17 - └─TableFullScan_17 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Sort_12 10000.00 root test.t.a:asc, test.t.b:asc +└─TableReader_18 10000.00 root data:TableFullScan_17 + └─TableFullScan_17 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select * from (select * from t order by c) t order by a, b; -id estRows task operator info -Sort_6 10000.00 root test.t.a:asc, test.t.b:asc -└─Sort_9 10000.00 root test.t.c:asc - └─TableReader_12 10000.00 root data:TableFullScan_11 - └─TableFullScan_11 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Sort_6 10000.00 root test.t.a:asc, test.t.b:asc +└─Sort_9 10000.00 root test.t.c:asc + └─TableReader_12 10000.00 root data:TableFullScan_11 + └─TableFullScan_11 10000.00 cop[tikv] table:t keep order:false, stats:pseudo drop table if exists t; set @@session.tidb_opt_insubq_to_join_and_agg=1; explain SELECT 0 AS a FROM dual UNION SELECT 1 AS a FROM dual ORDER BY a; -id estRows task operator info -Sort_13 2.00 root Column#3:asc -└─HashAgg_17 2.00 root group by:Column#3, funcs:firstrow(Column#6)->Column#3 - └─Union_18 2.00 root - ├─HashAgg_19 1.00 root group by:1, funcs:firstrow(0)->Column#6, funcs:firstrow(0)->Column#3 - │ └─TableDual_22 1.00 root rows:1 - └─HashAgg_25 1.00 root group by:1, funcs:firstrow(1)->Column#6, funcs:firstrow(1)->Column#3 - └─TableDual_28 1.00 root rows:1 +id estRows task access object operator info +Sort_13 2.00 root Column#3:asc +└─HashAgg_17 2.00 root group by:Column#3, funcs:firstrow(Column#6)->Column#3 + └─Union_18 2.00 root + ├─HashAgg_19 1.00 root group by:1, funcs:firstrow(0)->Column#6, funcs:firstrow(0)->Column#3 + │ └─TableDual_22 1.00 root rows:1 + └─HashAgg_25 1.00 root group by:1, funcs:firstrow(1)->Column#6, funcs:firstrow(1)->Column#3 + └─TableDual_28 1.00 root rows:1 explain SELECT 0 AS a FROM dual UNION (SELECT 1 AS a FROM dual ORDER BY a); -id estRows task operator info -HashAgg_15 2.00 root group by:Column#3, funcs:firstrow(Column#6)->Column#3 -└─Union_16 2.00 root - ├─HashAgg_17 1.00 root group by:1, funcs:firstrow(0)->Column#6, funcs:firstrow(0)->Column#3 - │ └─TableDual_20 1.00 root rows:1 - └─StreamAgg_27 1.00 root group by:Column#1, funcs:firstrow(Column#1)->Column#6, funcs:firstrow(Column#1)->Column#3 - └─Projection_32 1.00 root 1->Column#1 - └─TableDual_33 1.00 root rows:1 +id estRows task access object operator info +HashAgg_15 2.00 root group by:Column#3, funcs:firstrow(Column#6)->Column#3 +└─Union_16 2.00 root + ├─HashAgg_17 1.00 root group by:1, funcs:firstrow(0)->Column#6, funcs:firstrow(0)->Column#3 + │ └─TableDual_20 1.00 root rows:1 + └─StreamAgg_27 1.00 root group by:Column#1, funcs:firstrow(Column#1)->Column#6, funcs:firstrow(Column#1)->Column#3 + └─Projection_32 1.00 root 1->Column#1 + └─TableDual_33 1.00 root rows:1 create table t (i int key, j int, unique key (i, j)); begin; insert into t values (1, 1); explain update t set j = -j where i = 1 and j = 1; -id estRows task operator info -Update_2 N/A root N/A -└─Point_Get_1 1.00 root table:t, index:i j +id estRows task access object operator info +Update_2 N/A root N/A +└─Point_Get_1 1.00 root table:t, index:i(i, j) rollback; drop table if exists t; create table t(a int); begin; insert into t values (1); explain select * from t left outer join t t1 on t.a = t1.a where t.a not between 1 and 2; -id estRows task operator info -HashLeftJoin_9 8320.83 root left outer join, equal:[eq(test.t.a, test.t.a)] -├─UnionScan_15(Build) 6656.67 root not(and(ge(test.t.a, 1), le(test.t.a, 2))), not(isnull(test.t.a)) -│ └─TableReader_18 6656.67 root data:Selection_17 -│ └─Selection_17 6656.67 cop[tikv] not(isnull(test.t.a)), or(lt(test.t.a, 1), gt(test.t.a, 2)) -│ └─TableFullScan_16 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo -└─UnionScan_11(Probe) 6656.67 root not(and(ge(test.t.a, 1), le(test.t.a, 2))) - └─TableReader_14 6656.67 root data:Selection_13 - └─Selection_13 6656.67 cop[tikv] or(lt(test.t.a, 1), gt(test.t.a, 2)) - └─TableFullScan_12 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_9 8320.83 root left outer join, equal:[eq(test.t.a, test.t.a)] +├─UnionScan_15(Build) 6656.67 root not(and(ge(test.t.a, 1), le(test.t.a, 2))), not(isnull(test.t.a)) +│ └─TableReader_18 6656.67 root data:Selection_17 +│ └─Selection_17 6656.67 cop[tikv] not(isnull(test.t.a)), or(lt(test.t.a, 1), gt(test.t.a, 2)) +│ └─TableFullScan_16 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─UnionScan_11(Probe) 6656.67 root not(and(ge(test.t.a, 1), le(test.t.a, 2))) + └─TableReader_14 6656.67 root data:Selection_13 + └─Selection_13 6656.67 cop[tikv] or(lt(test.t.a, 1), gt(test.t.a, 2)) + └─TableFullScan_12 10000.00 cop[tikv] table:t keep order:false, stats:pseudo rollback; drop table if exists t; create table t(a time, b date); insert into t values (1, "1000-01-01"), (2, "1000-01-02"), (3, "1000-01-03"); analyze table t; explain select * from t where a = 1; -id estRows task operator info -TableReader_7 1.00 root data:Selection_6 -└─Selection_6 1.00 cop[tikv] eq(test.t.a, 00:00:01.000000) - └─TableFullScan_5 3.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 1.00 root data:Selection_6 +└─Selection_6 1.00 cop[tikv] eq(test.t.a, 00:00:01.000000) + └─TableFullScan_5 3.00 cop[tikv] table:t keep order:false explain select * from t where b = "1000-01-01"; -id estRows task operator info -TableReader_7 1.00 root data:Selection_6 -└─Selection_6 1.00 cop[tikv] eq(test.t.b, 1000-01-01 00:00:00.000000) - └─TableFullScan_5 3.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 1.00 root data:Selection_6 +└─Selection_6 1.00 cop[tikv] eq(test.t.b, 1000-01-01 00:00:00.000000) + └─TableFullScan_5 3.00 cop[tikv] table:t keep order:false drop table t; create table t(a int); insert into t values (1),(2),(2),(2),(9),(9),(9),(10); analyze table t with 1 buckets; explain select * from t where a >= 3 and a <= 8; -id estRows task operator info -TableReader_7 0.00 root data:Selection_6 -└─Selection_6 0.00 cop[tikv] ge(test.t.a, 3), le(test.t.a, 8) - └─TableFullScan_5 8.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 0.00 root data:Selection_6 +└─Selection_6 0.00 cop[tikv] ge(test.t.a, 3), le(test.t.a, 8) + └─TableFullScan_5 8.00 cop[tikv] table:t keep order:false drop table t; create table t(a int, b int, index idx_ab(a, b)); explain select a, b from t where a in (1) order by b; -id estRows task operator info -IndexReader_12 10.00 root index:IndexRangeScan_11 -└─IndexRangeScan_11 10.00 cop[tikv] table:t, index:a, b, range:[1,1], keep order:true, stats:pseudo +id estRows task access object operator info +IndexReader_12 10.00 root index:IndexRangeScan_11 +└─IndexRangeScan_11 10.00 cop[tikv] table:t, index:idx_ab(a, b) range:[1,1], keep order:true, stats:pseudo explain select a, b from t where a = 1 order by b; -id estRows task operator info -IndexReader_12 10.00 root index:IndexRangeScan_11 -└─IndexRangeScan_11 10.00 cop[tikv] table:t, index:a, b, range:[1,1], keep order:true, stats:pseudo +id estRows task access object operator info +IndexReader_12 10.00 root index:IndexRangeScan_11 +└─IndexRangeScan_11 10.00 cop[tikv] table:t, index:idx_ab(a, b) range:[1,1], keep order:true, stats:pseudo drop table if exists t; create table t(a int, b int); explain select a, b from (select a, b, avg(b) over (partition by a)as avg_b from t) as tt where a > 10 and b < 10 and a > avg_b; -id estRows task operator info -Projection_8 2666.67 root test.t.a, test.t.b -└─Selection_9 2666.67 root gt(cast(test.t.a), Column#5), lt(test.t.b, 10) - └─Window_10 3333.33 root avg(cast(test.t.b, decimal(65,4) BINARY))->Column#5 over(partition by test.t.a) - └─Sort_14 3333.33 root test.t.a:asc - └─TableReader_13 3333.33 root data:Selection_12 - └─Selection_12 3333.33 cop[tikv] gt(test.t.a, 10) - └─TableFullScan_11 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_8 2666.67 root test.t.a, test.t.b +└─Selection_9 2666.67 root gt(cast(test.t.a), Column#5), lt(test.t.b, 10) + └─Window_10 3333.33 root avg(cast(test.t.b, decimal(65,4) BINARY))->Column#5 over(partition by test.t.a) + └─Sort_14 3333.33 root test.t.a:asc + └─TableReader_13 3333.33 root data:Selection_12 + └─Selection_12 3333.33 cop[tikv] gt(test.t.a, 10) + └─TableFullScan_11 10000.00 cop[tikv] table:t keep order:false, stats:pseudo drop table if exists t; create table t(a int, b int); explain format="dot" select * from t where a < 2; diff --git a/cmd/explaintest/r/explain_easy_stats.result b/cmd/explaintest/r/explain_easy_stats.result index bcc53cd7e2536..5a870f6ed80ae 100644 --- a/cmd/explaintest/r/explain_easy_stats.result +++ b/cmd/explaintest/r/explain_easy_stats.result @@ -13,130 +13,129 @@ set @@session.tidb_opt_insubq_to_join_and_agg=1; set @@session.tidb_hashagg_partial_concurrency = 1; set @@session.tidb_hashagg_final_concurrency = 1; explain select * from t3 where exists (select s.a from t3 s having sum(s.a) = t3.a ); -id estRows task operator info -HashLeftJoin_12 1600.00 root semi join, equal:[eq(Column#13, Column#11)] -├─StreamAgg_27(Build) 1.00 root funcs:sum(Column#16)->Column#11 -│ └─TableReader_28 1.00 root data:StreamAgg_19 -│ └─StreamAgg_19 1.00 cop[tikv] funcs:sum(test.t3.a)->Column#16 -│ └─TableFullScan_26 2000.00 cop[tikv] table:s, keep order:false -└─Projection_13(Probe) 2000.00 root test.t3.a, test.t3.b, test.t3.c, test.t3.d, cast(test.t3.a, decimal(20,0) BINARY)->Column#13 - └─TableReader_15 2000.00 root data:TableFullScan_14 - └─TableFullScan_14 2000.00 cop[tikv] table:t3, keep order:false +id estRows task access object operator info +HashJoin_12 1600.00 root semi join, equal:[eq(Column#13, Column#11)] +├─StreamAgg_27(Build) 1.00 root funcs:sum(Column#16)->Column#11 +│ └─TableReader_28 1.00 root data:StreamAgg_19 +│ └─StreamAgg_19 1.00 cop[tikv] funcs:sum(test.t3.a)->Column#16 +│ └─TableFullScan_26 2000.00 cop[tikv] table:s keep order:false +└─Projection_13(Probe) 2000.00 root test.t3.a, test.t3.b, test.t3.c, test.t3.d, cast(test.t3.a, decimal(20,0) BINARY)->Column#13 + └─TableReader_15 2000.00 root data:TableFullScan_14 + └─TableFullScan_14 2000.00 cop[tikv] table:t3 keep order:false explain select * from t1; -id estRows task operator info -TableReader_5 1999.00 root data:TableFullScan_4 -└─TableFullScan_4 1999.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +TableReader_5 1999.00 root data:TableFullScan_4 +└─TableFullScan_4 1999.00 cop[tikv] table:t1 keep order:false explain select * from t1 order by c2; -id estRows task operator info -IndexLookUp_12 1999.00 root -├─IndexFullScan_10(Build) 1999.00 cop[tikv] table:t1, index:c2, keep order:true -└─TableRowIDScan_11(Probe) 1999.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +IndexLookUp_12 1999.00 root +├─IndexFullScan_10(Build) 1999.00 cop[tikv] table:t1, index:c2(c2) keep order:true +└─TableRowIDScan_11(Probe) 1999.00 cop[tikv] table:t1 keep order:false explain select * from t2 order by c2; -id estRows task operator info -Sort_4 1985.00 root test.t2.c2:asc -└─TableReader_8 1985.00 root data:TableFullScan_7 - └─TableFullScan_7 1985.00 cop[tikv] table:t2, keep order:false +id estRows task access object operator info +Sort_4 1985.00 root test.t2.c2:asc +└─TableReader_8 1985.00 root data:TableFullScan_7 + └─TableFullScan_7 1985.00 cop[tikv] table:t2 keep order:false explain select * from t1 where t1.c1 > 0; -id estRows task operator info -TableReader_6 1999.00 root data:TableRangeScan_5 -└─TableRangeScan_5 1999.00 cop[tikv] table:t1, range:(0,+inf], keep order:false +id estRows task access object operator info +TableReader_6 1999.00 root data:TableRangeScan_5 +└─TableRangeScan_5 1999.00 cop[tikv] table:t1 range:(0,+inf], keep order:false explain select t1.c1, t1.c2 from t1 where t1.c2 = 1; -id estRows task operator info -IndexReader_6 0.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 0.00 cop[tikv] table:t1, index:c2, range:[1,1], keep order:false +id estRows task access object operator info +IndexReader_6 0.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 0.00 cop[tikv] table:t1, index:c2(c2) range:[1,1], keep order:false explain select * from t1 left join t2 on t1.c2 = t2.c1 where t1.c1 > 1; -id estRows task operator info -HashLeftJoin_22 2481.25 root left outer join, equal:[eq(test.t1.c2, test.t2.c1)] -├─TableReader_36(Build) 1985.00 root data:Selection_35 -│ └─Selection_35 1985.00 cop[tikv] not(isnull(test.t2.c1)) -│ └─TableFullScan_34 1985.00 cop[tikv] table:t2, keep order:false -└─TableReader_33(Probe) 1998.00 root data:TableRangeScan_32 - └─TableRangeScan_32 1998.00 cop[tikv] table:t1, range:(1,+inf], keep order:false +id estRows task access object operator info +HashJoin_22 2481.25 root left outer join, equal:[eq(test.t1.c2, test.t2.c1)] +├─TableReader_36(Build) 1985.00 root data:Selection_35 +│ └─Selection_35 1985.00 cop[tikv] not(isnull(test.t2.c1)) +│ └─TableFullScan_34 1985.00 cop[tikv] table:t2 keep order:false +└─TableReader_33(Probe) 1998.00 root data:TableRangeScan_32 + └─TableRangeScan_32 1998.00 cop[tikv] table:t1 range:(1,+inf], keep order:false explain update t1 set t1.c2 = 2 where t1.c1 = 1; -id estRows task operator info -Update_2 N/A root N/A -└─Point_Get_1 1.00 root table:t1, handle:1 +id estRows task access object operator info +Update_2 N/A root N/A +└─Point_Get_1 1.00 root table:t1 handle:1 explain delete from t1 where t1.c2 = 1; -id estRows task operator info -Delete_5 N/A root N/A -└─SelectLock_7 0.00 root for update - └─IndexLookUp_13 0.00 root - ├─IndexRangeScan_11(Build) 0.00 cop[tikv] table:t1, index:c2, range:[1,1], keep order:false - └─TableRowIDScan_12(Probe) 0.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +Delete_4 N/A root N/A +└─IndexLookUp_11 0.00 root + ├─IndexRangeScan_9(Build) 0.00 cop[tikv] table:t1, index:c2(c2) range:[1,1], keep order:false + └─TableRowIDScan_10(Probe) 0.00 cop[tikv] table:t1 keep order:false explain select count(b.c2) from t1 a, t2 b where a.c1 = b.c2 group by a.c1; -id estRows task operator info -Projection_11 1985.00 root cast(Column#8, bigint(21) BINARY)->Column#7 -└─HashLeftJoin_21 1985.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] - ├─HashAgg_25(Build) 1985.00 root group by:test.t2.c2, funcs:count(test.t2.c2)->Column#8, funcs:firstrow(test.t2.c2)->test.t2.c2 - │ └─TableReader_32 1985.00 root data:Selection_31 - │ └─Selection_31 1985.00 cop[tikv] not(isnull(test.t2.c2)) - │ └─TableFullScan_30 1985.00 cop[tikv] table:b, keep order:false - └─TableReader_34(Probe) 1999.00 root data:TableFullScan_33 - └─TableFullScan_33 1999.00 cop[tikv] table:a, keep order:false +id estRows task access object operator info +Projection_11 1985.00 root cast(Column#8, bigint(21) BINARY)->Column#7 +└─HashJoin_21 1985.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] + ├─HashAgg_25(Build) 1985.00 root group by:test.t2.c2, funcs:count(test.t2.c2)->Column#8, funcs:firstrow(test.t2.c2)->test.t2.c2 + │ └─TableReader_32 1985.00 root data:Selection_31 + │ └─Selection_31 1985.00 cop[tikv] not(isnull(test.t2.c2)) + │ └─TableFullScan_30 1985.00 cop[tikv] table:b keep order:false + └─TableReader_34(Probe) 1999.00 root data:TableFullScan_33 + └─TableFullScan_33 1999.00 cop[tikv] table:a keep order:false explain select * from t2 order by t2.c2 limit 0, 1; -id estRows task operator info -TopN_7 1.00 root test.t2.c2:asc, offset:0, count:1 -└─TableReader_15 1.00 root data:TopN_14 - └─TopN_14 1.00 cop[tikv] test.t2.c2:asc, offset:0, count:1 - └─TableFullScan_13 1985.00 cop[tikv] table:t2, keep order:false +id estRows task access object operator info +TopN_7 1.00 root test.t2.c2:asc, offset:0, count:1 +└─TableReader_15 1.00 root data:TopN_14 + └─TopN_14 1.00 cop[tikv] test.t2.c2:asc, offset:0, count:1 + └─TableFullScan_13 1985.00 cop[tikv] table:t2 keep order:false explain select * from t1 where c1 > 1 and c2 = 1 and c3 < 1; -id estRows task operator info -IndexLookUp_11 0.00 root -├─IndexRangeScan_8(Build) 0.00 cop[tikv] table:t1, index:c2, range:(1 1,1 +inf], keep order:false -└─Selection_10(Probe) 0.00 cop[tikv] lt(test.t1.c3, 1) - └─TableRowIDScan_9 0.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +IndexLookUp_11 0.00 root +├─IndexRangeScan_8(Build) 0.00 cop[tikv] table:t1, index:c2(c2) range:(1 1,1 +inf], keep order:false +└─Selection_10(Probe) 0.00 cop[tikv] lt(test.t1.c3, 1) + └─TableRowIDScan_9 0.00 cop[tikv] table:t1 keep order:false explain select * from t1 where c1 = 1 and c2 > 1; -id estRows task operator info -Selection_6 0.50 root gt(test.t1.c2, 1) -└─Point_Get_5 1.00 root table:t1, handle:1 +id estRows task access object operator info +Selection_6 0.50 root gt(test.t1.c2, 1) +└─Point_Get_5 1.00 root table:t1 handle:1 explain select c1 from t1 where c1 in (select c2 from t2); -id estRows task operator info -HashLeftJoin_19 1985.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] -├─HashAgg_23(Build) 1985.00 root group by:test.t2.c2, funcs:firstrow(test.t2.c2)->test.t2.c2 -│ └─TableReader_30 1985.00 root data:Selection_29 -│ └─Selection_29 1985.00 cop[tikv] not(isnull(test.t2.c2)) -│ └─TableFullScan_28 1985.00 cop[tikv] table:t2, keep order:false -└─TableReader_32(Probe) 1999.00 root data:TableFullScan_31 - └─TableFullScan_31 1999.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +HashJoin_19 1985.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] +├─HashAgg_23(Build) 1985.00 root group by:test.t2.c2, funcs:firstrow(test.t2.c2)->test.t2.c2 +│ └─TableReader_30 1985.00 root data:Selection_29 +│ └─Selection_29 1985.00 cop[tikv] not(isnull(test.t2.c2)) +│ └─TableFullScan_28 1985.00 cop[tikv] table:t2 keep order:false +└─TableReader_32(Probe) 1999.00 root data:TableFullScan_31 + └─TableFullScan_31 1999.00 cop[tikv] table:t1 keep order:false explain select * from information_schema.columns; -id estRows task operator info -MemTableScan_4 10000.00 root table:COLUMNS +id estRows task access object operator info +MemTableScan_4 10000.00 root table:COLUMNS explain select c2 = (select c2 from t2 where t1.c1 = t2.c1 order by c1 limit 1) from t1; -id estRows task operator info -Projection_12 1999.00 root eq(test.t1.c2, test.t2.c2)->Column#8 -└─Apply_14 1999.00 root CARTESIAN left outer join - ├─TableReader_16(Build) 1999.00 root data:TableFullScan_15 - │ └─TableFullScan_15 1999.00 cop[tikv] table:t1, keep order:false - └─Projection_43(Probe) 1.00 root test.t2.c1, test.t2.c2 - └─IndexLookUp_42 1.00 root limit embedded(offset:0, count:1) - ├─Limit_41(Build) 1.00 cop[tikv] offset:0, count:1 - │ └─IndexRangeScan_39 1.25 cop[tikv] table:t2, index:c1, range: decided by [eq(test.t1.c1, test.t2.c1)], keep order:true - └─TableRowIDScan_40(Probe) 1.00 cop[tikv] table:t2, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_12 1999.00 root eq(test.t1.c2, test.t2.c2)->Column#8 +└─Apply_14 1999.00 root CARTESIAN left outer join + ├─TableReader_16(Build) 1999.00 root data:TableFullScan_15 + │ └─TableFullScan_15 1999.00 cop[tikv] table:t1 keep order:false + └─Projection_43(Probe) 1.00 root test.t2.c1, test.t2.c2 + └─IndexLookUp_42 1.00 root limit embedded(offset:0, count:1) + ├─Limit_41(Build) 1.00 cop[tikv] offset:0, count:1 + │ └─IndexRangeScan_39 1.25 cop[tikv] table:t2, index:c1(c1) range: decided by [eq(test.t1.c1, test.t2.c1)], keep order:true + └─TableRowIDScan_40(Probe) 1.00 cop[tikv] table:t2 keep order:false, stats:pseudo explain select * from t1 order by c1 desc limit 1; -id estRows task operator info -Limit_10 1.00 root offset:0, count:1 -└─TableReader_20 1.00 root data:Limit_19 - └─Limit_19 1.00 cop[tikv] offset:0, count:1 - └─TableFullScan_18 1.00 cop[tikv] table:t1, keep order:true, desc +id estRows task access object operator info +Limit_10 1.00 root offset:0, count:1 +└─TableReader_20 1.00 root data:Limit_19 + └─Limit_19 1.00 cop[tikv] offset:0, count:1 + └─TableFullScan_18 1.00 cop[tikv] table:t1 keep order:true, desc set @@session.tidb_opt_insubq_to_join_and_agg=0; explain select 1 in (select c2 from t2) from t1; -id estRows task operator info -HashLeftJoin_7 1999.00 root CARTESIAN left outer semi join -├─TableReader_14(Build) 0.00 root data:Selection_13 -│ └─Selection_13 0.00 cop[tikv] eq(1, test.t2.c2) -│ └─TableFullScan_12 1985.00 cop[tikv] table:t2, keep order:false -└─TableReader_9(Probe) 1999.00 root data:TableFullScan_8 - └─TableFullScan_8 1999.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +HashJoin_7 1999.00 root CARTESIAN left outer semi join +├─TableReader_14(Build) 0.00 root data:Selection_13 +│ └─Selection_13 0.00 cop[tikv] eq(1, test.t2.c2) +│ └─TableFullScan_12 1985.00 cop[tikv] table:t2 keep order:false +└─TableReader_9(Probe) 1999.00 root data:TableFullScan_8 + └─TableFullScan_8 1999.00 cop[tikv] table:t1 keep order:false explain format="dot" select 1 in (select c2 from t2) from t1; dot contents -digraph HashLeftJoin_7 { +digraph HashJoin_7 { subgraph cluster7{ node [style=filled, color=lightgrey] color=black label = "root" -"HashLeftJoin_7" -> "TableReader_9" -"HashLeftJoin_7" -> "TableReader_14" +"HashJoin_7" -> "TableReader_9" +"HashJoin_7" -> "TableReader_14" } subgraph cluster8{ node [style=filled, color=lightgrey] @@ -155,37 +154,37 @@ label = "cop" } explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 LIMIT 1; -id estRows task operator info -Point_Get_1 1.00 root table:index_prune, index:a b +id estRows task access object operator info +Point_Get_1 1.00 root table:index_prune, index:PRIMARY(a, b) explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 LIMIT 0; -id estRows task operator info -TableDual_5 0.00 root rows:0 +id estRows task access object operator info +TableDual_5 0.00 root rows:0 explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 LIMIT 1, 1; -id estRows task operator info -Limit_9 1.00 root offset:1, count:1 -└─Point_Get_11 1.00 root table:index_prune, index:a b +id estRows task access object operator info +Limit_9 1.00 root offset:1, count:1 +└─Point_Get_11 1.00 root table:index_prune, index:PRIMARY(a, b) explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 LIMIT 1, 0; -id estRows task operator info -Limit_9 0.00 root offset:1, count:0 -└─Point_Get_11 1.00 root table:index_prune, index:a b +id estRows task access object operator info +Limit_9 0.00 root offset:1, count:0 +└─Point_Get_11 1.00 root table:index_prune, index:PRIMARY(a, b) explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 LIMIT 0, 1; -id estRows task operator info -Point_Get_1 1.00 root table:index_prune, index:a b +id estRows task access object operator info +Point_Get_1 1.00 root table:index_prune, index:PRIMARY(a, b) explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 ORDER BY a; -id estRows task operator info -Point_Get_1 1.00 root table:index_prune, index:a b +id estRows task access object operator info +Point_Get_1 1.00 root table:index_prune, index:PRIMARY(a, b) explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 GROUP BY b; -id estRows task operator info -Point_Get_1 1.00 root table:index_prune, index:a b +id estRows task access object operator info +Point_Get_1 1.00 root table:index_prune, index:PRIMARY(a, b) explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 GROUP BY b ORDER BY a limit 1; -id estRows task operator info -Point_Get_1 1.00 root table:index_prune, index:a b +id estRows task access object operator info +Point_Get_1 1.00 root table:index_prune, index:PRIMARY(a, b) drop table if exists t1, t2, t3, index_prune; set @@session.tidb_opt_insubq_to_join_and_agg=1; drop table if exists tbl; create table tbl(column1 int, column2 int, index idx(column1, column2)); load stats 's/explain_easy_stats_tbl_dnf.json'; explain select * from tbl where (column1=0 and column2=1) or (column1=1 and column2=3) or (column1=2 and column2=5); -id estRows task operator info -IndexReader_6 3.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 3.00 cop[tikv] table:tbl, index:column1, column2, range:[0 1,0 1], [1 3,1 3], [2 5,2 5], keep order:false +id estRows task access object operator info +IndexReader_6 3.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 3.00 cop[tikv] table:tbl, index:idx(column1, column2) range:[0 1,0 1], [1 3,1 3], [2 5,2 5], keep order:false diff --git a/cmd/explaintest/r/explain_generate_column_substitute.result b/cmd/explaintest/r/explain_generate_column_substitute.result index b4d26bb35c954..bd32f690d888b 100644 --- a/cmd/explaintest/r/explain_generate_column_substitute.result +++ b/cmd/explaintest/r/explain_generate_column_substitute.result @@ -7,53 +7,53 @@ alter table t add index idx_c(c); alter table t add index idx_e(e); set @@sql_mode="" desc select * from t where a+1=3; -id estRows task operator info -IndexLookUp_10 10.00 root -├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:c, range:[3,3], keep order:false, stats:pseudo -└─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +IndexLookUp_10 10.00 root +├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:idx_c(c) range:[3,3], keep order:false, stats:pseudo +└─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t where a+1=3; a b c e 2 2.1 3 4.1 desc select a+1 from t where a+1=3; -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:c, range:[3,3], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:idx_c(c) range:[3,3], keep order:false, stats:pseudo select a+1 from t where a+1=3; a+1 3 desc select c from t where a+1=3; -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:c, range:[3,3], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:idx_c(c) range:[3,3], keep order:false, stats:pseudo select c from t where a+1=3; c 3 desc select * from t where b+a=3; -id estRows task operator info -IndexLookUp_10 10.00 root -├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:e, range:[3,3], keep order:false, stats:pseudo -└─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +IndexLookUp_10 10.00 root +├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:idx_e(e) range:[3,3], keep order:false, stats:pseudo +└─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t where b+a=3; a b c e 1 2 2 3 desc select b+a from t where b+a=3; -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:e, range:[3,3], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:idx_e(e) range:[3,3], keep order:false, stats:pseudo select b+a from t where b+a=3; b+a 3 desc select e from t where b+a=3; -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:e, range:[3,3], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:idx_e(e) range:[3,3], keep order:false, stats:pseudo select e from t where b+a=3; e 3 desc select a+1 from t where a+1 in (1, 2, 3); -id estRows task operator info -IndexReader_6 30.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 30.00 cop[tikv] table:t, index:c, range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 30.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 30.00 cop[tikv] table:t, index:idx_c(c) range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo select a+1 from t where a+1 in (1, 2, 3); a+1 1 @@ -61,10 +61,10 @@ a+1 2 3 desc select * from t where a+1 in (1, 2, 3); -id estRows task operator info -IndexLookUp_10 30.00 root -├─IndexRangeScan_8(Build) 30.00 cop[tikv] table:t, index:c, range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo -└─TableRowIDScan_9(Probe) 30.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +IndexLookUp_10 30.00 root +├─IndexRangeScan_8(Build) 30.00 cop[tikv] table:t, index:idx_c(c) range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo +└─TableRowIDScan_9(Probe) 30.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t where a+1 in (1, 2, 3); a b c e 1 2 2 3 @@ -72,9 +72,9 @@ a b c e 0 0 1 0 0 0 1 0 desc select a+1 from t where a+1 between 1 and 4; -id estRows task operator info -IndexReader_6 250.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 250.00 cop[tikv] table:t, index:c, range:[1,4], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 250.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 250.00 cop[tikv] table:t, index:idx_c(c) range:[1,4], keep order:false, stats:pseudo select a+1 from t where a+1 between 1 and 4; a+1 1 @@ -82,10 +82,10 @@ a+1 2 3 desc select * from t where a+1 between 1 and 4; -id estRows task operator info -IndexLookUp_10 250.00 root -├─IndexRangeScan_8(Build) 250.00 cop[tikv] table:t, index:c, range:[1,4], keep order:false, stats:pseudo -└─TableRowIDScan_9(Probe) 250.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +IndexLookUp_10 250.00 root +├─IndexRangeScan_8(Build) 250.00 cop[tikv] table:t, index:idx_c(c) range:[1,4], keep order:false, stats:pseudo +└─TableRowIDScan_9(Probe) 250.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t where a+1 between 1 and 4; a b c e 1 2 2 3 @@ -93,11 +93,11 @@ a b c e 0 0 1 0 0 0 1 0 desc select * from t order by a+1; -id estRows task operator info -Projection_13 10000.00 root test.t.a, test.t.b, test.t.c, test.t.e -└─IndexLookUp_12 10000.00 root - ├─IndexFullScan_10(Build) 10000.00 cop[tikv] table:t, index:c, keep order:true, stats:pseudo - └─TableRowIDScan_11(Probe) 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_13 10000.00 root test.t.a, test.t.b, test.t.c, test.t.e +└─IndexLookUp_12 10000.00 root + ├─IndexFullScan_10(Build) 10000.00 cop[tikv] table:t, index:idx_c(c) keep order:true, stats:pseudo + └─TableRowIDScan_11(Probe) 10000.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t order by a+1; a b c e -1 -2 0 -3 @@ -108,9 +108,9 @@ a b c e 5 3 6 8 5 -1 6 4 desc select a+1 from t order by a+1; -id estRows task operator info -IndexReader_13 10000.00 root index:IndexFullScan_12 -└─IndexFullScan_12 10000.00 cop[tikv] table:t, index:c, keep order:true, stats:pseudo +id estRows task access object operator info +IndexReader_13 10000.00 root index:IndexFullScan_12 +└─IndexFullScan_12 10000.00 cop[tikv] table:t, index:idx_c(c) keep order:true, stats:pseudo select a+1 from t order by a+1; a+1 0 @@ -121,9 +121,9 @@ a+1 6 6 desc select b+a from t order by b+a; -id estRows task operator info -IndexReader_13 10000.00 root index:IndexFullScan_12 -└─IndexFullScan_12 10000.00 cop[tikv] table:t, index:e, keep order:true, stats:pseudo +id estRows task access object operator info +IndexReader_13 10000.00 root index:IndexFullScan_12 +└─IndexFullScan_12 10000.00 cop[tikv] table:t, index:idx_e(e) keep order:true, stats:pseudo select b+a from t order by b+a; b+a -3 @@ -134,33 +134,29 @@ b+a 4.1 8 desc update t set a=1 where a+1 = 3; -id estRows task operator info -Update_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─IndexLookUp_13 10.00 root - ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, index:c, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_12(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Update_4 N/A root N/A +└─IndexLookUp_11 10.00 root + ├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t, index:idx_c(c) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo desc update t set a=2, b = 3 where b+a = 3; -id estRows task operator info -Update_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─IndexLookUp_13 10.00 root - ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, index:e, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_12(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Update_4 N/A root N/A +└─IndexLookUp_11 10.00 root + ├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t, index:idx_e(e) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo desc delete from t where a+1 = 3; -id estRows task operator info -Delete_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─IndexLookUp_13 10.00 root - ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, index:c, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_12(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Delete_4 N/A root N/A +└─IndexLookUp_11 10.00 root + ├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t, index:idx_c(c) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo desc delete from t where b+a = 0; -id estRows task operator info -Delete_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─IndexLookUp_13 10.00 root - ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, index:e, range:[0,0], keep order:false, stats:pseudo - └─TableRowIDScan_12(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Delete_4 N/A root N/A +└─IndexLookUp_11 10.00 root + ├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t, index:idx_e(e) range:[0,0], keep order:false, stats:pseudo + └─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo alter table t drop index idx_c; alter table t drop index idx_e; alter table t add index expr_idx_c((a+1)); @@ -169,59 +165,59 @@ truncate table t; insert into t values (1, 2.0, default, default), (2, 2.1, default, default), (5, 3.0, default, default), (5, -1.0, default, default), (0, 0.0, default, default), (-1, -2.0, default, default), (0, 0, default, default); desc select * from t where a+1=3; -id estRows task operator info -Projection_4 10.00 root test.t.a, test.t.b, test.t.c, test.t.e -└─IndexLookUp_10 10.00 root - ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 10.00 root test.t.a, test.t.b, test.t.c, test.t.e +└─IndexLookUp_10 10.00 root + ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t where a+1=3; a b c e 2 2.1 3 4.1 desc select a+1 from t where a+1=3; -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, range:[3,3], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) range:[3,3], keep order:false, stats:pseudo select a+1 from t where a+1=3; a+1 3 desc select c from t where a+1=3; -id estRows task operator info -Projection_4 10.00 root test.t.c -└─IndexLookUp_10 10.00 root - ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 10.00 root test.t.c +└─IndexLookUp_10 10.00 root + ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo select c from t where a+1=3; c 3 desc select * from t where b+a=3; -id estRows task operator info -Projection_4 10.00 root test.t.a, test.t.b, test.t.c, test.t.e -└─IndexLookUp_10 10.00 root - ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:_V$_expr_idx_e_0, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 10.00 root test.t.a, test.t.b, test.t.c, test.t.e +└─IndexLookUp_10 10.00 root + ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:expr_idx_e(_V$_expr_idx_e_0) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t where b+a=3; a b c e 1 2 2 3 desc select b+a from t where b+a=3; -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:_V$_expr_idx_e_0, range:[3,3], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t, index:expr_idx_e(_V$_expr_idx_e_0) range:[3,3], keep order:false, stats:pseudo select b+a from t where b+a=3; b+a 3 desc select e from t where b+a=3; -id estRows task operator info -Projection_4 10.00 root test.t.e -└─IndexLookUp_10 10.00 root - ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:_V$_expr_idx_e_0, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 10.00 root test.t.e +└─IndexLookUp_10 10.00 root + ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t, index:expr_idx_e(_V$_expr_idx_e_0) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo select e from t where b+a=3; e 3 desc select a+1 from t where a+1 in (1, 2, 3); -id estRows task operator info -IndexReader_6 30.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 30.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 30.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 30.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo select a+1 from t where a+1 in (1, 2, 3); a+1 1 @@ -229,11 +225,11 @@ a+1 2 3 desc select * from t where a+1 in (1, 2, 3); -id estRows task operator info -Projection_4 30.00 root test.t.a, test.t.b, test.t.c, test.t.e -└─IndexLookUp_10 30.00 root - ├─IndexRangeScan_8(Build) 30.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo - └─TableRowIDScan_9(Probe) 30.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 30.00 root test.t.a, test.t.b, test.t.c, test.t.e +└─IndexLookUp_10 30.00 root + ├─IndexRangeScan_8(Build) 30.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo + └─TableRowIDScan_9(Probe) 30.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t where a+1 in (1, 2, 3); a b c e 1 2 2 3 @@ -241,9 +237,9 @@ a b c e 0 0 1 0 0 0 1 0 desc select a+1 from t where a+1 between 1 and 4; -id estRows task operator info -IndexReader_6 250.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 250.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, range:[1,4], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 250.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 250.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) range:[1,4], keep order:false, stats:pseudo select a+1 from t where a+1 between 1 and 4; a+1 1 @@ -251,11 +247,11 @@ a+1 2 3 desc select * from t where a+1 between 1 and 4; -id estRows task operator info -Projection_4 250.00 root test.t.a, test.t.b, test.t.c, test.t.e -└─IndexLookUp_10 250.00 root - ├─IndexRangeScan_8(Build) 250.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, range:[1,4], keep order:false, stats:pseudo - └─TableRowIDScan_9(Probe) 250.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 250.00 root test.t.a, test.t.b, test.t.c, test.t.e +└─IndexLookUp_10 250.00 root + ├─IndexRangeScan_8(Build) 250.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) range:[1,4], keep order:false, stats:pseudo + └─TableRowIDScan_9(Probe) 250.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t where a+1 between 1 and 4; a b c e 1 2 2 3 @@ -263,12 +259,12 @@ a b c e 0 0 1 0 0 0 1 0 desc select * from t order by a+1; -id estRows task operator info -Projection_5 10000.00 root test.t.a, test.t.b, test.t.c, test.t.e -└─Projection_13 10000.00 root test.t.a, test.t.b, test.t.c, test.t.e, EMPTY_NAME - └─IndexLookUp_12 10000.00 root - ├─IndexFullScan_10(Build) 10000.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, keep order:true, stats:pseudo - └─TableRowIDScan_11(Probe) 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_5 10000.00 root test.t.a, test.t.b, test.t.c, test.t.e +└─Projection_13 10000.00 root test.t.a, test.t.b, test.t.c, test.t.e, EMPTY_NAME + └─IndexLookUp_12 10000.00 root + ├─IndexFullScan_10(Build) 10000.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) keep order:true, stats:pseudo + └─TableRowIDScan_11(Probe) 10000.00 cop[tikv] table:t keep order:false, stats:pseudo select * from t order by a+1; a b c e -1 -2 0 -3 @@ -279,9 +275,9 @@ a b c e 5 3 6 8 5 -1 6 4 desc select a+1 from t order by a+1; -id estRows task operator info -IndexReader_13 10000.00 root index:IndexFullScan_12 -└─IndexFullScan_12 10000.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, keep order:true, stats:pseudo +id estRows task access object operator info +IndexReader_13 10000.00 root index:IndexFullScan_12 +└─IndexFullScan_12 10000.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) keep order:true, stats:pseudo select a+1 from t order by a+1; a+1 0 @@ -292,9 +288,9 @@ a+1 6 6 desc select b+a from t order by b+a; -id estRows task operator info -IndexReader_13 10000.00 root index:IndexFullScan_12 -└─IndexFullScan_12 10000.00 cop[tikv] table:t, index:_V$_expr_idx_e_0, keep order:true, stats:pseudo +id estRows task access object operator info +IndexReader_13 10000.00 root index:IndexFullScan_12 +└─IndexFullScan_12 10000.00 cop[tikv] table:t, index:expr_idx_e(_V$_expr_idx_e_0) keep order:true, stats:pseudo select b+a from t order by b+a; b+a -3 @@ -305,30 +301,26 @@ b+a 4.1 8 desc update t set a=1 where a+1 = 3; -id estRows task operator info -Update_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─IndexLookUp_13 10.00 root - ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_12(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Update_4 N/A root N/A +└─IndexLookUp_11 10.00 root + ├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo desc update t set a=2, b = 3 where b+a = 3; -id estRows task operator info -Update_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─IndexLookUp_13 10.00 root - ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, index:_V$_expr_idx_e_0, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_12(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Update_4 N/A root N/A +└─IndexLookUp_11 10.00 root + ├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t, index:expr_idx_e(_V$_expr_idx_e_0) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo desc delete from t where a+1 = 3; -id estRows task operator info -Delete_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─IndexLookUp_13 10.00 root - ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, index:_V$_expr_idx_c_0, range:[3,3], keep order:false, stats:pseudo - └─TableRowIDScan_12(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Delete_4 N/A root N/A +└─IndexLookUp_11 10.00 root + ├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t, index:expr_idx_c(_V$_expr_idx_c_0) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo desc delete from t where b+a = 0; -id estRows task operator info -Delete_5 N/A root N/A -└─SelectLock_7 10.00 root for update - └─IndexLookUp_13 10.00 root - ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, index:_V$_expr_idx_e_0, range:[0,0], keep order:false, stats:pseudo - └─TableRowIDScan_12(Probe) 10.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Delete_4 N/A root N/A +└─IndexLookUp_11 10.00 root + ├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t, index:expr_idx_e(_V$_expr_idx_e_0) range:[0,0], keep order:false, stats:pseudo + └─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/explain_indexmerge.result b/cmd/explaintest/r/explain_indexmerge.result index b88c7c54c3b59..8282b615c6038 100644 --- a/cmd/explaintest/r/explain_indexmerge.result +++ b/cmd/explaintest/r/explain_indexmerge.result @@ -5,64 +5,64 @@ create index tc on t (c); create index td on t (d); load stats 's/explain_indexmerge_stats_t.json'; explain select * from t where a < 50 or b < 50; -id estRows task operator info -TableReader_7 4000000.00 root data:Selection_6 -└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.a, 50), lt(test.t.b, 50)) - └─TableFullScan_5 5000000.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 4000000.00 root data:Selection_6 +└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.a, 50), lt(test.t.b, 50)) + └─TableFullScan_5 5000000.00 cop[tikv] table:t keep order:false explain select * from t where (a < 50 or b < 50) and f > 100; -id estRows task operator info -TableReader_7 4000000.00 root data:Selection_6 -└─Selection_6 4000000.00 cop[tikv] gt(test.t.f, 100), or(lt(test.t.a, 50), lt(test.t.b, 50)) - └─TableFullScan_5 5000000.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 4000000.00 root data:Selection_6 +└─Selection_6 4000000.00 cop[tikv] gt(test.t.f, 100), or(lt(test.t.a, 50), lt(test.t.b, 50)) + └─TableFullScan_5 5000000.00 cop[tikv] table:t keep order:false explain select * from t where b < 50 or c < 50; -id estRows task operator info -TableReader_7 4000000.00 root data:Selection_6 -└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.b, 50), lt(test.t.c, 50)) - └─TableFullScan_5 5000000.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 4000000.00 root data:Selection_6 +└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.b, 50), lt(test.t.c, 50)) + └─TableFullScan_5 5000000.00 cop[tikv] table:t keep order:false set session tidb_enable_index_merge = on; explain select * from t where a < 50 or b < 50; -id estRows task operator info -IndexMerge_11 98.00 root -├─TableRangeScan_8 49.00 cop[tikv] table:t, range:[-inf,50), keep order:false -├─IndexRangeScan_9 49.00 cop[tikv] table:t, index:b, range:[-inf,50), keep order:false -└─TableRowIDScan_10 98.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +IndexMerge_11 98.00 root +├─TableRangeScan_8(Build) 49.00 cop[tikv] table:t range:[-inf,50), keep order:false +├─IndexRangeScan_9(Build) 49.00 cop[tikv] table:t, index:tb(b) range:[-inf,50), keep order:false +└─TableRowIDScan_10(Probe) 98.00 cop[tikv] table:t keep order:false explain select * from t where (a < 50 or b < 50) and f > 100; -id estRows task operator info -IndexMerge_12 98.00 root -├─TableRangeScan_8 49.00 cop[tikv] table:t, range:[-inf,50), keep order:false -├─IndexRangeScan_9 49.00 cop[tikv] table:t, index:b, range:[-inf,50), keep order:false -└─Selection_11 98.00 cop[tikv] gt(test.t.f, 100) - └─TableRowIDScan_10 98.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +IndexMerge_12 98.00 root +├─TableRangeScan_8(Build) 49.00 cop[tikv] table:t range:[-inf,50), keep order:false +├─IndexRangeScan_9(Build) 49.00 cop[tikv] table:t, index:tb(b) range:[-inf,50), keep order:false +└─Selection_11(Probe) 98.00 cop[tikv] gt(test.t.f, 100) + └─TableRowIDScan_10 98.00 cop[tikv] table:t keep order:false explain select * from t where a < 50 or b < 5000000; -id estRows task operator info -TableReader_7 4000000.00 root data:Selection_6 -└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.a, 50), lt(test.t.b, 5000000)) - └─TableFullScan_5 5000000.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 4000000.00 root data:Selection_6 +└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.a, 50), lt(test.t.b, 5000000)) + └─TableFullScan_5 5000000.00 cop[tikv] table:t keep order:false explain select * from t where b < 50 or c < 50; -id estRows task operator info -IndexMerge_11 98.00 root -├─IndexRangeScan_8 49.00 cop[tikv] table:t, index:b, range:[-inf,50), keep order:false -├─IndexRangeScan_9 49.00 cop[tikv] table:t, index:c, range:[-inf,50), keep order:false -└─TableRowIDScan_10 98.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +IndexMerge_11 98.00 root +├─IndexRangeScan_8(Build) 49.00 cop[tikv] table:t, index:tb(b) range:[-inf,50), keep order:false +├─IndexRangeScan_9(Build) 49.00 cop[tikv] table:t, index:tc(c) range:[-inf,50), keep order:false +└─TableRowIDScan_10(Probe) 98.00 cop[tikv] table:t keep order:false explain select * from t where b < 50 or c < 5000000; -id estRows task operator info -TableReader_7 4000000.00 root data:Selection_6 -└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.b, 50), lt(test.t.c, 5000000)) - └─TableFullScan_5 5000000.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 4000000.00 root data:Selection_6 +└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.b, 50), lt(test.t.c, 5000000)) + └─TableFullScan_5 5000000.00 cop[tikv] table:t keep order:false explain select * from t where a < 50 or b < 50 or c < 50; -id estRows task operator info -IndexMerge_12 147.00 root -├─TableRangeScan_8 49.00 cop[tikv] table:t, range:[-inf,50), keep order:false -├─IndexRangeScan_9 49.00 cop[tikv] table:t, index:b, range:[-inf,50), keep order:false -├─IndexRangeScan_10 49.00 cop[tikv] table:t, index:c, range:[-inf,50), keep order:false -└─TableRowIDScan_11 147.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +IndexMerge_12 147.00 root +├─TableRangeScan_8(Build) 49.00 cop[tikv] table:t range:[-inf,50), keep order:false +├─IndexRangeScan_9(Build) 49.00 cop[tikv] table:t, index:tb(b) range:[-inf,50), keep order:false +├─IndexRangeScan_10(Build) 49.00 cop[tikv] table:t, index:tc(c) range:[-inf,50), keep order:false +└─TableRowIDScan_11(Probe) 147.00 cop[tikv] table:t keep order:false explain select * from t where (b < 10000 or c < 10000) and (a < 10 or d < 10) and f < 10; -id estRows task operator info -IndexMerge_17 0.00 root -├─TableRangeScan_13 9.00 cop[tikv] table:t, range:[-inf,10), keep order:false -├─IndexRangeScan_14 9.00 cop[tikv] table:t, index:d, range:[-inf,10), keep order:false -└─Selection_16 0.00 cop[tikv] lt(test.t.f, 10), or(lt(test.t.b, 10000), lt(test.t.c, 10000)) - └─TableRowIDScan_15 18.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +IndexMerge_17 0.00 root +├─TableRangeScan_13(Build) 9.00 cop[tikv] table:t range:[-inf,10), keep order:false +├─IndexRangeScan_14(Build) 9.00 cop[tikv] table:t, index:td(d) range:[-inf,10), keep order:false +└─Selection_16(Probe) 0.00 cop[tikv] lt(test.t.f, 10), or(lt(test.t.b, 10000), lt(test.t.c, 10000)) + └─TableRowIDScan_15 18.00 cop[tikv] table:t keep order:false explain format="dot" select * from t where (a < 50 or b < 50) and f > 100; dot contents @@ -98,31 +98,31 @@ label = "cop" set session tidb_enable_index_merge = off; explain select /*+ use_index_merge(t, tb, tc) */ * from t where b < 50 or c < 5000000; -id estRows task operator info -IndexMerge_8 5000000.00 root -├─IndexRangeScan_5 49.00 cop[tikv] table:t, index:b, range:[-inf,50), keep order:false -├─IndexRangeScan_6 4999999.00 cop[tikv] table:t, index:c, range:[-inf,5000000), keep order:false -└─TableRowIDScan_7 5000000.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +IndexMerge_8 5000000.00 root +├─IndexRangeScan_5(Build) 49.00 cop[tikv] table:t, index:tb(b) range:[-inf,50), keep order:false +├─IndexRangeScan_6(Build) 4999999.00 cop[tikv] table:t, index:tc(c) range:[-inf,5000000), keep order:false +└─TableRowIDScan_7(Probe) 5000000.00 cop[tikv] table:t keep order:false explain select /*+ use_index_merge(t, tb, tc) */ * from t where (b < 10000 or c < 10000) and (a < 10 or d < 10) and f < 10; -id estRows task operator info -IndexMerge_9 0.00 root -├─IndexRangeScan_5 9999.00 cop[tikv] table:t, index:b, range:[-inf,10000), keep order:false -├─IndexRangeScan_6 9999.00 cop[tikv] table:t, index:c, range:[-inf,10000), keep order:false -└─Selection_8 0.00 cop[tikv] lt(test.t.f, 10), or(lt(test.t.a, 10), lt(test.t.d, 10)) - └─TableRowIDScan_7 19998.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +IndexMerge_9 0.00 root +├─IndexRangeScan_5(Build) 9999.00 cop[tikv] table:t, index:tb(b) range:[-inf,10000), keep order:false +├─IndexRangeScan_6(Build) 9999.00 cop[tikv] table:t, index:tc(c) range:[-inf,10000), keep order:false +└─Selection_8(Probe) 0.00 cop[tikv] lt(test.t.f, 10), or(lt(test.t.a, 10), lt(test.t.d, 10)) + └─TableRowIDScan_7 19998.00 cop[tikv] table:t keep order:false explain select /*+ use_index_merge(t, tb) */ * from t where b < 50 or c < 5000000; -id estRows task operator info -TableReader_7 4000000.00 root data:Selection_6 -└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.b, 50), lt(test.t.c, 5000000)) - └─TableFullScan_5 5000000.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 4000000.00 root data:Selection_6 +└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.b, 50), lt(test.t.c, 5000000)) + └─TableFullScan_5 5000000.00 cop[tikv] table:t keep order:false explain select /*+ no_index_merge(), use_index_merge(t, tb, tc) */ * from t where b < 50 or c < 5000000; -id estRows task operator info -TableReader_7 4000000.00 root data:Selection_6 -└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.b, 50), lt(test.t.c, 5000000)) - └─TableFullScan_5 5000000.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +TableReader_7 4000000.00 root data:Selection_6 +└─Selection_6 4000000.00 cop[tikv] or(lt(test.t.b, 50), lt(test.t.c, 5000000)) + └─TableFullScan_5 5000000.00 cop[tikv] table:t keep order:false explain select /*+ use_index_merge(t, primary, tb) */ * from t where a < 50 or b < 5000000; -id estRows task operator info -IndexMerge_8 5000000.00 root -├─TableRangeScan_5 49.00 cop[tikv] table:t, range:[-inf,50), keep order:false -├─IndexRangeScan_6 4999999.00 cop[tikv] table:t, index:b, range:[-inf,5000000), keep order:false -└─TableRowIDScan_7 5000000.00 cop[tikv] table:t, keep order:false +id estRows task access object operator info +IndexMerge_8 5000000.00 root +├─TableRangeScan_5(Build) 49.00 cop[tikv] table:t range:[-inf,50), keep order:false +├─IndexRangeScan_6(Build) 4999999.00 cop[tikv] table:t, index:tb(b) range:[-inf,5000000), keep order:false +└─TableRowIDScan_7(Probe) 5000000.00 cop[tikv] table:t keep order:false diff --git a/cmd/explaintest/r/explain_join_stats.result b/cmd/explaintest/r/explain_join_stats.result index 61b0f80135ea4..73bb6e2671ba4 100644 --- a/cmd/explaintest/r/explain_join_stats.result +++ b/cmd/explaintest/r/explain_join_stats.result @@ -5,23 +5,23 @@ load stats 's/explain_join_stats_e.json'; create table lo(a int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (a)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=30002; load stats 's/explain_join_stats_lo.json'; explain select count(*) from e, lo where lo.a=e.a and e.b=22336; -id estRows task operator info -StreamAgg_13 1.00 root funcs:count(1)->Column#5 -└─HashRightJoin_89 19977.00 root inner join, equal:[eq(test.lo.a, test.e.a)] - ├─TableReader_50(Build) 250.00 root data:TableFullScan_49 - │ └─TableFullScan_49 250.00 cop[tikv] table:lo, keep order:false - └─IndexLookUp_61(Probe) 19977.00 root - ├─IndexRangeScan_58(Build) 19977.00 cop[tikv] table:e, index:b, range:[22336,22336], keep order:false - └─Selection_60(Probe) 19977.00 cop[tikv] not(isnull(test.e.a)) - └─TableRowIDScan_59 19977.00 cop[tikv] table:e, keep order:false +id estRows task access object operator info +StreamAgg_13 1.00 root funcs:count(1)->Column#5 +└─HashJoin_89 19977.00 root inner join, equal:[eq(test.lo.a, test.e.a)] + ├─TableReader_50(Build) 250.00 root data:TableFullScan_49 + │ └─TableFullScan_49 250.00 cop[tikv] table:lo keep order:false + └─IndexLookUp_61(Probe) 19977.00 root + ├─IndexRangeScan_58(Build) 19977.00 cop[tikv] table:e, index:idx_b(b) range:[22336,22336], keep order:false + └─Selection_60(Probe) 19977.00 cop[tikv] not(isnull(test.e.a)) + └─TableRowIDScan_59 19977.00 cop[tikv] table:e keep order:false explain select /*+ TIDB_INLJ(e) */ count(*) from e, lo where lo.a=e.a and e.b=22336; -id estRows task operator info -StreamAgg_12 1.00 root funcs:count(1)->Column#5 -└─IndexJoin_56 19977.00 root inner join, inner:IndexLookUp_55, outer key:test.lo.a, inner key:test.e.a - ├─TableReader_40(Build) 250.00 root data:TableFullScan_39 - │ └─TableFullScan_39 250.00 cop[tikv] table:lo, keep order:false - └─IndexLookUp_55(Probe) 79.91 root - ├─Selection_53(Build) 4080.00 cop[tikv] not(isnull(test.e.a)) - │ └─IndexRangeScan_51 4080.00 cop[tikv] table:e, index:a, range: decided by [eq(test.e.a, test.lo.a)], keep order:false - └─Selection_54(Probe) 79.91 cop[tikv] eq(test.e.b, 22336) - └─TableRowIDScan_52 4080.00 cop[tikv] table:e, keep order:false +id estRows task access object operator info +StreamAgg_12 1.00 root funcs:count(1)->Column#5 +└─IndexJoin_56 19977.00 root inner join, inner:IndexLookUp_55, outer key:test.lo.a, inner key:test.e.a + ├─TableReader_40(Build) 250.00 root data:TableFullScan_39 + │ └─TableFullScan_39 250.00 cop[tikv] table:lo keep order:false + └─IndexLookUp_55(Probe) 79.91 root + ├─Selection_53(Build) 4080.00 cop[tikv] not(isnull(test.e.a)) + │ └─IndexRangeScan_51 4080.00 cop[tikv] table:e, index:idx_a(a) range: decided by [eq(test.e.a, test.lo.a)], keep order:false + └─Selection_54(Probe) 79.91 cop[tikv] eq(test.e.b, 22336) + └─TableRowIDScan_52 4080.00 cop[tikv] table:e keep order:false diff --git a/cmd/explaintest/r/explain_union_scan.result b/cmd/explaintest/r/explain_union_scan.result index 26cdbe97af71c..45f9ef1e4ab1a 100644 --- a/cmd/explaintest/r/explain_union_scan.result +++ b/cmd/explaintest/r/explain_union_scan.result @@ -11,21 +11,21 @@ insert into city values("06766b3ef41d484d8878606393f1ed0b", 88, "chongqing", "ch begin; update city set province_id = 77 where id="06766b3ef41d484d8878606393f1ed0b"; explain select t1.*, t2.province_id as provinceID, t2.city_name as cityName, t3.description as description from city t1 inner join city t2 on t1.id = t2.id left join city t3 on t1.province_id = t3.province_id where t1.province_id > 1 and t1.province_id < 100 limit 10; -id estRows task operator info -Limit_20 10.00 root offset:0, count:10 -└─HashLeftJoin_22 10.00 root left outer join, equal:[eq(test.city.province_id, test.city.province_id)] - ├─Limit_25(Build) 10.00 root offset:0, count:10 - │ └─IndexJoin_38 10.00 root inner join, inner:UnionScan_37, outer key:test.city.id, inner key:test.city.id - │ ├─UnionScan_47(Build) 10.33 root - │ │ └─TableReader_49 10.33 root data:TableFullScan_48 - │ │ └─TableFullScan_48 10.33 cop[tikv] table:t2, keep order:false - │ └─UnionScan_37(Probe) 0.97 root gt(test.city.province_id, 1), lt(test.city.province_id, 100) - │ └─IndexLookUp_36 0.97 root - │ ├─IndexRangeScan_33(Build) 1.00 cop[tikv] table:t1, index:id, range: decided by [eq(test.city.id, test.city.id)], keep order:false - │ └─Selection_35(Probe) 0.97 cop[tikv] gt(test.city.province_id, 1), lt(test.city.province_id, 100) - │ └─TableRowIDScan_34 1.00 cop[tikv] table:t1, keep order:false - └─UnionScan_57(Probe) 519304.44 root gt(test.city.province_id, 1), lt(test.city.province_id, 100), not(isnull(test.city.province_id)) - └─TableReader_60 519304.44 root data:Selection_59 - └─Selection_59 519304.44 cop[tikv] gt(test.city.province_id, 1), lt(test.city.province_id, 100), not(isnull(test.city.province_id)) - └─TableFullScan_58 536284.00 cop[tikv] table:t3, keep order:false +id estRows task access object operator info +Limit_20 10.00 root offset:0, count:10 +└─HashJoin_22 10.00 root left outer join, equal:[eq(test.city.province_id, test.city.province_id)] + ├─Limit_25(Build) 10.00 root offset:0, count:10 + │ └─IndexJoin_38 10.00 root inner join, inner:UnionScan_37, outer key:test.city.id, inner key:test.city.id + │ ├─UnionScan_47(Build) 10.33 root + │ │ └─TableReader_49 10.33 root data:TableFullScan_48 + │ │ └─TableFullScan_48 10.33 cop[tikv] table:t2 keep order:false + │ └─UnionScan_37(Probe) 0.97 root gt(test.city.province_id, 1), lt(test.city.province_id, 100) + │ └─IndexLookUp_36 0.97 root + │ ├─IndexRangeScan_33(Build) 1.00 cop[tikv] table:t1, index:PRIMARY(id) range: decided by [eq(test.city.id, test.city.id)], keep order:false + │ └─Selection_35(Probe) 0.97 cop[tikv] gt(test.city.province_id, 1), lt(test.city.province_id, 100) + │ └─TableRowIDScan_34 1.00 cop[tikv] table:t1 keep order:false + └─UnionScan_57(Probe) 519304.44 root gt(test.city.province_id, 1), lt(test.city.province_id, 100), not(isnull(test.city.province_id)) + └─TableReader_60 519304.44 root data:Selection_59 + └─Selection_59 519304.44 cop[tikv] gt(test.city.province_id, 1), lt(test.city.province_id, 100), not(isnull(test.city.province_id)) + └─TableFullScan_58 536284.00 cop[tikv] table:t3 keep order:false commit; diff --git a/cmd/explaintest/r/generated_columns.result b/cmd/explaintest/r/generated_columns.result index bdd201a74d339..c29348e67696a 100644 --- a/cmd/explaintest/r/generated_columns.result +++ b/cmd/explaintest/r/generated_columns.result @@ -7,11 +7,11 @@ city VARCHAR(64) AS (JSON_UNQUOTE(JSON_EXTRACT(address_info, '$.city'))) STORED, KEY (city) ); EXPLAIN SELECT name, id FROM person WHERE city = 'Beijing'; -id estRows task operator info -Projection_4 10.00 root test.person.name, test.person.id -└─IndexLookUp_10 10.00 root - ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:person, index:city, range:["Beijing","Beijing"], keep order:false, stats:pseudo - └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:person, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 10.00 root test.person.name, test.person.id +└─IndexLookUp_10 10.00 root + ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:person, index:city(city) range:["Beijing","Beijing"], keep order:false, stats:pseudo + └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:person keep order:false, stats:pseudo DROP TABLE IF EXISTS `sgc`; CREATE TABLE `sgc` ( `j1` JSON DEFAULT NULL, @@ -23,23 +23,23 @@ KEY `idx_b` (`b`), KEY `idx_a_b` (`a`,`b`) ); EXPLAIN SELECT a FROM sgc where a < 3; -id estRows task operator info -IndexReader_6 3323.33 root index:IndexRangeScan_5 -└─IndexRangeScan_5 3323.33 cop[tikv] table:sgc, index:a, range:[-inf,3), keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 3323.33 root index:IndexRangeScan_5 +└─IndexRangeScan_5 3323.33 cop[tikv] table:sgc, index:idx_a(a) range:[-inf,3), keep order:false, stats:pseudo EXPLAIN SELECT a, b FROM sgc where a < 3; -id estRows task operator info -IndexReader_6 3323.33 root index:IndexRangeScan_5 -└─IndexRangeScan_5 3323.33 cop[tikv] table:sgc, index:a, b, range:[-inf,3), keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 3323.33 root index:IndexRangeScan_5 +└─IndexRangeScan_5 3323.33 cop[tikv] table:sgc, index:idx_a_b(a, b) range:[-inf,3), keep order:false, stats:pseudo EXPLAIN SELECT a, b from sgc where b < 3; -id estRows task operator info -IndexReader_13 3323.33 root index:Selection_12 -└─Selection_12 3323.33 cop[tikv] lt(test.sgc.b, 3) - └─IndexFullScan_11 10000.00 cop[tikv] table:sgc, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_13 3323.33 root index:Selection_12 +└─Selection_12 3323.33 cop[tikv] lt(test.sgc.b, 3) + └─IndexFullScan_11 10000.00 cop[tikv] table:sgc, index:idx_a_b(a, b) keep order:false, stats:pseudo EXPLAIN SELECT a, b from sgc where a < 3 and b < 3; -id estRows task operator info -IndexReader_11 1104.45 root index:Selection_10 -└─Selection_10 1104.45 cop[tikv] lt(test.sgc.b, 3) - └─IndexRangeScan_9 3323.33 cop[tikv] table:sgc, index:a, b, range:[-inf,3), keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 1104.45 root index:Selection_10 +└─Selection_10 1104.45 cop[tikv] lt(test.sgc.b, 3) + └─IndexRangeScan_9 3323.33 cop[tikv] table:sgc, index:idx_a_b(a, b) range:[-inf,3), keep order:false, stats:pseudo DROP TABLE IF EXISTS sgc1, sgc2; CREATE TABLE `sgc1` ( @@ -70,25 +70,25 @@ INSERT INTO sgc2(j1, j2) VALUES ('{"a": 1}', '{"1": "1"}'); ANALYZE TABLE sgc1, sgc2; EXPLAIN SELECT /*+ TIDB_INLJ(sgc1, sgc2) */ * from sgc1 join sgc2 on sgc1.a=sgc2.a; -id estRows task operator info -IndexJoin_26 5.00 root inner join, inner:IndexLookUp_25, outer key:test.sgc2.a, inner key:test.sgc1.a -├─TableReader_47(Build) 1.00 root data:Selection_46 -│ └─Selection_46 1.00 cop[tikv] not(isnull(test.sgc2.a)) -│ └─TableFullScan_45 1.00 cop[tikv] table:sgc2, keep order:false -└─IndexLookUp_25(Probe) 5.00 root - ├─Selection_24(Build) 5.00 cop[tikv] not(isnull(test.sgc1.a)) - │ └─IndexRangeScan_22 5.00 cop[tikv] table:sgc1, index:a, range: decided by [eq(test.sgc1.a, test.sgc2.a)], keep order:false - └─TableRowIDScan_23(Probe) 5.00 cop[tikv] table:sgc1, keep order:false +id estRows task access object operator info +IndexJoin_26 5.00 root inner join, inner:IndexLookUp_25, outer key:test.sgc2.a, inner key:test.sgc1.a +├─TableReader_47(Build) 1.00 root data:Selection_46 +│ └─Selection_46 1.00 cop[tikv] not(isnull(test.sgc2.a)) +│ └─TableFullScan_45 1.00 cop[tikv] table:sgc2 keep order:false +└─IndexLookUp_25(Probe) 5.00 root + ├─Selection_24(Build) 5.00 cop[tikv] not(isnull(test.sgc1.a)) + │ └─IndexRangeScan_22 5.00 cop[tikv] table:sgc1, index:idx_a(a) range: decided by [eq(test.sgc1.a, test.sgc2.a)], keep order:false + └─TableRowIDScan_23(Probe) 5.00 cop[tikv] table:sgc1 keep order:false EXPLAIN SELECT * from sgc1 join sgc2 on sgc1.a=sgc2.a; -id estRows task operator info -Projection_6 5.00 root test.sgc1.j1, test.sgc1.j2, test.sgc1.a, test.sgc1.b, test.sgc2.j1, test.sgc2.j2, test.sgc2.a, test.sgc2.b -└─HashRightJoin_38 5.00 root inner join, equal:[eq(test.sgc2.a, test.sgc1.a)] - ├─TableReader_57(Build) 1.00 root data:Selection_56 - │ └─Selection_56 1.00 cop[tikv] not(isnull(test.sgc2.a)) - │ └─TableFullScan_55 1.00 cop[tikv] table:sgc2, keep order:false - └─TableReader_66(Probe) 5.00 root data:Selection_65 - └─Selection_65 5.00 cop[tikv] not(isnull(test.sgc1.a)) - └─TableFullScan_64 5.00 cop[tikv] table:sgc1, keep order:false +id estRows task access object operator info +Projection_6 5.00 root test.sgc1.j1, test.sgc1.j2, test.sgc1.a, test.sgc1.b, test.sgc2.j1, test.sgc2.j2, test.sgc2.a, test.sgc2.b +└─HashJoin_38 5.00 root inner join, equal:[eq(test.sgc2.a, test.sgc1.a)] + ├─TableReader_57(Build) 1.00 root data:Selection_56 + │ └─Selection_56 1.00 cop[tikv] not(isnull(test.sgc2.a)) + │ └─TableFullScan_55 1.00 cop[tikv] table:sgc2 keep order:false + └─TableReader_66(Probe) 5.00 root data:Selection_65 + └─Selection_65 5.00 cop[tikv] not(isnull(test.sgc1.a)) + └─TableFullScan_64 5.00 cop[tikv] table:sgc1 keep order:false DROP TABLE IF EXISTS sgc3; CREATE TABLE sgc3 ( j JSON, @@ -103,61 +103,61 @@ PARTITION p4 VALUES LESS THAN (5), PARTITION p5 VALUES LESS THAN (6), PARTITION max VALUES LESS THAN MAXVALUE); EXPLAIN SELECT * FROM sgc3 WHERE a <= 1; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.sgc3.a, 1) -│ └─TableFullScan_9 10000.00 cop[tikv] table:sgc3, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.sgc3.a, 1) - └─TableFullScan_12 10000.00 cop[tikv] table:sgc3, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.sgc3.a, 1) +│ └─TableFullScan_9 10000.00 cop[tikv] table:sgc3, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.sgc3.a, 1) + └─TableFullScan_12 10000.00 cop[tikv] table:sgc3, partition:p1 keep order:false, stats:pseudo EXPLAIN SELECT * FROM sgc3 WHERE a < 7; -id estRows task operator info -Union_13 23263.33 root -├─TableReader_16 3323.33 root data:Selection_15 -│ └─Selection_15 3323.33 cop[tikv] lt(test.sgc3.a, 7) -│ └─TableFullScan_14 10000.00 cop[tikv] table:sgc3, partition:p0, keep order:false, stats:pseudo -├─TableReader_19 3323.33 root data:Selection_18 -│ └─Selection_18 3323.33 cop[tikv] lt(test.sgc3.a, 7) -│ └─TableFullScan_17 10000.00 cop[tikv] table:sgc3, partition:p1, keep order:false, stats:pseudo -├─TableReader_22 3323.33 root data:Selection_21 -│ └─Selection_21 3323.33 cop[tikv] lt(test.sgc3.a, 7) -│ └─TableFullScan_20 10000.00 cop[tikv] table:sgc3, partition:p2, keep order:false, stats:pseudo -├─TableReader_25 3323.33 root data:Selection_24 -│ └─Selection_24 3323.33 cop[tikv] lt(test.sgc3.a, 7) -│ └─TableFullScan_23 10000.00 cop[tikv] table:sgc3, partition:p3, keep order:false, stats:pseudo -├─TableReader_28 3323.33 root data:Selection_27 -│ └─Selection_27 3323.33 cop[tikv] lt(test.sgc3.a, 7) -│ └─TableFullScan_26 10000.00 cop[tikv] table:sgc3, partition:p4, keep order:false, stats:pseudo -├─TableReader_31 3323.33 root data:Selection_30 -│ └─Selection_30 3323.33 cop[tikv] lt(test.sgc3.a, 7) -│ └─TableFullScan_29 10000.00 cop[tikv] table:sgc3, partition:p5, keep order:false, stats:pseudo -└─TableReader_34 3323.33 root data:Selection_33 - └─Selection_33 3323.33 cop[tikv] lt(test.sgc3.a, 7) - └─TableFullScan_32 10000.00 cop[tikv] table:sgc3, partition:max, keep order:false, stats:pseudo +id estRows task access object operator info +Union_13 23263.33 root +├─TableReader_16 3323.33 root data:Selection_15 +│ └─Selection_15 3323.33 cop[tikv] lt(test.sgc3.a, 7) +│ └─TableFullScan_14 10000.00 cop[tikv] table:sgc3, partition:p0 keep order:false, stats:pseudo +├─TableReader_19 3323.33 root data:Selection_18 +│ └─Selection_18 3323.33 cop[tikv] lt(test.sgc3.a, 7) +│ └─TableFullScan_17 10000.00 cop[tikv] table:sgc3, partition:p1 keep order:false, stats:pseudo +├─TableReader_22 3323.33 root data:Selection_21 +│ └─Selection_21 3323.33 cop[tikv] lt(test.sgc3.a, 7) +│ └─TableFullScan_20 10000.00 cop[tikv] table:sgc3, partition:p2 keep order:false, stats:pseudo +├─TableReader_25 3323.33 root data:Selection_24 +│ └─Selection_24 3323.33 cop[tikv] lt(test.sgc3.a, 7) +│ └─TableFullScan_23 10000.00 cop[tikv] table:sgc3, partition:p3 keep order:false, stats:pseudo +├─TableReader_28 3323.33 root data:Selection_27 +│ └─Selection_27 3323.33 cop[tikv] lt(test.sgc3.a, 7) +│ └─TableFullScan_26 10000.00 cop[tikv] table:sgc3, partition:p4 keep order:false, stats:pseudo +├─TableReader_31 3323.33 root data:Selection_30 +│ └─Selection_30 3323.33 cop[tikv] lt(test.sgc3.a, 7) +│ └─TableFullScan_29 10000.00 cop[tikv] table:sgc3, partition:p5 keep order:false, stats:pseudo +└─TableReader_34 3323.33 root data:Selection_33 + └─Selection_33 3323.33 cop[tikv] lt(test.sgc3.a, 7) + └─TableFullScan_32 10000.00 cop[tikv] table:sgc3, partition:max keep order:false, stats:pseudo DROP TABLE IF EXISTS t1; CREATE TABLE t1(a INT, b INT AS (a+1) VIRTUAL, c INT AS (b+1) VIRTUAL, d INT AS (c+1) VIRTUAL, KEY(b), INDEX IDX(c, d)); INSERT INTO t1 (a) VALUES (0); EXPLAIN SELECT b FROM t1 WHERE b=1; -id estRows task operator info -IndexReader_6 10.00 root index:IndexRangeScan_5 -└─IndexRangeScan_5 10.00 cop[tikv] table:t1, index:b, range:[1,1], keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_6 10.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 10.00 cop[tikv] table:t1, index:b(b) range:[1,1], keep order:false, stats:pseudo EXPLAIN SELECT b, c, d FROM t1 WHERE b=1; -id estRows task operator info -Projection_4 10.00 root test.t1.b, test.t1.c, test.t1.d -└─IndexLookUp_10 10.00 root - ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t1, index:b, range:[1,1], keep order:false, stats:pseudo - └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 10.00 root test.t1.b, test.t1.c, test.t1.d +└─IndexLookUp_10 10.00 root + ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t1, index:b(b) range:[1,1], keep order:false, stats:pseudo + └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t1 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b=1; -id estRows task operator info -IndexLookUp_10 10.00 root -├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t1, index:b, range:[1,1], keep order:false, stats:pseudo -└─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +IndexLookUp_10 10.00 root +├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t1, index:b(b) range:[1,1], keep order:false, stats:pseudo +└─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t1 keep order:false, stats:pseudo EXPLAIN SELECT c FROM t1 WHERE c=2 AND d=3; -id estRows task operator info -Projection_4 0.10 root test.t1.c -└─IndexReader_6 0.10 root index:IndexRangeScan_5 - └─IndexRangeScan_5 0.10 cop[tikv] table:t1, index:c, d, range:[2 3,2 3], keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 0.10 root test.t1.c +└─IndexReader_6 0.10 root index:IndexRangeScan_5 + └─IndexRangeScan_5 0.10 cop[tikv] table:t1, index:IDX(c, d) range:[2 3,2 3], keep order:false, stats:pseudo DROP TABLE IF EXISTS person; CREATE TABLE person ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, @@ -167,11 +167,11 @@ city_no INT AS (JSON_EXTRACT(address_info, '$.city_no')) VIRTUAL, KEY(city_no)); INSERT INTO person (name, address_info) VALUES ("John", CAST('{"city_no": 1}' AS JSON)); EXPLAIN SELECT name FROM person where city_no=1; -id estRows task operator info -Projection_4 10.00 root test.person.name -└─IndexLookUp_10 10.00 root - ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:person, index:city_no, range:[1,1], keep order:false, stats:pseudo - └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:person, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_4 10.00 root test.person.name +└─IndexLookUp_10 10.00 root + ├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:person, index:city_no(city_no) range:[1,1], keep order:false, stats:pseudo + └─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:person keep order:false, stats:pseudo DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT, b INT GENERATED ALWAYS AS (-a) VIRTUAL, @@ -179,38 +179,55 @@ c INT GENERATED ALWAYS AS (-a) STORED, index (c)); INSERT INTO t1 (a) VALUES (2), (1), (1), (3), (NULL); EXPLAIN SELECT sum(a) FROM t1 GROUP BY b; -id estRows task operator info -HashAgg_5 8000.00 root group by:Column#7, funcs:sum(Column#6)->Column#5 -└─Projection_12 10000.00 root cast(test.t1.a, decimal(65,0) BINARY)->Column#6, test.t1.b - └─TableReader_9 10000.00 root data:TableFullScan_8 - └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashAgg_5 8000.00 root group by:Column#7, funcs:sum(Column#6)->Column#5 +└─Projection_12 10000.00 root cast(test.t1.a, decimal(65,0) BINARY)->Column#6, test.t1.b + └─TableReader_9 10000.00 root data:TableFullScan_8 + └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo EXPLAIN SELECT sum(a) FROM t1 GROUP BY c; -id estRows task operator info -HashAgg_11 8000.00 root group by:test.t1.c, funcs:sum(Column#6)->Column#5 -└─TableReader_12 8000.00 root data:HashAgg_5 - └─HashAgg_5 8000.00 cop[tikv] group by:test.t1.c, funcs:sum(test.t1.a)->Column#6 - └─TableFullScan_10 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashAgg_11 8000.00 root group by:test.t1.c, funcs:sum(Column#6)->Column#5 +└─TableReader_12 8000.00 root data:HashAgg_5 + └─HashAgg_5 8000.00 cop[tikv] group by:test.t1.c, funcs:sum(test.t1.a)->Column#6 + └─TableFullScan_10 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo EXPLAIN SELECT sum(b) FROM t1 GROUP BY a; -id estRows task operator info -HashAgg_5 8000.00 root group by:Column#7, funcs:sum(Column#6)->Column#5 -└─Projection_12 10000.00 root cast(test.t1.b, decimal(65,0) BINARY)->Column#6, test.t1.a - └─TableReader_9 10000.00 root data:TableFullScan_8 - └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashAgg_5 8000.00 root group by:Column#7, funcs:sum(Column#6)->Column#5 +└─Projection_12 10000.00 root cast(test.t1.b, decimal(65,0) BINARY)->Column#6, test.t1.a + └─TableReader_9 10000.00 root data:TableFullScan_8 + └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo EXPLAIN SELECT sum(b) FROM t1 GROUP BY c; -id estRows task operator info -HashAgg_5 8000.00 root group by:Column#9, funcs:sum(Column#8)->Column#5 -└─Projection_18 10000.00 root cast(test.t1.b, decimal(65,0) BINARY)->Column#8, test.t1.c - └─TableReader_11 10000.00 root data:TableFullScan_10 - └─TableFullScan_10 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashAgg_5 8000.00 root group by:Column#9, funcs:sum(Column#8)->Column#5 +└─Projection_18 10000.00 root cast(test.t1.b, decimal(65,0) BINARY)->Column#8, test.t1.c + └─TableReader_11 10000.00 root data:TableFullScan_10 + └─TableFullScan_10 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo EXPLAIN SELECT sum(c) FROM t1 GROUP BY a; -id estRows task operator info -HashAgg_9 8000.00 root group by:test.t1.a, funcs:sum(Column#6)->Column#5 -└─TableReader_10 8000.00 root data:HashAgg_5 - └─HashAgg_5 8000.00 cop[tikv] group by:test.t1.a, funcs:sum(test.t1.c)->Column#6 - └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashAgg_9 8000.00 root group by:test.t1.a, funcs:sum(Column#6)->Column#5 +└─TableReader_10 8000.00 root data:HashAgg_5 + └─HashAgg_5 8000.00 cop[tikv] group by:test.t1.a, funcs:sum(test.t1.c)->Column#6 + └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo EXPLAIN SELECT sum(c) FROM t1 GROUP BY b; -id estRows task operator info -HashAgg_5 8000.00 root group by:Column#7, funcs:sum(Column#6)->Column#5 -└─Projection_12 10000.00 root cast(test.t1.c, decimal(65,0) BINARY)->Column#6, test.t1.b - └─TableReader_9 10000.00 root data:TableFullScan_8 - └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashAgg_5 8000.00 root group by:Column#7, funcs:sum(Column#6)->Column#5 +└─Projection_12 10000.00 root cast(test.t1.c, decimal(65,0) BINARY)->Column#6, test.t1.b + └─TableReader_9 10000.00 root data:TableFullScan_8 + └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +DROP TABLE IF EXISTS tu; +CREATE TABLE tu (a INT, b INT, c INT GENERATED ALWAYS AS (a + b) VIRTUAL, primary key (a), unique key uk(c)); +INSERT INTO tu(a, b) VALUES(1, 2); +EXPLAIN SELECT * FROM tu WHERE c = 1; +id estRows task access object operator info +Point_Get_5 1.00 root table:tu, index:uk(c) +EXPLAIN SELECT a, c FROM tu WHERE c = 1; +id estRows task access object operator info +Projection_4 1.00 root test.tu.a, test.tu.c +└─Point_Get_5 1.00 root table:tu, index:uk(c) +EXPLAIN SELECT * FROM tu WHERE c in(1, 2, 3); +id estRows task access object operator info +Batch_Point_Get_5 3.00 root table:tu, index:uk(c) keep order:false, desc:false +EXPLAIN SELECT c, a FROM tu WHERE c in(1, 2, 3); +id estRows task access object operator info +Projection_4 3.00 root test.tu.c, test.tu.a +└─Batch_Point_Get_5 3.00 root table:tu, index:uk(c) keep order:false, desc:false diff --git a/cmd/explaintest/r/index_join.result b/cmd/explaintest/r/index_join.result index 3238d7bc4ad62..851d74e672c43 100644 --- a/cmd/explaintest/r/index_join.result +++ b/cmd/explaintest/r/index_join.result @@ -7,36 +7,36 @@ analyze table t1, t2; set session tidb_hashagg_partial_concurrency = 1; set session tidb_hashagg_final_concurrency = 1; explain select /*+ TIDB_INLJ(t1, t2) */ * from t1 join t2 on t1.a=t2.a; -id estRows task operator info -IndexJoin_25 5.00 root inner join, inner:IndexLookUp_24, outer key:test.t2.a, inner key:test.t1.a -├─TableReader_43(Build) 1.00 root data:Selection_42 -│ └─Selection_42 1.00 cop[tikv] not(isnull(test.t2.a)) -│ └─TableFullScan_41 1.00 cop[tikv] table:t2, keep order:false -└─IndexLookUp_24(Probe) 5.00 root - ├─Selection_23(Build) 5.00 cop[tikv] not(isnull(test.t1.a)) - │ └─IndexRangeScan_21 5.00 cop[tikv] table:t1, index:a, range: decided by [eq(test.t1.a, test.t2.a)], keep order:false - └─TableRowIDScan_22(Probe) 5.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +IndexJoin_25 5.00 root inner join, inner:IndexLookUp_24, outer key:test.t2.a, inner key:test.t1.a +├─TableReader_43(Build) 1.00 root data:Selection_42 +│ └─Selection_42 1.00 cop[tikv] not(isnull(test.t2.a)) +│ └─TableFullScan_41 1.00 cop[tikv] table:t2 keep order:false +└─IndexLookUp_24(Probe) 5.00 root + ├─Selection_23(Build) 5.00 cop[tikv] not(isnull(test.t1.a)) + │ └─IndexRangeScan_21 5.00 cop[tikv] table:t1, index:idx(a) range: decided by [eq(test.t1.a, test.t2.a)], keep order:false + └─TableRowIDScan_22(Probe) 5.00 cop[tikv] table:t1 keep order:false explain select * from t1 join t2 on t1.a=t2.a; -id estRows task operator info -Projection_6 5.00 root test.t1.a, test.t1.b, test.t2.a, test.t2.b -└─HashRightJoin_37 5.00 root inner join, equal:[eq(test.t2.a, test.t1.a)] - ├─TableReader_48(Build) 1.00 root data:Selection_47 - │ └─Selection_47 1.00 cop[tikv] not(isnull(test.t2.a)) - │ └─TableFullScan_46 1.00 cop[tikv] table:t2, keep order:false - └─TableReader_54(Probe) 5.00 root data:Selection_53 - └─Selection_53 5.00 cop[tikv] not(isnull(test.t1.a)) - └─TableFullScan_52 5.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +Projection_6 5.00 root test.t1.a, test.t1.b, test.t2.a, test.t2.b +└─HashJoin_37 5.00 root inner join, equal:[eq(test.t2.a, test.t1.a)] + ├─TableReader_48(Build) 1.00 root data:Selection_47 + │ └─Selection_47 1.00 cop[tikv] not(isnull(test.t2.a)) + │ └─TableFullScan_46 1.00 cop[tikv] table:t2 keep order:false + └─TableReader_54(Probe) 5.00 root data:Selection_53 + └─Selection_53 5.00 cop[tikv] not(isnull(test.t1.a)) + └─TableFullScan_52 5.00 cop[tikv] table:t1 keep order:false drop table if exists t1, t2; create table t1(a int not null, b int not null); create table t2(a int not null, b int not null, key a(a)); set @@tidb_opt_insubq_to_join_and_agg=0; explain select /*+ TIDB_INLJ(t2@sel_2) */ * from t1 where t1.a in (select t2.a from t2); -id estRows task operator info -IndexJoin_10 8000.00 root semi join, inner:IndexReader_9, outer key:test.t1.a, inner key:test.t2.a -├─TableReader_18(Build) 10000.00 root data:TableFullScan_17 -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo -└─IndexReader_9(Probe) 1.25 root index:IndexRangeScan_8 - └─IndexRangeScan_8 1.25 cop[tikv] table:t2, index:a, range: decided by [eq(test.t2.a, test.t1.a)], keep order:false, stats:pseudo +id estRows task access object operator info +IndexJoin_10 8000.00 root semi join, inner:IndexReader_9, outer key:test.t1.a, inner key:test.t2.a +├─TableReader_18(Build) 10000.00 root data:TableFullScan_17 +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─IndexReader_9(Probe) 1.25 root index:IndexRangeScan_8 + └─IndexRangeScan_8 1.25 cop[tikv] table:t2, index:a(a) range: decided by [eq(test.t2.a, test.t1.a)], keep order:false, stats:pseudo show warnings; Level Code Message set @@tidb_opt_insubq_to_join_and_agg=1; @@ -44,11 +44,11 @@ drop table if exists t1, t2; create table t1(a int not null, b int not null, key a(a)); create table t2(a int not null, b int not null, key a(a)); explain select /*+ TIDB_INLJ(t1) */ * from t1 where t1.a in (select t2.a from t2); -id estRows task operator info -IndexJoin_13 10000.00 root inner join, inner:IndexLookUp_12, outer key:test.t2.a, inner key:test.t1.a -├─StreamAgg_26(Build) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a -│ └─IndexReader_39 10000.00 root index:IndexFullScan_38 -│ └─IndexFullScan_38 10000.00 cop[tikv] table:t2, index:a, keep order:true, stats:pseudo -└─IndexLookUp_12(Probe) 1.25 root - ├─IndexRangeScan_10(Build) 1.25 cop[tikv] table:t1, index:a, range: decided by [eq(test.t1.a, test.t2.a)], keep order:false, stats:pseudo - └─TableRowIDScan_11(Probe) 1.25 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +IndexJoin_13 10000.00 root inner join, inner:IndexLookUp_12, outer key:test.t2.a, inner key:test.t1.a +├─StreamAgg_26(Build) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a +│ └─IndexReader_39 10000.00 root index:IndexFullScan_38 +│ └─IndexFullScan_38 10000.00 cop[tikv] table:t2, index:a(a) keep order:true, stats:pseudo +└─IndexLookUp_12(Probe) 1.25 root + ├─IndexRangeScan_10(Build) 1.25 cop[tikv] table:t1, index:a(a) range: decided by [eq(test.t1.a, test.t2.a)], keep order:false, stats:pseudo + └─TableRowIDScan_11(Probe) 1.25 cop[tikv] table:t1 keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/partition_pruning.result b/cmd/explaintest/r/partition_pruning.result index 7cfd3ada19542..c7a376bb87bbd 100644 --- a/cmd/explaintest/r/partition_pruning.result +++ b/cmd/explaintest/r/partition_pruning.result @@ -15,36 +15,36 @@ PARTITION p5 VALUES LESS THAN (6), PARTITION max VALUES LESS THAN MAXVALUE); INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8); EXPLAIN SELECT * FROM t1 WHERE a <= 1; -id estRows task operator info -Union_8 2.00 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,1], keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,1], keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 2.00 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,1], keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,1], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE a < 7; -id estRows task operator info -Union_13 49.00 root -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_21 3333.33 root data:TableRangeScan_20 -│ └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:TableRangeScan_22 -│ └─TableRangeScan_22 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_25 3333.33 root data:TableRangeScan_24 -│ └─TableRangeScan_24 3333.33 cop[tikv] table:t1, partition:p5, range:[-inf,7), keep order:false, stats:pseudo -└─TableReader_27 3333.33 root data:TableRangeScan_26 - └─TableRangeScan_26 3333.33 cop[tikv] table:t1, partition:max, range:[-inf,7), keep order:false, stats:pseudo +id estRows task access object operator info +Union_13 49.00 root +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_21 3333.33 root data:TableRangeScan_20 +│ └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_23 3333.33 root data:TableRangeScan_22 +│ └─TableRangeScan_22 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_25 3333.33 root data:TableRangeScan_24 +│ └─TableRangeScan_24 3333.33 cop[tikv] table:t1, partition:p5 range:[-inf,7), keep order:false, stats:pseudo +└─TableReader_27 3333.33 root data:TableRangeScan_26 + └─TableRangeScan_26 3333.33 cop[tikv] table:t1, partition:max range:[-inf,7), keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE a <= 1; -id estRows task operator info -Union_8 2.00 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,1], keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,1], keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 2.00 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,1], keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,1], keep order:false, stats:pseudo DROP TABLE t1; # # Bug#49742: Partition Pruning not working correctly for RANGE @@ -64,21 +64,21 @@ a -1 0 EXPLAIN SELECT * FROM t1 WHERE a < 1; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,1), keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,1), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 2 order by a; a -1 0 1 EXPLAIN SELECT * FROM t1 WHERE a < 2; -id estRows task operator info -Union_8 4.00 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,2), keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,2), keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 4.00 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,2), keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,2), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 3 order by a; a -1 @@ -86,14 +86,14 @@ a 1 2 EXPLAIN SELECT * FROM t1 WHERE a < 3; -id estRows task operator info -Union_9 9.00 root -├─TableReader_11 3333.33 root data:TableRangeScan_10 -│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,3), keep order:false, stats:pseudo -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,3), keep order:false, stats:pseudo -└─TableReader_15 3333.33 root data:TableRangeScan_14 - └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,3), keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9.00 root +├─TableReader_11 3333.33 root data:TableRangeScan_10 +│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,3), keep order:false, stats:pseudo +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,3), keep order:false, stats:pseudo +└─TableReader_15 3333.33 root data:TableRangeScan_14 + └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,3), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 4 order by a; a -1 @@ -102,16 +102,16 @@ a 2 3 EXPLAIN SELECT * FROM t1 WHERE a < 4; -id estRows task operator info -Union_10 16.00 root -├─TableReader_12 3333.33 root data:TableRangeScan_11 -│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,4), keep order:false, stats:pseudo -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,4), keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,4), keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:TableRangeScan_17 - └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,4), keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 16.00 root +├─TableReader_12 3333.33 root data:TableRangeScan_11 +│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,4), keep order:false, stats:pseudo +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,4), keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,4), keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:TableRangeScan_17 + └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,4), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 5 order by a; a -1 @@ -121,18 +121,18 @@ a 3 4 EXPLAIN SELECT * FROM t1 WHERE a < 5; -id estRows task operator info -Union_11 25.00 root -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,5), keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,5), keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,5), keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,5), keep order:false, stats:pseudo -└─TableReader_21 3333.33 root data:TableRangeScan_20 - └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,5), keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 25.00 root +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,5), keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,5), keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,5), keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,5), keep order:false, stats:pseudo +└─TableReader_21 3333.33 root data:TableRangeScan_20 + └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,5), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 6 order by a; a -1 @@ -143,20 +143,20 @@ a 4 5 EXPLAIN SELECT * FROM t1 WHERE a < 6; -id estRows task operator info -Union_12 36.00 root -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,6), keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,6), keep order:false, stats:pseudo -├─TableReader_18 3333.33 root data:TableRangeScan_17 -│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,6), keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:TableRangeScan_19 -│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,6), keep order:false, stats:pseudo -├─TableReader_22 3333.33 root data:TableRangeScan_21 -│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,6), keep order:false, stats:pseudo -└─TableReader_24 3333.33 root data:TableRangeScan_23 - └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:p5, range:[-inf,6), keep order:false, stats:pseudo +id estRows task access object operator info +Union_12 36.00 root +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,6), keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,6), keep order:false, stats:pseudo +├─TableReader_18 3333.33 root data:TableRangeScan_17 +│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,6), keep order:false, stats:pseudo +├─TableReader_20 3333.33 root data:TableRangeScan_19 +│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,6), keep order:false, stats:pseudo +├─TableReader_22 3333.33 root data:TableRangeScan_21 +│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,6), keep order:false, stats:pseudo +└─TableReader_24 3333.33 root data:TableRangeScan_23 + └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:p5 range:[-inf,6), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 7 order by a; a -1 @@ -168,34 +168,34 @@ a 5 6 EXPLAIN SELECT * FROM t1 WHERE a < 7; -id estRows task operator info -Union_13 49.00 root -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_21 3333.33 root data:TableRangeScan_20 -│ └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:TableRangeScan_22 -│ └─TableRangeScan_22 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,7), keep order:false, stats:pseudo -├─TableReader_25 3333.33 root data:TableRangeScan_24 -│ └─TableRangeScan_24 3333.33 cop[tikv] table:t1, partition:p5, range:[-inf,7), keep order:false, stats:pseudo -└─TableReader_27 3333.33 root data:TableRangeScan_26 - └─TableRangeScan_26 3333.33 cop[tikv] table:t1, partition:max, range:[-inf,7), keep order:false, stats:pseudo +id estRows task access object operator info +Union_13 49.00 root +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_21 3333.33 root data:TableRangeScan_20 +│ └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_23 3333.33 root data:TableRangeScan_22 +│ └─TableRangeScan_22 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,7), keep order:false, stats:pseudo +├─TableReader_25 3333.33 root data:TableRangeScan_24 +│ └─TableRangeScan_24 3333.33 cop[tikv] table:t1, partition:p5 range:[-inf,7), keep order:false, stats:pseudo +└─TableReader_27 3333.33 root data:TableRangeScan_26 + └─TableRangeScan_26 3333.33 cop[tikv] table:t1, partition:max range:[-inf,7), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 1 order by a; a -1 0 1 EXPLAIN SELECT * FROM t1 WHERE a <= 1; -id estRows task operator info -Union_8 2.00 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,1], keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,1], keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 2.00 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,1], keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,1], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 2 order by a; a -1 @@ -203,14 +203,14 @@ a 1 2 EXPLAIN SELECT * FROM t1 WHERE a <= 2; -id estRows task operator info -Union_9 6.00 root -├─TableReader_11 3333.33 root data:TableRangeScan_10 -│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,2], keep order:false, stats:pseudo -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,2], keep order:false, stats:pseudo -└─TableReader_15 3333.33 root data:TableRangeScan_14 - └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,2], keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 6.00 root +├─TableReader_11 3333.33 root data:TableRangeScan_10 +│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,2], keep order:false, stats:pseudo +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,2], keep order:false, stats:pseudo +└─TableReader_15 3333.33 root data:TableRangeScan_14 + └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,2], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 3 order by a; a -1 @@ -219,16 +219,16 @@ a 2 3 EXPLAIN SELECT * FROM t1 WHERE a <= 3; -id estRows task operator info -Union_10 12.00 root -├─TableReader_12 3333.33 root data:TableRangeScan_11 -│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,3], keep order:false, stats:pseudo -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,3], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,3], keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:TableRangeScan_17 - └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,3], keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 12.00 root +├─TableReader_12 3333.33 root data:TableRangeScan_11 +│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,3], keep order:false, stats:pseudo +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,3], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,3], keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:TableRangeScan_17 + └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,3], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 4 order by a; a -1 @@ -238,18 +238,18 @@ a 3 4 EXPLAIN SELECT * FROM t1 WHERE a <= 4; -id estRows task operator info -Union_11 20.00 root -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,4], keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,4], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,4], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,4], keep order:false, stats:pseudo -└─TableReader_21 3333.33 root data:TableRangeScan_20 - └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,4], keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 20.00 root +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,4], keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,4], keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,4], keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,4], keep order:false, stats:pseudo +└─TableReader_21 3333.33 root data:TableRangeScan_20 + └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,4], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 5 order by a; a -1 @@ -260,20 +260,20 @@ a 4 5 EXPLAIN SELECT * FROM t1 WHERE a <= 5; -id estRows task operator info -Union_12 30.00 root -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,5], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,5], keep order:false, stats:pseudo -├─TableReader_18 3333.33 root data:TableRangeScan_17 -│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,5], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:TableRangeScan_19 -│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,5], keep order:false, stats:pseudo -├─TableReader_22 3333.33 root data:TableRangeScan_21 -│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,5], keep order:false, stats:pseudo -└─TableReader_24 3333.33 root data:TableRangeScan_23 - └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:p5, range:[-inf,5], keep order:false, stats:pseudo +id estRows task access object operator info +Union_12 30.00 root +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,5], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,5], keep order:false, stats:pseudo +├─TableReader_18 3333.33 root data:TableRangeScan_17 +│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,5], keep order:false, stats:pseudo +├─TableReader_20 3333.33 root data:TableRangeScan_19 +│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,5], keep order:false, stats:pseudo +├─TableReader_22 3333.33 root data:TableRangeScan_21 +│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,5], keep order:false, stats:pseudo +└─TableReader_24 3333.33 root data:TableRangeScan_23 + └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:p5 range:[-inf,5], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 6 order by a; a -1 @@ -285,22 +285,22 @@ a 5 6 EXPLAIN SELECT * FROM t1 WHERE a <= 6; -id estRows task operator info -Union_13 42.00 root -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,6], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,6], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,6], keep order:false, stats:pseudo -├─TableReader_21 3333.33 root data:TableRangeScan_20 -│ └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,6], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:TableRangeScan_22 -│ └─TableRangeScan_22 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,6], keep order:false, stats:pseudo -├─TableReader_25 3333.33 root data:TableRangeScan_24 -│ └─TableRangeScan_24 3333.33 cop[tikv] table:t1, partition:p5, range:[-inf,6], keep order:false, stats:pseudo -└─TableReader_27 3333.33 root data:TableRangeScan_26 - └─TableRangeScan_26 3333.33 cop[tikv] table:t1, partition:max, range:[-inf,6], keep order:false, stats:pseudo +id estRows task access object operator info +Union_13 42.00 root +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,6], keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,6], keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,6], keep order:false, stats:pseudo +├─TableReader_21 3333.33 root data:TableRangeScan_20 +│ └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,6], keep order:false, stats:pseudo +├─TableReader_23 3333.33 root data:TableRangeScan_22 +│ └─TableRangeScan_22 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,6], keep order:false, stats:pseudo +├─TableReader_25 3333.33 root data:TableRangeScan_24 +│ └─TableRangeScan_24 3333.33 cop[tikv] table:t1, partition:p5 range:[-inf,6], keep order:false, stats:pseudo +└─TableReader_27 3333.33 root data:TableRangeScan_26 + └─TableRangeScan_26 3333.33 cop[tikv] table:t1, partition:max range:[-inf,6], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 7 order by a; a -1 @@ -313,64 +313,64 @@ a 6 7 EXPLAIN SELECT * FROM t1 WHERE a <= 7; -id estRows task operator info -Union_13 49.00 root -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,7], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,7], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,7], keep order:false, stats:pseudo -├─TableReader_21 3333.33 root data:TableRangeScan_20 -│ └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,7], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:TableRangeScan_22 -│ └─TableRangeScan_22 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,7], keep order:false, stats:pseudo -├─TableReader_25 3333.33 root data:TableRangeScan_24 -│ └─TableRangeScan_24 3333.33 cop[tikv] table:t1, partition:p5, range:[-inf,7], keep order:false, stats:pseudo -└─TableReader_27 3333.33 root data:TableRangeScan_26 - └─TableRangeScan_26 3333.33 cop[tikv] table:t1, partition:max, range:[-inf,7], keep order:false, stats:pseudo +id estRows task access object operator info +Union_13 49.00 root +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,7], keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,7], keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,7], keep order:false, stats:pseudo +├─TableReader_21 3333.33 root data:TableRangeScan_20 +│ └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,7], keep order:false, stats:pseudo +├─TableReader_23 3333.33 root data:TableRangeScan_22 +│ └─TableRangeScan_22 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,7], keep order:false, stats:pseudo +├─TableReader_25 3333.33 root data:TableRangeScan_24 +│ └─TableRangeScan_24 3333.33 cop[tikv] table:t1, partition:p5 range:[-inf,7], keep order:false, stats:pseudo +└─TableReader_27 3333.33 root data:TableRangeScan_26 + └─TableRangeScan_26 3333.33 cop[tikv] table:t1, partition:max range:[-inf,7], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a = 1 order by a; a 1 EXPLAIN SELECT * FROM t1 WHERE a = 1; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:1, partition:p1 +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:p1 handle:1 SELECT * FROM t1 WHERE a = 2 order by a; a 2 EXPLAIN SELECT * FROM t1 WHERE a = 2; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:2, partition:p2 +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:p2 handle:2 SELECT * FROM t1 WHERE a = 3 order by a; a 3 EXPLAIN SELECT * FROM t1 WHERE a = 3; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:3, partition:p3 +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:p3 handle:3 SELECT * FROM t1 WHERE a = 4 order by a; a 4 EXPLAIN SELECT * FROM t1 WHERE a = 4; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:4, partition:p4 +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:p4 handle:4 SELECT * FROM t1 WHERE a = 5 order by a; a 5 EXPLAIN SELECT * FROM t1 WHERE a = 5; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:5, partition:p5 +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:p5 handle:5 SELECT * FROM t1 WHERE a = 6 order by a; a 6 EXPLAIN SELECT * FROM t1 WHERE a = 6; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:6, partition:max +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:max handle:6 SELECT * FROM t1 WHERE a = 7 order by a; a 7 EXPLAIN SELECT * FROM t1 WHERE a = 7; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:7, partition:max +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:max handle:7 SELECT * FROM t1 WHERE a >= 1 order by a; a 1 @@ -382,20 +382,20 @@ a 7 8 EXPLAIN SELECT * FROM t1 WHERE a >= 1; -id estRows task operator info -Union_12 20000.00 root -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1, range:[1,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2, range:[1,+inf], keep order:false, stats:pseudo -├─TableReader_18 3333.33 root data:TableRangeScan_17 -│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3, range:[1,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:TableRangeScan_19 -│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p4, range:[1,+inf], keep order:false, stats:pseudo -├─TableReader_22 3333.33 root data:TableRangeScan_21 -│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p5, range:[1,+inf], keep order:false, stats:pseudo -└─TableReader_24 3333.33 root data:TableRangeScan_23 - └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:max, range:[1,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_12 20000.00 root +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1 range:[1,+inf], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2 range:[1,+inf], keep order:false, stats:pseudo +├─TableReader_18 3333.33 root data:TableRangeScan_17 +│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3 range:[1,+inf], keep order:false, stats:pseudo +├─TableReader_20 3333.33 root data:TableRangeScan_19 +│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p4 range:[1,+inf], keep order:false, stats:pseudo +├─TableReader_22 3333.33 root data:TableRangeScan_21 +│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p5 range:[1,+inf], keep order:false, stats:pseudo +└─TableReader_24 3333.33 root data:TableRangeScan_23 + └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:max range:[1,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 2 order by a; a 2 @@ -406,18 +406,18 @@ a 7 8 EXPLAIN SELECT * FROM t1 WHERE a >= 2; -id estRows task operator info -Union_11 16666.67 root -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p2, range:[2,+inf], keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p3, range:[2,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p4, range:[2,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p5, range:[2,+inf], keep order:false, stats:pseudo -└─TableReader_21 3333.33 root data:TableRangeScan_20 - └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:max, range:[2,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16666.67 root +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p2 range:[2,+inf], keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p3 range:[2,+inf], keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p4 range:[2,+inf], keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p5 range:[2,+inf], keep order:false, stats:pseudo +└─TableReader_21 3333.33 root data:TableRangeScan_20 + └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:max range:[2,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 3 order by a; a 3 @@ -427,16 +427,16 @@ a 7 8 EXPLAIN SELECT * FROM t1 WHERE a >= 3; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_12 3333.33 root data:TableRangeScan_11 -│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p3, range:[3,+inf], keep order:false, stats:pseudo -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p4, range:[3,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p5, range:[3,+inf], keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:TableRangeScan_17 - └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:max, range:[3,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_12 3333.33 root data:TableRangeScan_11 +│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p3 range:[3,+inf], keep order:false, stats:pseudo +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p4 range:[3,+inf], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p5 range:[3,+inf], keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:TableRangeScan_17 + └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:max range:[3,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 4 order by a; a 4 @@ -445,14 +445,14 @@ a 7 8 EXPLAIN SELECT * FROM t1 WHERE a >= 4; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_11 3333.33 root data:TableRangeScan_10 -│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p4, range:[4,+inf], keep order:false, stats:pseudo -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p5, range:[4,+inf], keep order:false, stats:pseudo -└─TableReader_15 3333.33 root data:TableRangeScan_14 - └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:max, range:[4,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_11 3333.33 root data:TableRangeScan_10 +│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p4 range:[4,+inf], keep order:false, stats:pseudo +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p5 range:[4,+inf], keep order:false, stats:pseudo +└─TableReader_15 3333.33 root data:TableRangeScan_14 + └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:max range:[4,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 5 order by a; a 5 @@ -460,29 +460,29 @@ a 7 8 EXPLAIN SELECT * FROM t1 WHERE a >= 5; -id estRows task operator info -Union_8 6666.67 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p5, range:[5,+inf], keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:max, range:[5,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6666.67 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p5 range:[5,+inf], keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:max range:[5,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 6 order by a; a 6 7 8 EXPLAIN SELECT * FROM t1 WHERE a >= 6; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:[6,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:[6,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 7 order by a; a 7 8 EXPLAIN SELECT * FROM t1 WHERE a >= 7; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:[7,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:[7,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 1 order by a; a 2 @@ -493,18 +493,18 @@ a 7 8 EXPLAIN SELECT * FROM t1 WHERE a > 1; -id estRows task operator info -Union_11 16666.67 root -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p2, range:(1,+inf], keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p3, range:(1,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p4, range:(1,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p5, range:(1,+inf], keep order:false, stats:pseudo -└─TableReader_21 3333.33 root data:TableRangeScan_20 - └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:max, range:(1,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16666.67 root +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p2 range:(1,+inf], keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p3 range:(1,+inf], keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p4 range:(1,+inf], keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p5 range:(1,+inf], keep order:false, stats:pseudo +└─TableReader_21 3333.33 root data:TableRangeScan_20 + └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:max range:(1,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 2 order by a; a 3 @@ -514,16 +514,16 @@ a 7 8 EXPLAIN SELECT * FROM t1 WHERE a > 2; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_12 3333.33 root data:TableRangeScan_11 -│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p3, range:(2,+inf], keep order:false, stats:pseudo -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p4, range:(2,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p5, range:(2,+inf], keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:TableRangeScan_17 - └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:max, range:(2,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_12 3333.33 root data:TableRangeScan_11 +│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p3 range:(2,+inf], keep order:false, stats:pseudo +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p4 range:(2,+inf], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p5 range:(2,+inf], keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:TableRangeScan_17 + └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:max range:(2,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 3 order by a; a 4 @@ -532,14 +532,14 @@ a 7 8 EXPLAIN SELECT * FROM t1 WHERE a > 3; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_11 3333.33 root data:TableRangeScan_10 -│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p4, range:(3,+inf], keep order:false, stats:pseudo -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p5, range:(3,+inf], keep order:false, stats:pseudo -└─TableReader_15 3333.33 root data:TableRangeScan_14 - └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:max, range:(3,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_11 3333.33 root data:TableRangeScan_10 +│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p4 range:(3,+inf], keep order:false, stats:pseudo +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p5 range:(3,+inf], keep order:false, stats:pseudo +└─TableReader_15 3333.33 root data:TableRangeScan_14 + └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:max range:(3,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 4 order by a; a 5 @@ -547,36 +547,36 @@ a 7 8 EXPLAIN SELECT * FROM t1 WHERE a > 4; -id estRows task operator info -Union_8 6666.67 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p5, range:(4,+inf], keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:max, range:(4,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6666.67 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p5 range:(4,+inf], keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:max range:(4,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 5 order by a; a 6 7 8 EXPLAIN SELECT * FROM t1 WHERE a > 5; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:(5,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:(5,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 6 order by a; a 7 8 EXPLAIN SELECT * FROM t1 WHERE a > 6; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:(6,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:(6,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 7 order by a; a 8 EXPLAIN SELECT * FROM t1 WHERE a > 7; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:(7,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:(7,+inf], keep order:false, stats:pseudo DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY) PARTITION BY RANGE (a) ( @@ -592,21 +592,21 @@ a -1 0 EXPLAIN SELECT * FROM t1 WHERE a < 1; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,1), keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,1), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 2 order by a; a -1 0 1 EXPLAIN SELECT * FROM t1 WHERE a < 2; -id estRows task operator info -Union_8 4.00 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,2), keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,2), keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 4.00 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,2), keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,2), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 3 order by a; a -1 @@ -614,14 +614,14 @@ a 1 2 EXPLAIN SELECT * FROM t1 WHERE a < 3; -id estRows task operator info -Union_9 9.00 root -├─TableReader_11 3333.33 root data:TableRangeScan_10 -│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,3), keep order:false, stats:pseudo -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,3), keep order:false, stats:pseudo -└─TableReader_15 3333.33 root data:TableRangeScan_14 - └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,3), keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9.00 root +├─TableReader_11 3333.33 root data:TableRangeScan_10 +│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,3), keep order:false, stats:pseudo +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,3), keep order:false, stats:pseudo +└─TableReader_15 3333.33 root data:TableRangeScan_14 + └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,3), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 4 order by a; a -1 @@ -630,16 +630,16 @@ a 2 3 EXPLAIN SELECT * FROM t1 WHERE a < 4; -id estRows task operator info -Union_10 16.00 root -├─TableReader_12 3333.33 root data:TableRangeScan_11 -│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,4), keep order:false, stats:pseudo -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,4), keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,4), keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:TableRangeScan_17 - └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,4), keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 16.00 root +├─TableReader_12 3333.33 root data:TableRangeScan_11 +│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,4), keep order:false, stats:pseudo +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,4), keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,4), keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:TableRangeScan_17 + └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,4), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 5 order by a; a -1 @@ -649,18 +649,18 @@ a 3 4 EXPLAIN SELECT * FROM t1 WHERE a < 5; -id estRows task operator info -Union_11 25.00 root -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,5), keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,5), keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,5), keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,5), keep order:false, stats:pseudo -└─TableReader_21 3333.33 root data:TableRangeScan_20 - └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,5), keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 25.00 root +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,5), keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,5), keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,5), keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,5), keep order:false, stats:pseudo +└─TableReader_21 3333.33 root data:TableRangeScan_20 + └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,5), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a < 6 order by a; a -1 @@ -671,32 +671,32 @@ a 4 5 EXPLAIN SELECT * FROM t1 WHERE a < 6; -id estRows task operator info -Union_12 36.00 root -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,6), keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,6), keep order:false, stats:pseudo -├─TableReader_18 3333.33 root data:TableRangeScan_17 -│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,6), keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:TableRangeScan_19 -│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,6), keep order:false, stats:pseudo -├─TableReader_22 3333.33 root data:TableRangeScan_21 -│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,6), keep order:false, stats:pseudo -└─TableReader_24 3333.33 root data:TableRangeScan_23 - └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:max, range:[-inf,6), keep order:false, stats:pseudo +id estRows task access object operator info +Union_12 36.00 root +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,6), keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,6), keep order:false, stats:pseudo +├─TableReader_18 3333.33 root data:TableRangeScan_17 +│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,6), keep order:false, stats:pseudo +├─TableReader_20 3333.33 root data:TableRangeScan_19 +│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,6), keep order:false, stats:pseudo +├─TableReader_22 3333.33 root data:TableRangeScan_21 +│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,6), keep order:false, stats:pseudo +└─TableReader_24 3333.33 root data:TableRangeScan_23 + └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:max range:[-inf,6), keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 1 order by a; a -1 0 1 EXPLAIN SELECT * FROM t1 WHERE a <= 1; -id estRows task operator info -Union_8 2.00 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,1], keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,1], keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 2.00 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,1], keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,1], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 2 order by a; a -1 @@ -704,14 +704,14 @@ a 1 2 EXPLAIN SELECT * FROM t1 WHERE a <= 2; -id estRows task operator info -Union_9 6.00 root -├─TableReader_11 3333.33 root data:TableRangeScan_10 -│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,2], keep order:false, stats:pseudo -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,2], keep order:false, stats:pseudo -└─TableReader_15 3333.33 root data:TableRangeScan_14 - └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,2], keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 6.00 root +├─TableReader_11 3333.33 root data:TableRangeScan_10 +│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,2], keep order:false, stats:pseudo +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,2], keep order:false, stats:pseudo +└─TableReader_15 3333.33 root data:TableRangeScan_14 + └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,2], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 3 order by a; a -1 @@ -720,16 +720,16 @@ a 2 3 EXPLAIN SELECT * FROM t1 WHERE a <= 3; -id estRows task operator info -Union_10 12.00 root -├─TableReader_12 3333.33 root data:TableRangeScan_11 -│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,3], keep order:false, stats:pseudo -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,3], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,3], keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:TableRangeScan_17 - └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,3], keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 12.00 root +├─TableReader_12 3333.33 root data:TableRangeScan_11 +│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,3], keep order:false, stats:pseudo +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,3], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,3], keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:TableRangeScan_17 + └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,3], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 4 order by a; a -1 @@ -739,18 +739,18 @@ a 3 4 EXPLAIN SELECT * FROM t1 WHERE a <= 4; -id estRows task operator info -Union_11 20.00 root -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,4], keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,4], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,4], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,4], keep order:false, stats:pseudo -└─TableReader_21 3333.33 root data:TableRangeScan_20 - └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,4], keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 20.00 root +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,4], keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,4], keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,4], keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,4], keep order:false, stats:pseudo +└─TableReader_21 3333.33 root data:TableRangeScan_20 + └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,4], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 5 order by a; a -1 @@ -761,20 +761,20 @@ a 4 5 EXPLAIN SELECT * FROM t1 WHERE a <= 5; -id estRows task operator info -Union_12 30.00 root -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,5], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,5], keep order:false, stats:pseudo -├─TableReader_18 3333.33 root data:TableRangeScan_17 -│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,5], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:TableRangeScan_19 -│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,5], keep order:false, stats:pseudo -├─TableReader_22 3333.33 root data:TableRangeScan_21 -│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,5], keep order:false, stats:pseudo -└─TableReader_24 3333.33 root data:TableRangeScan_23 - └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:max, range:[-inf,5], keep order:false, stats:pseudo +id estRows task access object operator info +Union_12 30.00 root +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,5], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,5], keep order:false, stats:pseudo +├─TableReader_18 3333.33 root data:TableRangeScan_17 +│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,5], keep order:false, stats:pseudo +├─TableReader_20 3333.33 root data:TableRangeScan_19 +│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,5], keep order:false, stats:pseudo +├─TableReader_22 3333.33 root data:TableRangeScan_21 +│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,5], keep order:false, stats:pseudo +└─TableReader_24 3333.33 root data:TableRangeScan_23 + └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:max range:[-inf,5], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a <= 6 order by a; a -1 @@ -786,56 +786,56 @@ a 5 6 EXPLAIN SELECT * FROM t1 WHERE a <= 6; -id estRows task operator info -Union_12 36.00 root -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0, range:[-inf,6], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1, range:[-inf,6], keep order:false, stats:pseudo -├─TableReader_18 3333.33 root data:TableRangeScan_17 -│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2, range:[-inf,6], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:TableRangeScan_19 -│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3, range:[-inf,6], keep order:false, stats:pseudo -├─TableReader_22 3333.33 root data:TableRangeScan_21 -│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4, range:[-inf,6], keep order:false, stats:pseudo -└─TableReader_24 3333.33 root data:TableRangeScan_23 - └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:max, range:[-inf,6], keep order:false, stats:pseudo +id estRows task access object operator info +Union_12 36.00 root +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p0 range:[-inf,6], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p1 range:[-inf,6], keep order:false, stats:pseudo +├─TableReader_18 3333.33 root data:TableRangeScan_17 +│ └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:p2 range:[-inf,6], keep order:false, stats:pseudo +├─TableReader_20 3333.33 root data:TableRangeScan_19 +│ └─TableRangeScan_19 3333.33 cop[tikv] table:t1, partition:p3 range:[-inf,6], keep order:false, stats:pseudo +├─TableReader_22 3333.33 root data:TableRangeScan_21 +│ └─TableRangeScan_21 3333.33 cop[tikv] table:t1, partition:p4 range:[-inf,6], keep order:false, stats:pseudo +└─TableReader_24 3333.33 root data:TableRangeScan_23 + └─TableRangeScan_23 3333.33 cop[tikv] table:t1, partition:max range:[-inf,6], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a = 1; a 1 EXPLAIN SELECT * FROM t1 WHERE a = 1; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:1, partition:p1 +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:p1 handle:1 SELECT * FROM t1 WHERE a = 2; a 2 EXPLAIN SELECT * FROM t1 WHERE a = 2; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:2, partition:p2 +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:p2 handle:2 SELECT * FROM t1 WHERE a = 3; a 3 EXPLAIN SELECT * FROM t1 WHERE a = 3; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:3, partition:p3 +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:p3 handle:3 SELECT * FROM t1 WHERE a = 4; a 4 EXPLAIN SELECT * FROM t1 WHERE a = 4; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:4, partition:p4 +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:p4 handle:4 SELECT * FROM t1 WHERE a = 5; a 5 EXPLAIN SELECT * FROM t1 WHERE a = 5; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:5, partition:max +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:max handle:5 SELECT * FROM t1 WHERE a = 6; a 6 EXPLAIN SELECT * FROM t1 WHERE a = 6; -id estRows task operator info -Point_Get_6 1.00 root table:t1, handle:6, partition:max +id estRows task access object operator info +Point_Get_6 1.00 root table:t1, partition:max handle:6 SELECT * FROM t1 WHERE a >= 1 order by a; a 1 @@ -846,18 +846,18 @@ a 6 7 EXPLAIN SELECT * FROM t1 WHERE a >= 1; -id estRows task operator info -Union_11 16666.67 root -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1, range:[1,+inf], keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:TableRangeScan_14 -│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2, range:[1,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:TableRangeScan_16 -│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p3, range:[1,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:TableRangeScan_18 -│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p4, range:[1,+inf], keep order:false, stats:pseudo -└─TableReader_21 3333.33 root data:TableRangeScan_20 - └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:max, range:[1,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16666.67 root +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p1 range:[1,+inf], keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:TableRangeScan_14 +│ └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:p2 range:[1,+inf], keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:TableRangeScan_16 +│ └─TableRangeScan_16 3333.33 cop[tikv] table:t1, partition:p3 range:[1,+inf], keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:TableRangeScan_18 +│ └─TableRangeScan_18 3333.33 cop[tikv] table:t1, partition:p4 range:[1,+inf], keep order:false, stats:pseudo +└─TableReader_21 3333.33 root data:TableRangeScan_20 + └─TableRangeScan_20 3333.33 cop[tikv] table:t1, partition:max range:[1,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 2 order by a; a 2 @@ -867,16 +867,16 @@ a 6 7 EXPLAIN SELECT * FROM t1 WHERE a >= 2; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_12 3333.33 root data:TableRangeScan_11 -│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p2, range:[2,+inf], keep order:false, stats:pseudo -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p3, range:[2,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p4, range:[2,+inf], keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:TableRangeScan_17 - └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:max, range:[2,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_12 3333.33 root data:TableRangeScan_11 +│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p2 range:[2,+inf], keep order:false, stats:pseudo +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p3 range:[2,+inf], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p4 range:[2,+inf], keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:TableRangeScan_17 + └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:max range:[2,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 3 order by a; a 3 @@ -885,14 +885,14 @@ a 6 7 EXPLAIN SELECT * FROM t1 WHERE a >= 3; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_11 3333.33 root data:TableRangeScan_10 -│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p3, range:[3,+inf], keep order:false, stats:pseudo -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p4, range:[3,+inf], keep order:false, stats:pseudo -└─TableReader_15 3333.33 root data:TableRangeScan_14 - └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:max, range:[3,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_11 3333.33 root data:TableRangeScan_10 +│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p3 range:[3,+inf], keep order:false, stats:pseudo +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p4 range:[3,+inf], keep order:false, stats:pseudo +└─TableReader_15 3333.33 root data:TableRangeScan_14 + └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:max range:[3,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 4 order by a; a 4 @@ -900,29 +900,29 @@ a 6 7 EXPLAIN SELECT * FROM t1 WHERE a >= 4; -id estRows task operator info -Union_8 6666.67 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p4, range:[4,+inf], keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:max, range:[4,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6666.67 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p4 range:[4,+inf], keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:max range:[4,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 5 order by a; a 5 6 7 EXPLAIN SELECT * FROM t1 WHERE a >= 5; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:[5,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:[5,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a >= 6 order by a; a 6 7 EXPLAIN SELECT * FROM t1 WHERE a >= 6; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:[6,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:[6,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 1 order by a; a 2 @@ -932,16 +932,16 @@ a 6 7 EXPLAIN SELECT * FROM t1 WHERE a > 1; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_12 3333.33 root data:TableRangeScan_11 -│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p2, range:(1,+inf], keep order:false, stats:pseudo -├─TableReader_14 3333.33 root data:TableRangeScan_13 -│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p3, range:(1,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:TableRangeScan_15 -│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p4, range:(1,+inf], keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:TableRangeScan_17 - └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:max, range:(1,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_12 3333.33 root data:TableRangeScan_11 +│ └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:p2 range:(1,+inf], keep order:false, stats:pseudo +├─TableReader_14 3333.33 root data:TableRangeScan_13 +│ └─TableRangeScan_13 3333.33 cop[tikv] table:t1, partition:p3 range:(1,+inf], keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:TableRangeScan_15 +│ └─TableRangeScan_15 3333.33 cop[tikv] table:t1, partition:p4 range:(1,+inf], keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:TableRangeScan_17 + └─TableRangeScan_17 3333.33 cop[tikv] table:t1, partition:max range:(1,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 2 order by a; a 3 @@ -950,14 +950,14 @@ a 6 7 EXPLAIN SELECT * FROM t1 WHERE a > 2; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_11 3333.33 root data:TableRangeScan_10 -│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p3, range:(2,+inf], keep order:false, stats:pseudo -├─TableReader_13 3333.33 root data:TableRangeScan_12 -│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p4, range:(2,+inf], keep order:false, stats:pseudo -└─TableReader_15 3333.33 root data:TableRangeScan_14 - └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:max, range:(2,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_11 3333.33 root data:TableRangeScan_10 +│ └─TableRangeScan_10 3333.33 cop[tikv] table:t1, partition:p3 range:(2,+inf], keep order:false, stats:pseudo +├─TableReader_13 3333.33 root data:TableRangeScan_12 +│ └─TableRangeScan_12 3333.33 cop[tikv] table:t1, partition:p4 range:(2,+inf], keep order:false, stats:pseudo +└─TableReader_15 3333.33 root data:TableRangeScan_14 + └─TableRangeScan_14 3333.33 cop[tikv] table:t1, partition:max range:(2,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 3 order by a; a 4 @@ -965,36 +965,36 @@ a 6 7 EXPLAIN SELECT * FROM t1 WHERE a > 3; -id estRows task operator info -Union_8 6666.67 root -├─TableReader_10 3333.33 root data:TableRangeScan_9 -│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p4, range:(3,+inf], keep order:false, stats:pseudo -└─TableReader_12 3333.33 root data:TableRangeScan_11 - └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:max, range:(3,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6666.67 root +├─TableReader_10 3333.33 root data:TableRangeScan_9 +│ └─TableRangeScan_9 3333.33 cop[tikv] table:t1, partition:p4 range:(3,+inf], keep order:false, stats:pseudo +└─TableReader_12 3333.33 root data:TableRangeScan_11 + └─TableRangeScan_11 3333.33 cop[tikv] table:t1, partition:max range:(3,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 4 order by a; a 5 6 7 EXPLAIN SELECT * FROM t1 WHERE a > 4; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:(4,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:(4,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 5 order by a; a 6 7 EXPLAIN SELECT * FROM t1 WHERE a > 5; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:(5,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:(5,+inf], keep order:false, stats:pseudo SELECT * FROM t1 WHERE a > 6 order by a; a 7 EXPLAIN SELECT * FROM t1 WHERE a > 6; -id estRows task operator info -TableReader_7 3333.33 root data:TableRangeScan_6 -└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max, range:(6,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_7 3333.33 root data:TableRangeScan_6 +└─TableRangeScan_6 3333.33 cop[tikv] table:t1, partition:max range:(6,+inf], keep order:false, stats:pseudo DROP TABLE t1; # test of RANGE and index CREATE TABLE t1 (a DATE, KEY(a)) @@ -1025,444 +1025,444 @@ INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), (1, '2009-04-03'), (2, '2009-04-03'), (1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03'; -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03'; -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03'; -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03'; -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03'; -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo DROP TABLE t1; # Test with DATE column NOT NULL CREATE TABLE t1 ( @@ -1480,444 +1480,444 @@ INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), (1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -IndexReader_11 0.00 root index:Selection_10 -└─Selection_10 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 0.00 root index:Selection_10 +└─Selection_10 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -id estRows task operator info -IndexReader_11 0.00 root index:Selection_10 -└─Selection_10 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 0.00 root index:Selection_10 +└─Selection_10 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03'; -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03'; -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03'; -id estRows task operator info -IndexReader_11 10.00 root index:Selection_10 -└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 10.00 root index:Selection_10 +└─Selection_10 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03'; -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03'; -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─IndexReader_15 3323.33 root index:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3323.33 root index:Selection_20 -│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3323.33 root index:Selection_26 - └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─IndexReader_15 3323.33 root index:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3323.33 root index:Selection_20 +│ └─Selection_20 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3323.33 root index:Selection_26 + └─Selection_26 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -IndexReader_11 0.00 root index:Selection_10 -└─Selection_10 0.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 0.00 root index:Selection_10 +└─Selection_10 0.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─IndexReader_15 3333.33 root index:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_21 3333.33 root index:Selection_20 -│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) -│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_27 3333.33 root index:Selection_26 - └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─IndexReader_15 3333.33 root index:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_21 3333.33 root index:Selection_20 +│ └─Selection_20 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) +│ └─IndexFullScan_19 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_27 3333.33 root index:Selection_26 + └─Selection_26 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) + └─IndexFullScan_25 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─IndexReader_14 3323.33 root index:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:a, b, keep order:false, stats:pseudo -└─IndexReader_20 3323.33 root index:Selection_19 - └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─IndexReader_14 3323.33 root index:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_20 3323.33 root index:Selection_19 + └─Selection_19 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -IndexReader_11 0.00 root index:Selection_10 -└─Selection_10 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +IndexReader_11 0.00 root index:Selection_10 +└─Selection_10 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─IndexReader_16 3333.33 root index:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:a, b, keep order:false, stats:pseudo -├─IndexReader_22 3333.33 root index:Selection_21 -│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:a, b, keep order:false, stats:pseudo -├─IndexReader_28 3333.33 root index:Selection_27 -│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:a, b, keep order:false, stats:pseudo -└─IndexReader_34 3333.33 root index:Selection_33 - └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:a, b, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─IndexReader_16 3333.33 root index:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090402, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_22 3333.33 root index:Selection_21 +│ └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090403, index:PRIMARY(a, b) keep order:false, stats:pseudo +├─IndexReader_28 3333.33 root index:Selection_27 +│ └─Selection_27 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─IndexFullScan_26 10000.00 cop[tikv] table:t1, partition:p20090404, index:PRIMARY(a, b) keep order:false, stats:pseudo +└─IndexReader_34 3333.33 root index:Selection_33 + └─Selection_33 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) + └─IndexFullScan_32 10000.00 cop[tikv] table:t1, partition:p20090405, index:PRIMARY(a, b) keep order:false, stats:pseudo DROP TABLE t1; # Test with DATETIME column NULL CREATE TABLE t1 ( @@ -1934,444 +1934,444 @@ INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), (1, '2009-04-03'), (2, '2009-04-03'), (1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03'; -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03'; -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03'; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03'; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03'; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo DROP TABLE t1; # Test with DATE column NULL CREATE TABLE t1 ( @@ -2388,444 +2388,444 @@ INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), (1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -TableReader_8 0.00 root data:Selection_7 -└─Selection_7 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 0.00 root data:Selection_7 +└─Selection_7 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -id estRows task operator info -TableReader_8 0.00 root data:Selection_7 -└─Selection_7 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 0.00 root data:Selection_7 +└─Selection_7 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03'; -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03'; -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03'; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03'; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03'; -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -TableReader_8 0.00 root data:Selection_7 -└─Selection_7 0.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 0.00 root data:Selection_7 +└─Selection_7 0.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task operator info -Union_9 10000.00 root -├─TableReader_12 3333.33 root data:Selection_11 -│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_15 3333.33 root data:Selection_14 -│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_18 3333.33 root data:Selection_17 - └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 10000.00 root +├─TableReader_12 3333.33 root data:Selection_11 +│ └─Selection_11 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_15 3333.33 root data:Selection_14 +│ └─Selection_14 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_18 3333.33 root data:Selection_17 + └─Selection_17 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -TableReader_8 0.00 root data:Selection_7 -└─Selection_7 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 0.00 root data:Selection_7 +└─Selection_7 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo DROP TABLE t1; # For better code coverage of the patch CREATE TABLE t1 ( @@ -2840,23 +2840,23 @@ PARTITION p20090405 VALUES LESS THAN MAXVALUE); INSERT INTO t1 VALUES (1, '2009-01-01'), (2, NULL); # test with an invalid date, which lead to item->null_value is set. EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-99' AS DATETIME); -id estRows task operator info -Union_11 0.00 root -├─TableReader_14 0.00 root data:Selection_13 -│ └─Selection_13 0.00 cop[tikv] lt(test.t1.b, NULL) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401, keep order:false, stats:pseudo -├─TableReader_17 0.00 root data:Selection_16 -│ └─Selection_16 0.00 cop[tikv] lt(test.t1.b, NULL) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t1, partition:p20090402, keep order:false, stats:pseudo -├─TableReader_20 0.00 root data:Selection_19 -│ └─Selection_19 0.00 cop[tikv] lt(test.t1.b, NULL) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090403, keep order:false, stats:pseudo -├─TableReader_23 0.00 root data:Selection_22 -│ └─Selection_22 0.00 cop[tikv] lt(test.t1.b, NULL) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t1, partition:p20090404, keep order:false, stats:pseudo -└─TableReader_26 0.00 root data:Selection_25 - └─Selection_25 0.00 cop[tikv] lt(test.t1.b, NULL) - └─TableFullScan_24 10000.00 cop[tikv] table:t1, partition:p20090405, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 0.00 root +├─TableReader_14 0.00 root data:Selection_13 +│ └─Selection_13 0.00 cop[tikv] lt(test.t1.b, NULL) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p20090401 keep order:false, stats:pseudo +├─TableReader_17 0.00 root data:Selection_16 +│ └─Selection_16 0.00 cop[tikv] lt(test.t1.b, NULL) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t1, partition:p20090402 keep order:false, stats:pseudo +├─TableReader_20 0.00 root data:Selection_19 +│ └─Selection_19 0.00 cop[tikv] lt(test.t1.b, NULL) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t1, partition:p20090403 keep order:false, stats:pseudo +├─TableReader_23 0.00 root data:Selection_22 +│ └─Selection_22 0.00 cop[tikv] lt(test.t1.b, NULL) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t1, partition:p20090404 keep order:false, stats:pseudo +└─TableReader_26 0.00 root data:Selection_25 + └─Selection_25 0.00 cop[tikv] lt(test.t1.b, NULL) + └─TableFullScan_24 10000.00 cop[tikv] table:t1, partition:p20090405 keep order:false, stats:pseudo DROP TABLE t1; CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, @@ -2879,41 +2879,41 @@ partition p1 values less than (20) ); insert into t3 values (5),(15); explain select * from t3 where a=11; -id estRows task operator info -Union_8 20.00 root -├─TableReader_11 10.00 root data:Selection_10 -│ └─Selection_10 10.00 cop[tikv] eq(test.t3.a, 11) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t3, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 10.00 root data:Selection_13 - └─Selection_13 10.00 cop[tikv] eq(test.t3.a, 11) - └─TableFullScan_12 10000.00 cop[tikv] table:t3, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 20.00 root +├─TableReader_11 10.00 root data:Selection_10 +│ └─Selection_10 10.00 cop[tikv] eq(test.t3.a, 11) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t3, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 10.00 root data:Selection_13 + └─Selection_13 10.00 cop[tikv] eq(test.t3.a, 11) + └─TableFullScan_12 10000.00 cop[tikv] table:t3, partition:p1 keep order:false, stats:pseudo explain select * from t3 where a=10; -id estRows task operator info -Union_8 20.00 root -├─TableReader_11 10.00 root data:Selection_10 -│ └─Selection_10 10.00 cop[tikv] eq(test.t3.a, 10) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t3, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 10.00 root data:Selection_13 - └─Selection_13 10.00 cop[tikv] eq(test.t3.a, 10) - └─TableFullScan_12 10000.00 cop[tikv] table:t3, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 20.00 root +├─TableReader_11 10.00 root data:Selection_10 +│ └─Selection_10 10.00 cop[tikv] eq(test.t3.a, 10) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t3, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 10.00 root data:Selection_13 + └─Selection_13 10.00 cop[tikv] eq(test.t3.a, 10) + └─TableFullScan_12 10000.00 cop[tikv] table:t3, partition:p1 keep order:false, stats:pseudo explain select * from t3 where a=20; -id estRows task operator info -Union_8 20.00 root -├─TableReader_11 10.00 root data:Selection_10 -│ └─Selection_10 10.00 cop[tikv] eq(test.t3.a, 20) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t3, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 10.00 root data:Selection_13 - └─Selection_13 10.00 cop[tikv] eq(test.t3.a, 20) - └─TableFullScan_12 10000.00 cop[tikv] table:t3, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 20.00 root +├─TableReader_11 10.00 root data:Selection_10 +│ └─Selection_10 10.00 cop[tikv] eq(test.t3.a, 20) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t3, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 10.00 root data:Selection_13 + └─Selection_13 10.00 cop[tikv] eq(test.t3.a, 20) + └─TableFullScan_12 10000.00 cop[tikv] table:t3, partition:p1 keep order:false, stats:pseudo explain select * from t3 where a=30; -id estRows task operator info -Union_8 20.00 root -├─TableReader_11 10.00 root data:Selection_10 -│ └─Selection_10 10.00 cop[tikv] eq(test.t3.a, 30) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t3, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 10.00 root data:Selection_13 - └─Selection_13 10.00 cop[tikv] eq(test.t3.a, 30) - └─TableFullScan_12 10000.00 cop[tikv] table:t3, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 20.00 root +├─TableReader_11 10.00 root data:Selection_10 +│ └─Selection_10 10.00 cop[tikv] eq(test.t3.a, 30) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t3, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 10.00 root data:Selection_13 + └─Selection_13 10.00 cop[tikv] eq(test.t3.a, 30) + └─TableFullScan_12 10000.00 cop[tikv] table:t3, partition:p1 keep order:false, stats:pseudo create table t7 (a int not null) partition by RANGE(a) ( partition p10 values less than (10), partition p30 values less than (30), @@ -2923,209 +2923,209 @@ partition p90 values less than (90) ); insert into t7 values (10),(30),(50); explain select * from t7 where a < 5; -id estRows task operator info -TableReader_8 3323.33 root data:Selection_7 -└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 5) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3323.33 root data:Selection_7 +└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 5) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a < 9; -id estRows task operator info -TableReader_8 3323.33 root data:Selection_7 -└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 9) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3323.33 root data:Selection_7 +└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 9) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a <= 9; -id estRows task operator info -TableReader_8 3323.33 root data:Selection_7 -└─Selection_7 3323.33 cop[tikv] le(test.t7.a, 9) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3323.33 root data:Selection_7 +└─Selection_7 3323.33 cop[tikv] le(test.t7.a, 9) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a = 9; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 9) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 9) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a >= 9; -id estRows task operator info -Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 -│ └─Selection_13 3333.33 cop[tikv] ge(test.t7.a, 9) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 -│ └─Selection_16 3333.33 cop[tikv] ge(test.t7.a, 9) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 -│ └─Selection_19 3333.33 cop[tikv] ge(test.t7.a, 9) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 -│ └─Selection_22 3333.33 cop[tikv] ge(test.t7.a, 9) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 - └─Selection_25 3333.33 cop[tikv] ge(test.t7.a, 9) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16666.67 root +├─TableReader_14 3333.33 root data:Selection_13 +│ └─Selection_13 3333.33 cop[tikv] ge(test.t7.a, 9) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:Selection_16 +│ └─Selection_16 3333.33 cop[tikv] ge(test.t7.a, 9) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3333.33 root data:Selection_19 +│ └─Selection_19 3333.33 cop[tikv] ge(test.t7.a, 9) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3333.33 root data:Selection_22 +│ └─Selection_22 3333.33 cop[tikv] ge(test.t7.a, 9) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3333.33 root data:Selection_25 + └─Selection_25 3333.33 cop[tikv] ge(test.t7.a, 9) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a > 9; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t7.a, 9) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t7.a, 9) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t7.a, 9) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t7.a, 9) - └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t7.a, 9) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t7.a, 9) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t7.a, 9) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t7.a, 9) + └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a < 10; -id estRows task operator info -TableReader_8 3323.33 root data:Selection_7 -└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 10) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3323.33 root data:Selection_7 +└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 10) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a <= 10; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.t7.a, 10) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 10) - └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.t7.a, 10) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 10) + └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo explain select * from t7 where a = 10; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 10) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 10) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo explain select * from t7 where a >= 10; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] ge(test.t7.a, 10) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t7.a, 10) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] ge(test.t7.a, 10) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] ge(test.t7.a, 10) - └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] ge(test.t7.a, 10) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t7.a, 10) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] ge(test.t7.a, 10) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] ge(test.t7.a, 10) + └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a > 10; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t7.a, 10) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t7.a, 10) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t7.a, 10) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t7.a, 10) - └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t7.a, 10) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t7.a, 10) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t7.a, 10) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t7.a, 10) + └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a < 89; -id estRows task operator info -Union_11 16616.67 root -├─TableReader_14 3323.33 root data:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t7.a, 89) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3323.33 root data:Selection_16 -│ └─Selection_16 3323.33 cop[tikv] lt(test.t7.a, 89) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3323.33 root data:Selection_19 -│ └─Selection_19 3323.33 cop[tikv] lt(test.t7.a, 89) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3323.33 root data:Selection_22 -│ └─Selection_22 3323.33 cop[tikv] lt(test.t7.a, 89) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3323.33 root data:Selection_25 - └─Selection_25 3323.33 cop[tikv] lt(test.t7.a, 89) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16616.67 root +├─TableReader_14 3323.33 root data:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t7.a, 89) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3323.33 root data:Selection_16 +│ └─Selection_16 3323.33 cop[tikv] lt(test.t7.a, 89) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3323.33 root data:Selection_19 +│ └─Selection_19 3323.33 cop[tikv] lt(test.t7.a, 89) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3323.33 root data:Selection_22 +│ └─Selection_22 3323.33 cop[tikv] lt(test.t7.a, 89) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3323.33 root data:Selection_25 + └─Selection_25 3323.33 cop[tikv] lt(test.t7.a, 89) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a <= 89; -id estRows task operator info -Union_11 16616.67 root -├─TableReader_14 3323.33 root data:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 89) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3323.33 root data:Selection_16 -│ └─Selection_16 3323.33 cop[tikv] le(test.t7.a, 89) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3323.33 root data:Selection_19 -│ └─Selection_19 3323.33 cop[tikv] le(test.t7.a, 89) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3323.33 root data:Selection_22 -│ └─Selection_22 3323.33 cop[tikv] le(test.t7.a, 89) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3323.33 root data:Selection_25 - └─Selection_25 3323.33 cop[tikv] le(test.t7.a, 89) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16616.67 root +├─TableReader_14 3323.33 root data:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 89) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3323.33 root data:Selection_16 +│ └─Selection_16 3323.33 cop[tikv] le(test.t7.a, 89) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3323.33 root data:Selection_19 +│ └─Selection_19 3323.33 cop[tikv] le(test.t7.a, 89) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3323.33 root data:Selection_22 +│ └─Selection_22 3323.33 cop[tikv] le(test.t7.a, 89) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3323.33 root data:Selection_25 + └─Selection_25 3323.33 cop[tikv] le(test.t7.a, 89) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a = 89; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 89) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 89) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a > 89; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a >= 89; -id estRows task operator info -TableReader_8 3333.33 root data:Selection_7 -└─Selection_7 3333.33 cop[tikv] ge(test.t7.a, 89) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3333.33 root data:Selection_7 +└─Selection_7 3333.33 cop[tikv] ge(test.t7.a, 89) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a < 90; -id estRows task operator info -Union_11 16616.67 root -├─TableReader_14 3323.33 root data:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t7.a, 90) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3323.33 root data:Selection_16 -│ └─Selection_16 3323.33 cop[tikv] lt(test.t7.a, 90) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3323.33 root data:Selection_19 -│ └─Selection_19 3323.33 cop[tikv] lt(test.t7.a, 90) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3323.33 root data:Selection_22 -│ └─Selection_22 3323.33 cop[tikv] lt(test.t7.a, 90) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3323.33 root data:Selection_25 - └─Selection_25 3323.33 cop[tikv] lt(test.t7.a, 90) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16616.67 root +├─TableReader_14 3323.33 root data:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t7.a, 90) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3323.33 root data:Selection_16 +│ └─Selection_16 3323.33 cop[tikv] lt(test.t7.a, 90) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3323.33 root data:Selection_19 +│ └─Selection_19 3323.33 cop[tikv] lt(test.t7.a, 90) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3323.33 root data:Selection_22 +│ └─Selection_22 3323.33 cop[tikv] lt(test.t7.a, 90) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3323.33 root data:Selection_25 + └─Selection_25 3323.33 cop[tikv] lt(test.t7.a, 90) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a <= 90; -id estRows task operator info -Union_11 16616.67 root -├─TableReader_14 3323.33 root data:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 90) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3323.33 root data:Selection_16 -│ └─Selection_16 3323.33 cop[tikv] le(test.t7.a, 90) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3323.33 root data:Selection_19 -│ └─Selection_19 3323.33 cop[tikv] le(test.t7.a, 90) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3323.33 root data:Selection_22 -│ └─Selection_22 3323.33 cop[tikv] le(test.t7.a, 90) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3323.33 root data:Selection_25 - └─Selection_25 3323.33 cop[tikv] le(test.t7.a, 90) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16616.67 root +├─TableReader_14 3323.33 root data:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 90) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3323.33 root data:Selection_16 +│ └─Selection_16 3323.33 cop[tikv] le(test.t7.a, 90) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3323.33 root data:Selection_19 +│ └─Selection_19 3323.33 cop[tikv] le(test.t7.a, 90) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3323.33 root data:Selection_22 +│ └─Selection_22 3323.33 cop[tikv] le(test.t7.a, 90) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3323.33 root data:Selection_25 + └─Selection_25 3323.33 cop[tikv] le(test.t7.a, 90) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a = 90; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a > 90; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a >= 90; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a > 91; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a > 11 and a < 29; -id estRows task operator info -TableReader_8 250.00 root data:Selection_7 -└─Selection_7 250.00 cop[tikv] gt(test.t7.a, 11), lt(test.t7.a, 29) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 250.00 root data:Selection_7 +└─Selection_7 250.00 cop[tikv] gt(test.t7.a, 11), lt(test.t7.a, 29) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo drop table t7; create table t7 (a int unsigned not null) partition by RANGE(a) ( partition p10 values less than (10), @@ -3136,209 +3136,209 @@ partition p90 values less than (90) ); insert into t7 values (10),(30),(50); explain select * from t7 where a < 5; -id estRows task operator info -TableReader_8 3323.33 root data:Selection_7 -└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 5) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3323.33 root data:Selection_7 +└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 5) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a < 9; -id estRows task operator info -TableReader_8 3323.33 root data:Selection_7 -└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 9) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3323.33 root data:Selection_7 +└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 9) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a <= 9; -id estRows task operator info -TableReader_8 3323.33 root data:Selection_7 -└─Selection_7 3323.33 cop[tikv] le(test.t7.a, 9) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3323.33 root data:Selection_7 +└─Selection_7 3323.33 cop[tikv] le(test.t7.a, 9) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a = 9; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 9) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 9) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a >= 9; -id estRows task operator info -Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 -│ └─Selection_13 3333.33 cop[tikv] ge(test.t7.a, 9) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 -│ └─Selection_16 3333.33 cop[tikv] ge(test.t7.a, 9) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 -│ └─Selection_19 3333.33 cop[tikv] ge(test.t7.a, 9) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 -│ └─Selection_22 3333.33 cop[tikv] ge(test.t7.a, 9) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 - └─Selection_25 3333.33 cop[tikv] ge(test.t7.a, 9) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16666.67 root +├─TableReader_14 3333.33 root data:Selection_13 +│ └─Selection_13 3333.33 cop[tikv] ge(test.t7.a, 9) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3333.33 root data:Selection_16 +│ └─Selection_16 3333.33 cop[tikv] ge(test.t7.a, 9) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3333.33 root data:Selection_19 +│ └─Selection_19 3333.33 cop[tikv] ge(test.t7.a, 9) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3333.33 root data:Selection_22 +│ └─Selection_22 3333.33 cop[tikv] ge(test.t7.a, 9) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3333.33 root data:Selection_25 + └─Selection_25 3333.33 cop[tikv] ge(test.t7.a, 9) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a > 9; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t7.a, 9) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t7.a, 9) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t7.a, 9) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t7.a, 9) - └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t7.a, 9) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t7.a, 9) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t7.a, 9) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t7.a, 9) + └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a < 10; -id estRows task operator info -TableReader_8 3323.33 root data:Selection_7 -└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 10) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3323.33 root data:Selection_7 +└─Selection_7 3323.33 cop[tikv] lt(test.t7.a, 10) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo explain select * from t7 where a <= 10; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.t7.a, 10) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 10) - └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.t7.a, 10) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 10) + └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo explain select * from t7 where a = 10; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 10) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 10) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo explain select * from t7 where a >= 10; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] ge(test.t7.a, 10) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] ge(test.t7.a, 10) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] ge(test.t7.a, 10) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] ge(test.t7.a, 10) - └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] ge(test.t7.a, 10) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] ge(test.t7.a, 10) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] ge(test.t7.a, 10) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] ge(test.t7.a, 10) + └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a > 10; -id estRows task operator info -Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 -│ └─Selection_12 3333.33 cop[tikv] gt(test.t7.a, 10) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 -│ └─Selection_15 3333.33 cop[tikv] gt(test.t7.a, 10) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 -│ └─Selection_18 3333.33 cop[tikv] gt(test.t7.a, 10) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 - └─Selection_21 3333.33 cop[tikv] gt(test.t7.a, 10) - └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 13333.33 root +├─TableReader_13 3333.33 root data:Selection_12 +│ └─Selection_12 3333.33 cop[tikv] gt(test.t7.a, 10) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_16 3333.33 root data:Selection_15 +│ └─Selection_15 3333.33 cop[tikv] gt(test.t7.a, 10) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_19 3333.33 root data:Selection_18 +│ └─Selection_18 3333.33 cop[tikv] gt(test.t7.a, 10) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_22 3333.33 root data:Selection_21 + └─Selection_21 3333.33 cop[tikv] gt(test.t7.a, 10) + └─TableFullScan_20 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a < 89; -id estRows task operator info -Union_11 16616.67 root -├─TableReader_14 3323.33 root data:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t7.a, 89) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3323.33 root data:Selection_16 -│ └─Selection_16 3323.33 cop[tikv] lt(test.t7.a, 89) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3323.33 root data:Selection_19 -│ └─Selection_19 3323.33 cop[tikv] lt(test.t7.a, 89) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3323.33 root data:Selection_22 -│ └─Selection_22 3323.33 cop[tikv] lt(test.t7.a, 89) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3323.33 root data:Selection_25 - └─Selection_25 3323.33 cop[tikv] lt(test.t7.a, 89) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16616.67 root +├─TableReader_14 3323.33 root data:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t7.a, 89) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3323.33 root data:Selection_16 +│ └─Selection_16 3323.33 cop[tikv] lt(test.t7.a, 89) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3323.33 root data:Selection_19 +│ └─Selection_19 3323.33 cop[tikv] lt(test.t7.a, 89) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3323.33 root data:Selection_22 +│ └─Selection_22 3323.33 cop[tikv] lt(test.t7.a, 89) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3323.33 root data:Selection_25 + └─Selection_25 3323.33 cop[tikv] lt(test.t7.a, 89) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a <= 89; -id estRows task operator info -Union_11 16616.67 root -├─TableReader_14 3323.33 root data:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 89) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3323.33 root data:Selection_16 -│ └─Selection_16 3323.33 cop[tikv] le(test.t7.a, 89) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3323.33 root data:Selection_19 -│ └─Selection_19 3323.33 cop[tikv] le(test.t7.a, 89) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3323.33 root data:Selection_22 -│ └─Selection_22 3323.33 cop[tikv] le(test.t7.a, 89) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3323.33 root data:Selection_25 - └─Selection_25 3323.33 cop[tikv] le(test.t7.a, 89) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16616.67 root +├─TableReader_14 3323.33 root data:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 89) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3323.33 root data:Selection_16 +│ └─Selection_16 3323.33 cop[tikv] le(test.t7.a, 89) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3323.33 root data:Selection_19 +│ └─Selection_19 3323.33 cop[tikv] le(test.t7.a, 89) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3323.33 root data:Selection_22 +│ └─Selection_22 3323.33 cop[tikv] le(test.t7.a, 89) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3323.33 root data:Selection_25 + └─Selection_25 3323.33 cop[tikv] le(test.t7.a, 89) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a = 89; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 89) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t7.a, 89) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a > 89; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a >= 89; -id estRows task operator info -TableReader_8 3333.33 root data:Selection_7 -└─Selection_7 3333.33 cop[tikv] ge(test.t7.a, 89) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 3333.33 root data:Selection_7 +└─Selection_7 3333.33 cop[tikv] ge(test.t7.a, 89) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a < 90; -id estRows task operator info -Union_11 16616.67 root -├─TableReader_14 3323.33 root data:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] lt(test.t7.a, 90) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3323.33 root data:Selection_16 -│ └─Selection_16 3323.33 cop[tikv] lt(test.t7.a, 90) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3323.33 root data:Selection_19 -│ └─Selection_19 3323.33 cop[tikv] lt(test.t7.a, 90) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3323.33 root data:Selection_22 -│ └─Selection_22 3323.33 cop[tikv] lt(test.t7.a, 90) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3323.33 root data:Selection_25 - └─Selection_25 3323.33 cop[tikv] lt(test.t7.a, 90) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16616.67 root +├─TableReader_14 3323.33 root data:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] lt(test.t7.a, 90) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3323.33 root data:Selection_16 +│ └─Selection_16 3323.33 cop[tikv] lt(test.t7.a, 90) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3323.33 root data:Selection_19 +│ └─Selection_19 3323.33 cop[tikv] lt(test.t7.a, 90) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3323.33 root data:Selection_22 +│ └─Selection_22 3323.33 cop[tikv] lt(test.t7.a, 90) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3323.33 root data:Selection_25 + └─Selection_25 3323.33 cop[tikv] lt(test.t7.a, 90) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a <= 90; -id estRows task operator info -Union_11 16616.67 root -├─TableReader_14 3323.33 root data:Selection_13 -│ └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 90) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10, keep order:false, stats:pseudo -├─TableReader_17 3323.33 root data:Selection_16 -│ └─Selection_16 3323.33 cop[tikv] le(test.t7.a, 90) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo -├─TableReader_20 3323.33 root data:Selection_19 -│ └─Selection_19 3323.33 cop[tikv] le(test.t7.a, 90) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50, keep order:false, stats:pseudo -├─TableReader_23 3323.33 root data:Selection_22 -│ └─Selection_22 3323.33 cop[tikv] le(test.t7.a, 90) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70, keep order:false, stats:pseudo -└─TableReader_26 3323.33 root data:Selection_25 - └─Selection_25 3323.33 cop[tikv] le(test.t7.a, 90) - └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16616.67 root +├─TableReader_14 3323.33 root data:Selection_13 +│ └─Selection_13 3323.33 cop[tikv] le(test.t7.a, 90) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t7, partition:p10 keep order:false, stats:pseudo +├─TableReader_17 3323.33 root data:Selection_16 +│ └─Selection_16 3323.33 cop[tikv] le(test.t7.a, 90) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo +├─TableReader_20 3323.33 root data:Selection_19 +│ └─Selection_19 3323.33 cop[tikv] le(test.t7.a, 90) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t7, partition:p50 keep order:false, stats:pseudo +├─TableReader_23 3323.33 root data:Selection_22 +│ └─Selection_22 3323.33 cop[tikv] le(test.t7.a, 90) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t7, partition:p70 keep order:false, stats:pseudo +└─TableReader_26 3323.33 root data:Selection_25 + └─Selection_25 3323.33 cop[tikv] le(test.t7.a, 90) + └─TableFullScan_24 10000.00 cop[tikv] table:t7, partition:p90 keep order:false, stats:pseudo explain select * from t7 where a = 90; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a > 90; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a >= 90; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a > 91; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t7 where a > 11 and a < 29; -id estRows task operator info -TableReader_8 250.00 root data:Selection_7 -└─Selection_7 250.00 cop[tikv] gt(test.t7.a, 11), lt(test.t7.a, 29) - └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p30, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 250.00 root data:Selection_7 +└─Selection_7 250.00 cop[tikv] gt(test.t7.a, 11), lt(test.t7.a, 29) + └─TableFullScan_6 10000.00 cop[tikv] table:t7, partition:p30 keep order:false, stats:pseudo create table t8 (a date not null) partition by RANGE(YEAR(a)) ( partition p0 values less than (1980), partition p1 values less than (1990), @@ -3346,17 +3346,17 @@ partition p2 values less than (2000) ); insert into t8 values ('1985-05-05'),('1995-05-05'); explain select * from t8 where a < '1980-02-02'; -id estRows task operator info -Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 -│ └─Selection_11 3323.33 cop[tikv] lt(test.t8.a, 1980-02-02 00:00:00.000000) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t8, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 -│ └─Selection_14 3323.33 cop[tikv] lt(test.t8.a, 1980-02-02 00:00:00.000000) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t8, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 - └─Selection_17 3323.33 cop[tikv] lt(test.t8.a, 1980-02-02 00:00:00.000000) - └─TableFullScan_16 10000.00 cop[tikv] table:t8, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 9970.00 root +├─TableReader_12 3323.33 root data:Selection_11 +│ └─Selection_11 3323.33 cop[tikv] lt(test.t8.a, 1980-02-02 00:00:00.000000) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t8, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 3323.33 root data:Selection_14 +│ └─Selection_14 3323.33 cop[tikv] lt(test.t8.a, 1980-02-02 00:00:00.000000) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t8, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 3323.33 root data:Selection_17 + └─Selection_17 3323.33 cop[tikv] lt(test.t8.a, 1980-02-02 00:00:00.000000) + └─TableFullScan_16 10000.00 cop[tikv] table:t8, partition:p2 keep order:false, stats:pseudo create table t9 (a date not null) partition by RANGE(TO_DAYS(a)) ( partition p0 values less than (732299), -- 2004-12-19 partition p1 values less than (732468), -- 2005-06-06 @@ -3364,23 +3364,23 @@ partition p2 values less than (732664) -- 2005-12-19 ); insert into t9 values ('2005-05-05'), ('2005-04-04'); explain select * from t9 where a < '2004-12-19'; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] lt(test.t9.a, 2004-12-19 00:00:00.000000) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t9, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] lt(test.t9.a, 2004-12-19 00:00:00.000000) - └─TableFullScan_12 10000.00 cop[tikv] table:t9, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] lt(test.t9.a, 2004-12-19 00:00:00.000000) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t9, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] lt(test.t9.a, 2004-12-19 00:00:00.000000) + └─TableFullScan_12 10000.00 cop[tikv] table:t9, partition:p1 keep order:false, stats:pseudo explain select * from t9 where a <= '2004-12-19'; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] le(test.t9.a, 2004-12-19 00:00:00.000000) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t9, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] le(test.t9.a, 2004-12-19 00:00:00.000000) - └─TableFullScan_12 10000.00 cop[tikv] table:t9, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] le(test.t9.a, 2004-12-19 00:00:00.000000) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t9, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] le(test.t9.a, 2004-12-19 00:00:00.000000) + └─TableFullScan_12 10000.00 cop[tikv] table:t9, partition:p1 keep order:false, stats:pseudo drop table t7,t8,t9; create table t1 ( a1 int not null @@ -3392,26 +3392,26 @@ partition p2 values less than (9) ); insert into t1 values (1),(2),(3); explain select * from t1 where a1 > 3; -id estRows task operator info -Union_8 6666.67 root -├─TableReader_11 3333.33 root data:Selection_10 -│ └─Selection_10 3333.33 cop[tikv] gt(test.t1.a1, 3) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo -└─TableReader_14 3333.33 root data:Selection_13 - └─Selection_13 3333.33 cop[tikv] gt(test.t1.a1, 3) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6666.67 root +├─TableReader_11 3333.33 root data:Selection_10 +│ └─Selection_10 3333.33 cop[tikv] gt(test.t1.a1, 3) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo +└─TableReader_14 3333.33 root data:Selection_13 + └─Selection_13 3333.33 cop[tikv] gt(test.t1.a1, 3) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo explain select * from t1 where a1 >= 3; -id estRows task operator info -Union_8 6666.67 root -├─TableReader_11 3333.33 root data:Selection_10 -│ └─Selection_10 3333.33 cop[tikv] ge(test.t1.a1, 3) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo -└─TableReader_14 3333.33 root data:Selection_13 - └─Selection_13 3333.33 cop[tikv] ge(test.t1.a1, 3) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6666.67 root +├─TableReader_11 3333.33 root data:Selection_10 +│ └─Selection_10 3333.33 cop[tikv] ge(test.t1.a1, 3) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo +└─TableReader_14 3333.33 root data:Selection_13 + └─Selection_13 3333.33 cop[tikv] ge(test.t1.a1, 3) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo explain select * from t1 where a1 < 3 and a1 > 3; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 drop table t1; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -3440,92 +3440,92 @@ insert into t2 select a,3 from t1 where a >= 400 and a < 600; insert into t2 select a,4 from t1 where a >= 600 and a < 800; insert into t2 select a,5 from t1 where a >= 800 and a < 1001; explain select * from t2; -id estRows task operator info -Union_10 50000.00 root -├─TableReader_12 10000.00 root data:TableFullScan_11 -│ └─TableFullScan_11 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_14 10000.00 root data:TableFullScan_13 -│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─TableReader_16 10000.00 root data:TableFullScan_15 -│ └─TableFullScan_15 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─TableReader_18 10000.00 root data:TableFullScan_17 -│ └─TableFullScan_17 10000.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─TableReader_20 10000.00 root data:TableFullScan_19 - └─TableFullScan_19 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 50000.00 root +├─TableReader_12 10000.00 root data:TableFullScan_11 +│ └─TableFullScan_11 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_14 10000.00 root data:TableFullScan_13 +│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─TableReader_16 10000.00 root data:TableFullScan_15 +│ └─TableFullScan_15 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─TableReader_18 10000.00 root data:TableFullScan_17 +│ └─TableFullScan_17 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─TableReader_20 10000.00 root data:TableFullScan_19 + └─TableFullScan_19 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where a < 801 and a > 200; -id estRows task operator info -Union_10 1000.00 root -├─TableReader_13 250.00 root data:Selection_12 -│ └─Selection_12 250.00 cop[tikv] gt(test.t2.a, 200), lt(test.t2.a, 801) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─TableReader_16 250.00 root data:Selection_15 -│ └─Selection_15 250.00 cop[tikv] gt(test.t2.a, 200), lt(test.t2.a, 801) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─TableReader_19 250.00 root data:Selection_18 -│ └─Selection_18 250.00 cop[tikv] gt(test.t2.a, 200), lt(test.t2.a, 801) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─TableReader_22 250.00 root data:Selection_21 - └─Selection_21 250.00 cop[tikv] gt(test.t2.a, 200), lt(test.t2.a, 801) - └─TableFullScan_20 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 1000.00 root +├─TableReader_13 250.00 root data:Selection_12 +│ └─Selection_12 250.00 cop[tikv] gt(test.t2.a, 200), lt(test.t2.a, 801) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─TableReader_16 250.00 root data:Selection_15 +│ └─Selection_15 250.00 cop[tikv] gt(test.t2.a, 200), lt(test.t2.a, 801) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─TableReader_19 250.00 root data:Selection_18 +│ └─Selection_18 250.00 cop[tikv] gt(test.t2.a, 200), lt(test.t2.a, 801) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─TableReader_22 250.00 root data:Selection_21 + └─Selection_21 250.00 cop[tikv] gt(test.t2.a, 200), lt(test.t2.a, 801) + └─TableFullScan_20 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where a < 801 and a > 800; -id estRows task operator info -TableReader_8 0.00 root data:Selection_7 -└─Selection_7 0.00 cop[tikv] gt(test.t2.a, 800), lt(test.t2.a, 801) - └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 0.00 root data:Selection_7 +└─Selection_7 0.00 cop[tikv] gt(test.t2.a, 800), lt(test.t2.a, 801) + └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where a > 600; -id estRows task operator info -Union_8 6666.67 root -├─TableReader_11 3333.33 root data:Selection_10 -│ └─Selection_10 3333.33 cop[tikv] gt(test.t2.a, 600) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─TableReader_14 3333.33 root data:Selection_13 - └─Selection_13 3333.33 cop[tikv] gt(test.t2.a, 600) - └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6666.67 root +├─TableReader_11 3333.33 root data:Selection_10 +│ └─Selection_10 3333.33 cop[tikv] gt(test.t2.a, 600) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─TableReader_14 3333.33 root data:Selection_13 + └─Selection_13 3333.33 cop[tikv] gt(test.t2.a, 600) + └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where a > 600 and b = 1; -id estRows task operator info -Union_8 6.67 root -├─TableReader_11 3.33 root data:Selection_10 -│ └─Selection_10 3.33 cop[tikv] eq(test.t2.b, 1), gt(test.t2.a, 600) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─TableReader_14 3.33 root data:Selection_13 - └─Selection_13 3.33 cop[tikv] eq(test.t2.b, 1), gt(test.t2.a, 600) - └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6.67 root +├─TableReader_11 3.33 root data:Selection_10 +│ └─Selection_10 3.33 cop[tikv] eq(test.t2.b, 1), gt(test.t2.a, 600) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─TableReader_14 3.33 root data:Selection_13 + └─Selection_13 3.33 cop[tikv] eq(test.t2.b, 1), gt(test.t2.a, 600) + └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where a > 600 and b = 4; -id estRows task operator info -Union_8 6.67 root -├─TableReader_11 3.33 root data:Selection_10 -│ └─Selection_10 3.33 cop[tikv] eq(test.t2.b, 4), gt(test.t2.a, 600) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─TableReader_14 3.33 root data:Selection_13 - └─Selection_13 3.33 cop[tikv] eq(test.t2.b, 4), gt(test.t2.a, 600) - └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6.67 root +├─TableReader_11 3.33 root data:Selection_10 +│ └─Selection_10 3.33 cop[tikv] eq(test.t2.b, 4), gt(test.t2.a, 600) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─TableReader_14 3.33 root data:Selection_13 + └─Selection_13 3.33 cop[tikv] eq(test.t2.b, 4), gt(test.t2.a, 600) + └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where a > 600 and b = 5; -id estRows task operator info -Union_8 6.67 root -├─TableReader_11 3.33 root data:Selection_10 -│ └─Selection_10 3.33 cop[tikv] eq(test.t2.b, 5), gt(test.t2.a, 600) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─TableReader_14 3.33 root data:Selection_13 - └─Selection_13 3.33 cop[tikv] eq(test.t2.b, 5), gt(test.t2.a, 600) - └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6.67 root +├─TableReader_11 3.33 root data:Selection_10 +│ └─Selection_10 3.33 cop[tikv] eq(test.t2.b, 5), gt(test.t2.a, 600) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─TableReader_14 3.33 root data:Selection_13 + └─Selection_13 3.33 cop[tikv] eq(test.t2.b, 5), gt(test.t2.a, 600) + └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where b = 5; -id estRows task operator info -Union_11 50.00 root -├─TableReader_14 10.00 root data:Selection_13 -│ └─Selection_13 10.00 cop[tikv] eq(test.t2.b, 5) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_17 10.00 root data:Selection_16 -│ └─Selection_16 10.00 cop[tikv] eq(test.t2.b, 5) -│ └─TableFullScan_15 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─TableReader_20 10.00 root data:Selection_19 -│ └─Selection_19 10.00 cop[tikv] eq(test.t2.b, 5) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─TableReader_23 10.00 root data:Selection_22 -│ └─Selection_22 10.00 cop[tikv] eq(test.t2.b, 5) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─TableReader_26 10.00 root data:Selection_25 - └─Selection_25 10.00 cop[tikv] eq(test.t2.b, 5) - └─TableFullScan_24 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 50.00 root +├─TableReader_14 10.00 root data:Selection_13 +│ └─Selection_13 10.00 cop[tikv] eq(test.t2.b, 5) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_17 10.00 root data:Selection_16 +│ └─Selection_16 10.00 cop[tikv] eq(test.t2.b, 5) +│ └─TableFullScan_15 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─TableReader_20 10.00 root data:Selection_19 +│ └─Selection_19 10.00 cop[tikv] eq(test.t2.b, 5) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─TableReader_23 10.00 root data:Selection_22 +│ └─Selection_22 10.00 cop[tikv] eq(test.t2.b, 5) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─TableReader_26 10.00 root data:Selection_25 + └─Selection_25 10.00 cop[tikv] eq(test.t2.b, 5) + └─TableFullScan_24 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo flush status; update t2 set b = 100 where b = 6; show status like 'Handler_read_rnd_next'; @@ -3568,216 +3568,216 @@ insert into t2 select a,7 from t1 where a >= 700 and a < 800; insert into t2 select a,8 from t1 where a >= 800 and a < 900; insert into t2 select a,9 from t1 where a >= 900 and a < 1001; explain select * from t2; -id estRows task operator info -Union_10 50000.00 root -├─TableReader_12 10000.00 root data:TableFullScan_11 -│ └─TableFullScan_11 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_14 10000.00 root data:TableFullScan_13 -│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─TableReader_16 10000.00 root data:TableFullScan_15 -│ └─TableFullScan_15 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─TableReader_18 10000.00 root data:TableFullScan_17 -│ └─TableFullScan_17 10000.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─TableReader_20 10000.00 root data:TableFullScan_19 - └─TableFullScan_19 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 50000.00 root +├─TableReader_12 10000.00 root data:TableFullScan_11 +│ └─TableFullScan_11 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_14 10000.00 root data:TableFullScan_13 +│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─TableReader_16 10000.00 root data:TableFullScan_15 +│ └─TableFullScan_15 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─TableReader_18 10000.00 root data:TableFullScan_17 +│ └─TableFullScan_17 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─TableReader_20 10000.00 root data:TableFullScan_19 + └─TableFullScan_19 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where a = 101; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t2.a, 101) - └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t2.a, 101) + └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo explain select * from t2 where a = 550; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t2.a, 550) - └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t2.a, 550) + └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo explain select * from t2 where a = 833; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t2.a, 833) - └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t2.a, 833) + └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where (a = 100 OR a = 900); -id estRows task operator info -Union_8 40.00 root -├─TableReader_11 20.00 root data:Selection_10 -│ └─Selection_10 20.00 cop[tikv] or(eq(test.t2.a, 100), eq(test.t2.a, 900)) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 20.00 root data:Selection_13 - └─Selection_13 20.00 cop[tikv] or(eq(test.t2.a, 100), eq(test.t2.a, 900)) - └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 40.00 root +├─TableReader_11 20.00 root data:Selection_10 +│ └─Selection_10 20.00 cop[tikv] or(eq(test.t2.a, 100), eq(test.t2.a, 900)) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 20.00 root data:Selection_13 + └─Selection_13 20.00 cop[tikv] or(eq(test.t2.a, 100), eq(test.t2.a, 900)) + └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where (a > 100 AND a < 600); -id estRows task operator info -Union_9 750.00 root -├─TableReader_12 250.00 root data:Selection_11 -│ └─Selection_11 250.00 cop[tikv] gt(test.t2.a, 100), lt(test.t2.a, 600) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 250.00 root data:Selection_14 -│ └─Selection_14 250.00 cop[tikv] gt(test.t2.a, 100), lt(test.t2.a, 600) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 250.00 root data:Selection_17 - └─Selection_17 250.00 cop[tikv] gt(test.t2.a, 100), lt(test.t2.a, 600) - └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 750.00 root +├─TableReader_12 250.00 root data:Selection_11 +│ └─Selection_11 250.00 cop[tikv] gt(test.t2.a, 100), lt(test.t2.a, 600) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 250.00 root data:Selection_14 +│ └─Selection_14 250.00 cop[tikv] gt(test.t2.a, 100), lt(test.t2.a, 600) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 250.00 root data:Selection_17 + └─Selection_17 250.00 cop[tikv] gt(test.t2.a, 100), lt(test.t2.a, 600) + └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo explain select * from t2 where b = 4; -id estRows task operator info -Union_11 50.00 root -├─IndexLookUp_17 10.00 root -│ ├─IndexRangeScan_15(Build) 10.00 cop[tikv] table:t2, partition:p0, index:b, range:[4,4], keep order:false, stats:pseudo -│ └─TableRowIDScan_16(Probe) 10.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─IndexLookUp_23 10.00 root -│ ├─IndexRangeScan_21(Build) 10.00 cop[tikv] table:t2, partition:p1, index:b, range:[4,4], keep order:false, stats:pseudo -│ └─TableRowIDScan_22(Probe) 10.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─IndexLookUp_29 10.00 root -│ ├─IndexRangeScan_27(Build) 10.00 cop[tikv] table:t2, partition:p2, index:b, range:[4,4], keep order:false, stats:pseudo -│ └─TableRowIDScan_28(Probe) 10.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─IndexLookUp_35 10.00 root -│ ├─IndexRangeScan_33(Build) 10.00 cop[tikv] table:t2, partition:p3, index:b, range:[4,4], keep order:false, stats:pseudo -│ └─TableRowIDScan_34(Probe) 10.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─IndexLookUp_41 10.00 root - ├─IndexRangeScan_39(Build) 10.00 cop[tikv] table:t2, partition:p4, index:b, range:[4,4], keep order:false, stats:pseudo - └─TableRowIDScan_40(Probe) 10.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 50.00 root +├─IndexLookUp_17 10.00 root +│ ├─IndexRangeScan_15(Build) 10.00 cop[tikv] table:t2, partition:p0, index:b(b) range:[4,4], keep order:false, stats:pseudo +│ └─TableRowIDScan_16(Probe) 10.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─IndexLookUp_23 10.00 root +│ ├─IndexRangeScan_21(Build) 10.00 cop[tikv] table:t2, partition:p1, index:b(b) range:[4,4], keep order:false, stats:pseudo +│ └─TableRowIDScan_22(Probe) 10.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─IndexLookUp_29 10.00 root +│ ├─IndexRangeScan_27(Build) 10.00 cop[tikv] table:t2, partition:p2, index:b(b) range:[4,4], keep order:false, stats:pseudo +│ └─TableRowIDScan_28(Probe) 10.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─IndexLookUp_35 10.00 root +│ ├─IndexRangeScan_33(Build) 10.00 cop[tikv] table:t2, partition:p3, index:b(b) range:[4,4], keep order:false, stats:pseudo +│ └─TableRowIDScan_34(Probe) 10.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─IndexLookUp_41 10.00 root + ├─IndexRangeScan_39(Build) 10.00 cop[tikv] table:t2, partition:p4, index:b(b) range:[4,4], keep order:false, stats:pseudo + └─TableRowIDScan_40(Probe) 10.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where b = 6; -id estRows task operator info -Union_11 50.00 root -├─IndexLookUp_17 10.00 root -│ ├─IndexRangeScan_15(Build) 10.00 cop[tikv] table:t2, partition:p0, index:b, range:[6,6], keep order:false, stats:pseudo -│ └─TableRowIDScan_16(Probe) 10.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─IndexLookUp_23 10.00 root -│ ├─IndexRangeScan_21(Build) 10.00 cop[tikv] table:t2, partition:p1, index:b, range:[6,6], keep order:false, stats:pseudo -│ └─TableRowIDScan_22(Probe) 10.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─IndexLookUp_29 10.00 root -│ ├─IndexRangeScan_27(Build) 10.00 cop[tikv] table:t2, partition:p2, index:b, range:[6,6], keep order:false, stats:pseudo -│ └─TableRowIDScan_28(Probe) 10.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─IndexLookUp_35 10.00 root -│ ├─IndexRangeScan_33(Build) 10.00 cop[tikv] table:t2, partition:p3, index:b, range:[6,6], keep order:false, stats:pseudo -│ └─TableRowIDScan_34(Probe) 10.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─IndexLookUp_41 10.00 root - ├─IndexRangeScan_39(Build) 10.00 cop[tikv] table:t2, partition:p4, index:b, range:[6,6], keep order:false, stats:pseudo - └─TableRowIDScan_40(Probe) 10.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 50.00 root +├─IndexLookUp_17 10.00 root +│ ├─IndexRangeScan_15(Build) 10.00 cop[tikv] table:t2, partition:p0, index:b(b) range:[6,6], keep order:false, stats:pseudo +│ └─TableRowIDScan_16(Probe) 10.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─IndexLookUp_23 10.00 root +│ ├─IndexRangeScan_21(Build) 10.00 cop[tikv] table:t2, partition:p1, index:b(b) range:[6,6], keep order:false, stats:pseudo +│ └─TableRowIDScan_22(Probe) 10.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─IndexLookUp_29 10.00 root +│ ├─IndexRangeScan_27(Build) 10.00 cop[tikv] table:t2, partition:p2, index:b(b) range:[6,6], keep order:false, stats:pseudo +│ └─TableRowIDScan_28(Probe) 10.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─IndexLookUp_35 10.00 root +│ ├─IndexRangeScan_33(Build) 10.00 cop[tikv] table:t2, partition:p3, index:b(b) range:[6,6], keep order:false, stats:pseudo +│ └─TableRowIDScan_34(Probe) 10.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─IndexLookUp_41 10.00 root + ├─IndexRangeScan_39(Build) 10.00 cop[tikv] table:t2, partition:p4, index:b(b) range:[6,6], keep order:false, stats:pseudo + └─TableRowIDScan_40(Probe) 10.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where b in (1,3,5); -id estRows task operator info -Union_11 150.00 root -├─IndexLookUp_17 30.00 root -│ ├─IndexRangeScan_15(Build) 30.00 cop[tikv] table:t2, partition:p0, index:b, range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo -│ └─TableRowIDScan_16(Probe) 30.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─IndexLookUp_23 30.00 root -│ ├─IndexRangeScan_21(Build) 30.00 cop[tikv] table:t2, partition:p1, index:b, range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo -│ └─TableRowIDScan_22(Probe) 30.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─IndexLookUp_29 30.00 root -│ ├─IndexRangeScan_27(Build) 30.00 cop[tikv] table:t2, partition:p2, index:b, range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo -│ └─TableRowIDScan_28(Probe) 30.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─IndexLookUp_35 30.00 root -│ ├─IndexRangeScan_33(Build) 30.00 cop[tikv] table:t2, partition:p3, index:b, range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo -│ └─TableRowIDScan_34(Probe) 30.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─IndexLookUp_41 30.00 root - ├─IndexRangeScan_39(Build) 30.00 cop[tikv] table:t2, partition:p4, index:b, range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo - └─TableRowIDScan_40(Probe) 30.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 150.00 root +├─IndexLookUp_17 30.00 root +│ ├─IndexRangeScan_15(Build) 30.00 cop[tikv] table:t2, partition:p0, index:b(b) range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo +│ └─TableRowIDScan_16(Probe) 30.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─IndexLookUp_23 30.00 root +│ ├─IndexRangeScan_21(Build) 30.00 cop[tikv] table:t2, partition:p1, index:b(b) range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo +│ └─TableRowIDScan_22(Probe) 30.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─IndexLookUp_29 30.00 root +│ ├─IndexRangeScan_27(Build) 30.00 cop[tikv] table:t2, partition:p2, index:b(b) range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo +│ └─TableRowIDScan_28(Probe) 30.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─IndexLookUp_35 30.00 root +│ ├─IndexRangeScan_33(Build) 30.00 cop[tikv] table:t2, partition:p3, index:b(b) range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo +│ └─TableRowIDScan_34(Probe) 30.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─IndexLookUp_41 30.00 root + ├─IndexRangeScan_39(Build) 30.00 cop[tikv] table:t2, partition:p4, index:b(b) range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo + └─TableRowIDScan_40(Probe) 30.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where b in (2,4,6); -id estRows task operator info -Union_11 150.00 root -├─IndexLookUp_17 30.00 root -│ ├─IndexRangeScan_15(Build) 30.00 cop[tikv] table:t2, partition:p0, index:b, range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo -│ └─TableRowIDScan_16(Probe) 30.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─IndexLookUp_23 30.00 root -│ ├─IndexRangeScan_21(Build) 30.00 cop[tikv] table:t2, partition:p1, index:b, range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo -│ └─TableRowIDScan_22(Probe) 30.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─IndexLookUp_29 30.00 root -│ ├─IndexRangeScan_27(Build) 30.00 cop[tikv] table:t2, partition:p2, index:b, range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo -│ └─TableRowIDScan_28(Probe) 30.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─IndexLookUp_35 30.00 root -│ ├─IndexRangeScan_33(Build) 30.00 cop[tikv] table:t2, partition:p3, index:b, range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo -│ └─TableRowIDScan_34(Probe) 30.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─IndexLookUp_41 30.00 root - ├─IndexRangeScan_39(Build) 30.00 cop[tikv] table:t2, partition:p4, index:b, range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo - └─TableRowIDScan_40(Probe) 30.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 150.00 root +├─IndexLookUp_17 30.00 root +│ ├─IndexRangeScan_15(Build) 30.00 cop[tikv] table:t2, partition:p0, index:b(b) range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo +│ └─TableRowIDScan_16(Probe) 30.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─IndexLookUp_23 30.00 root +│ ├─IndexRangeScan_21(Build) 30.00 cop[tikv] table:t2, partition:p1, index:b(b) range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo +│ └─TableRowIDScan_22(Probe) 30.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─IndexLookUp_29 30.00 root +│ ├─IndexRangeScan_27(Build) 30.00 cop[tikv] table:t2, partition:p2, index:b(b) range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo +│ └─TableRowIDScan_28(Probe) 30.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─IndexLookUp_35 30.00 root +│ ├─IndexRangeScan_33(Build) 30.00 cop[tikv] table:t2, partition:p3, index:b(b) range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo +│ └─TableRowIDScan_34(Probe) 30.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─IndexLookUp_41 30.00 root + ├─IndexRangeScan_39(Build) 30.00 cop[tikv] table:t2, partition:p4, index:b(b) range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo + └─TableRowIDScan_40(Probe) 30.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where b in (7,8,9); -id estRows task operator info -Union_11 150.00 root -├─IndexLookUp_17 30.00 root -│ ├─IndexRangeScan_15(Build) 30.00 cop[tikv] table:t2, partition:p0, index:b, range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo -│ └─TableRowIDScan_16(Probe) 30.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─IndexLookUp_23 30.00 root -│ ├─IndexRangeScan_21(Build) 30.00 cop[tikv] table:t2, partition:p1, index:b, range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo -│ └─TableRowIDScan_22(Probe) 30.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─IndexLookUp_29 30.00 root -│ ├─IndexRangeScan_27(Build) 30.00 cop[tikv] table:t2, partition:p2, index:b, range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo -│ └─TableRowIDScan_28(Probe) 30.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─IndexLookUp_35 30.00 root -│ ├─IndexRangeScan_33(Build) 30.00 cop[tikv] table:t2, partition:p3, index:b, range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo -│ └─TableRowIDScan_34(Probe) 30.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─IndexLookUp_41 30.00 root - ├─IndexRangeScan_39(Build) 30.00 cop[tikv] table:t2, partition:p4, index:b, range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo - └─TableRowIDScan_40(Probe) 30.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 150.00 root +├─IndexLookUp_17 30.00 root +│ ├─IndexRangeScan_15(Build) 30.00 cop[tikv] table:t2, partition:p0, index:b(b) range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo +│ └─TableRowIDScan_16(Probe) 30.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─IndexLookUp_23 30.00 root +│ ├─IndexRangeScan_21(Build) 30.00 cop[tikv] table:t2, partition:p1, index:b(b) range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo +│ └─TableRowIDScan_22(Probe) 30.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─IndexLookUp_29 30.00 root +│ ├─IndexRangeScan_27(Build) 30.00 cop[tikv] table:t2, partition:p2, index:b(b) range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo +│ └─TableRowIDScan_28(Probe) 30.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─IndexLookUp_35 30.00 root +│ ├─IndexRangeScan_33(Build) 30.00 cop[tikv] table:t2, partition:p3, index:b(b) range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo +│ └─TableRowIDScan_34(Probe) 30.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─IndexLookUp_41 30.00 root + ├─IndexRangeScan_39(Build) 30.00 cop[tikv] table:t2, partition:p4, index:b(b) range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo + └─TableRowIDScan_40(Probe) 30.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where b > 5; -id estRows task operator info -Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 -│ └─Selection_13 3333.33 cop[tikv] gt(test.t2.b, 5) -│ └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 -│ └─Selection_19 3333.33 cop[tikv] gt(test.t2.b, 5) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─TableReader_26 3333.33 root data:Selection_25 -│ └─Selection_25 3333.33 cop[tikv] gt(test.t2.b, 5) -│ └─TableFullScan_24 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─TableReader_32 3333.33 root data:Selection_31 -│ └─Selection_31 3333.33 cop[tikv] gt(test.t2.b, 5) -│ └─TableFullScan_30 10000.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─TableReader_38 3333.33 root data:Selection_37 - └─Selection_37 3333.33 cop[tikv] gt(test.t2.b, 5) - └─TableFullScan_36 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 16666.67 root +├─TableReader_14 3333.33 root data:Selection_13 +│ └─Selection_13 3333.33 cop[tikv] gt(test.t2.b, 5) +│ └─TableFullScan_12 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_20 3333.33 root data:Selection_19 +│ └─Selection_19 3333.33 cop[tikv] gt(test.t2.b, 5) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─TableReader_26 3333.33 root data:Selection_25 +│ └─Selection_25 3333.33 cop[tikv] gt(test.t2.b, 5) +│ └─TableFullScan_24 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─TableReader_32 3333.33 root data:Selection_31 +│ └─Selection_31 3333.33 cop[tikv] gt(test.t2.b, 5) +│ └─TableFullScan_30 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─TableReader_38 3333.33 root data:Selection_37 + └─Selection_37 3333.33 cop[tikv] gt(test.t2.b, 5) + └─TableFullScan_36 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where b > 5 and b < 8; -id estRows task operator info -Union_11 1250.00 root -├─IndexLookUp_17 250.00 root -│ ├─IndexRangeScan_15(Build) 250.00 cop[tikv] table:t2, partition:p0, index:b, range:(5,8), keep order:false, stats:pseudo -│ └─TableRowIDScan_16(Probe) 250.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─IndexLookUp_23 250.00 root -│ ├─IndexRangeScan_21(Build) 250.00 cop[tikv] table:t2, partition:p1, index:b, range:(5,8), keep order:false, stats:pseudo -│ └─TableRowIDScan_22(Probe) 250.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─IndexLookUp_29 250.00 root -│ ├─IndexRangeScan_27(Build) 250.00 cop[tikv] table:t2, partition:p2, index:b, range:(5,8), keep order:false, stats:pseudo -│ └─TableRowIDScan_28(Probe) 250.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─IndexLookUp_35 250.00 root -│ ├─IndexRangeScan_33(Build) 250.00 cop[tikv] table:t2, partition:p3, index:b, range:(5,8), keep order:false, stats:pseudo -│ └─TableRowIDScan_34(Probe) 250.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─IndexLookUp_41 250.00 root - ├─IndexRangeScan_39(Build) 250.00 cop[tikv] table:t2, partition:p4, index:b, range:(5,8), keep order:false, stats:pseudo - └─TableRowIDScan_40(Probe) 250.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 1250.00 root +├─IndexLookUp_17 250.00 root +│ ├─IndexRangeScan_15(Build) 250.00 cop[tikv] table:t2, partition:p0, index:b(b) range:(5,8), keep order:false, stats:pseudo +│ └─TableRowIDScan_16(Probe) 250.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─IndexLookUp_23 250.00 root +│ ├─IndexRangeScan_21(Build) 250.00 cop[tikv] table:t2, partition:p1, index:b(b) range:(5,8), keep order:false, stats:pseudo +│ └─TableRowIDScan_22(Probe) 250.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─IndexLookUp_29 250.00 root +│ ├─IndexRangeScan_27(Build) 250.00 cop[tikv] table:t2, partition:p2, index:b(b) range:(5,8), keep order:false, stats:pseudo +│ └─TableRowIDScan_28(Probe) 250.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─IndexLookUp_35 250.00 root +│ ├─IndexRangeScan_33(Build) 250.00 cop[tikv] table:t2, partition:p3, index:b(b) range:(5,8), keep order:false, stats:pseudo +│ └─TableRowIDScan_34(Probe) 250.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─IndexLookUp_41 250.00 root + ├─IndexRangeScan_39(Build) 250.00 cop[tikv] table:t2, partition:p4, index:b(b) range:(5,8), keep order:false, stats:pseudo + └─TableRowIDScan_40(Probe) 250.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where b > 5 and b < 7; -id estRows task operator info -Union_11 1250.00 root -├─IndexLookUp_17 250.00 root -│ ├─IndexRangeScan_15(Build) 250.00 cop[tikv] table:t2, partition:p0, index:b, range:(5,7), keep order:false, stats:pseudo -│ └─TableRowIDScan_16(Probe) 250.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─IndexLookUp_23 250.00 root -│ ├─IndexRangeScan_21(Build) 250.00 cop[tikv] table:t2, partition:p1, index:b, range:(5,7), keep order:false, stats:pseudo -│ └─TableRowIDScan_22(Probe) 250.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─IndexLookUp_29 250.00 root -│ ├─IndexRangeScan_27(Build) 250.00 cop[tikv] table:t2, partition:p2, index:b, range:(5,7), keep order:false, stats:pseudo -│ └─TableRowIDScan_28(Probe) 250.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─IndexLookUp_35 250.00 root -│ ├─IndexRangeScan_33(Build) 250.00 cop[tikv] table:t2, partition:p3, index:b, range:(5,7), keep order:false, stats:pseudo -│ └─TableRowIDScan_34(Probe) 250.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─IndexLookUp_41 250.00 root - ├─IndexRangeScan_39(Build) 250.00 cop[tikv] table:t2, partition:p4, index:b, range:(5,7), keep order:false, stats:pseudo - └─TableRowIDScan_40(Probe) 250.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 1250.00 root +├─IndexLookUp_17 250.00 root +│ ├─IndexRangeScan_15(Build) 250.00 cop[tikv] table:t2, partition:p0, index:b(b) range:(5,7), keep order:false, stats:pseudo +│ └─TableRowIDScan_16(Probe) 250.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─IndexLookUp_23 250.00 root +│ ├─IndexRangeScan_21(Build) 250.00 cop[tikv] table:t2, partition:p1, index:b(b) range:(5,7), keep order:false, stats:pseudo +│ └─TableRowIDScan_22(Probe) 250.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─IndexLookUp_29 250.00 root +│ ├─IndexRangeScan_27(Build) 250.00 cop[tikv] table:t2, partition:p2, index:b(b) range:(5,7), keep order:false, stats:pseudo +│ └─TableRowIDScan_28(Probe) 250.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─IndexLookUp_35 250.00 root +│ ├─IndexRangeScan_33(Build) 250.00 cop[tikv] table:t2, partition:p3, index:b(b) range:(5,7), keep order:false, stats:pseudo +│ └─TableRowIDScan_34(Probe) 250.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─IndexLookUp_41 250.00 root + ├─IndexRangeScan_39(Build) 250.00 cop[tikv] table:t2, partition:p4, index:b(b) range:(5,7), keep order:false, stats:pseudo + └─TableRowIDScan_40(Probe) 250.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo explain select * from t2 where b > 0 and b < 5; -id estRows task operator info -Union_11 1250.00 root -├─IndexLookUp_17 250.00 root -│ ├─IndexRangeScan_15(Build) 250.00 cop[tikv] table:t2, partition:p0, index:b, range:(0,5), keep order:false, stats:pseudo -│ └─TableRowIDScan_16(Probe) 250.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─IndexLookUp_23 250.00 root -│ ├─IndexRangeScan_21(Build) 250.00 cop[tikv] table:t2, partition:p1, index:b, range:(0,5), keep order:false, stats:pseudo -│ └─TableRowIDScan_22(Probe) 250.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -├─IndexLookUp_29 250.00 root -│ ├─IndexRangeScan_27(Build) 250.00 cop[tikv] table:t2, partition:p2, index:b, range:(0,5), keep order:false, stats:pseudo -│ └─TableRowIDScan_28(Probe) 250.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo -├─IndexLookUp_35 250.00 root -│ ├─IndexRangeScan_33(Build) 250.00 cop[tikv] table:t2, partition:p3, index:b, range:(0,5), keep order:false, stats:pseudo -│ └─TableRowIDScan_34(Probe) 250.00 cop[tikv] table:t2, partition:p3, keep order:false, stats:pseudo -└─IndexLookUp_41 250.00 root - ├─IndexRangeScan_39(Build) 250.00 cop[tikv] table:t2, partition:p4, index:b, range:(0,5), keep order:false, stats:pseudo - └─TableRowIDScan_40(Probe) 250.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_11 1250.00 root +├─IndexLookUp_17 250.00 root +│ ├─IndexRangeScan_15(Build) 250.00 cop[tikv] table:t2, partition:p0, index:b(b) range:(0,5), keep order:false, stats:pseudo +│ └─TableRowIDScan_16(Probe) 250.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─IndexLookUp_23 250.00 root +│ ├─IndexRangeScan_21(Build) 250.00 cop[tikv] table:t2, partition:p1, index:b(b) range:(0,5), keep order:false, stats:pseudo +│ └─TableRowIDScan_22(Probe) 250.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +├─IndexLookUp_29 250.00 root +│ ├─IndexRangeScan_27(Build) 250.00 cop[tikv] table:t2, partition:p2, index:b(b) range:(0,5), keep order:false, stats:pseudo +│ └─TableRowIDScan_28(Probe) 250.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +├─IndexLookUp_35 250.00 root +│ ├─IndexRangeScan_33(Build) 250.00 cop[tikv] table:t2, partition:p3, index:b(b) range:(0,5), keep order:false, stats:pseudo +│ └─TableRowIDScan_34(Probe) 250.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +└─IndexLookUp_41 250.00 root + ├─IndexRangeScan_39(Build) 250.00 cop[tikv] table:t2, partition:p4, index:b(b) range:(0,5), keep order:false, stats:pseudo + └─TableRowIDScan_40(Probe) 250.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo flush status; update t2 set a = 111 where b = 10; show status like 'Handler_read_rnd_next'; @@ -3825,13 +3825,13 @@ Variable_name Value drop table t1, t2; create table t1 (s1 int); explain select 1 from t1 union all select 2; -id estRows task operator info -Union_8 10001.00 root -├─Projection_9 10000.00 root 1->Column#5 -│ └─TableReader_11 10000.00 root data:TableFullScan_10 -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo -└─Projection_12 1.00 root 2->Column#5 - └─TableDual_13 1.00 root rows:1 +id estRows task access object operator info +Union_8 10001.00 root +├─Projection_9 10000.00 root 1->Column#5 +│ └─TableReader_11 10000.00 root data:TableFullScan_10 +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─Projection_12 1.00 root 2->Column#5 + └─TableDual_13 1.00 root rows:1 drop table t1; create table t1 (a int) partition by range(a) ( @@ -3848,109 +3848,109 @@ partition p2 values less than (255) insert into t1 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE); insert into t2 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE); explain select * from t1 where a=0; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.a, 0) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p0, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.a, 0) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p0 keep order:false, stats:pseudo explain select * from t2 where a=0; -id estRows task operator info -Union_9 30.00 root -├─TableReader_12 10.00 root data:Selection_11 -│ └─Selection_11 10.00 cop[tikv] eq(test.t2.a, 0) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 10.00 root data:Selection_14 -│ └─Selection_14 10.00 cop[tikv] eq(test.t2.a, 0) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 10.00 root data:Selection_17 - └─Selection_17 10.00 cop[tikv] eq(test.t2.a, 0) - └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 30.00 root +├─TableReader_12 10.00 root data:Selection_11 +│ └─Selection_11 10.00 cop[tikv] eq(test.t2.a, 0) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 10.00 root data:Selection_14 +│ └─Selection_14 10.00 cop[tikv] eq(test.t2.a, 0) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 10.00 root data:Selection_17 + └─Selection_17 10.00 cop[tikv] eq(test.t2.a, 0) + └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo explain select * from t1 where a=0xFE; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.t1.a, 254) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.t1.a, 254) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo explain select * from t2 where a=0xFE; -id estRows task operator info -Union_9 30.00 root -├─TableReader_12 10.00 root data:Selection_11 -│ └─Selection_11 10.00 cop[tikv] eq(test.t2.a, 254) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 10.00 root data:Selection_14 -│ └─Selection_14 10.00 cop[tikv] eq(test.t2.a, 254) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 10.00 root data:Selection_17 - └─Selection_17 10.00 cop[tikv] eq(test.t2.a, 254) - └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 30.00 root +├─TableReader_12 10.00 root data:Selection_11 +│ └─Selection_11 10.00 cop[tikv] eq(test.t2.a, 254) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 10.00 root data:Selection_14 +│ └─Selection_14 10.00 cop[tikv] eq(test.t2.a, 254) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 10.00 root data:Selection_17 + └─Selection_17 10.00 cop[tikv] eq(test.t2.a, 254) + └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo explain select * from t1 where a > 0xFE AND a <= 0xFF; -id estRows task operator info -TableDual_6 0.00 root rows:0 +id estRows task access object operator info +TableDual_6 0.00 root rows:0 explain select * from t2 where a > 0xFE AND a <= 0xFF; -id estRows task operator info -Union_9 750.00 root -├─TableReader_12 250.00 root data:Selection_11 -│ └─Selection_11 250.00 cop[tikv] gt(test.t2.a, 254), le(test.t2.a, 255) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 250.00 root data:Selection_14 -│ └─Selection_14 250.00 cop[tikv] gt(test.t2.a, 254), le(test.t2.a, 255) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 250.00 root data:Selection_17 - └─Selection_17 250.00 cop[tikv] gt(test.t2.a, 254), le(test.t2.a, 255) - └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 750.00 root +├─TableReader_12 250.00 root data:Selection_11 +│ └─Selection_11 250.00 cop[tikv] gt(test.t2.a, 254), le(test.t2.a, 255) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 250.00 root data:Selection_14 +│ └─Selection_14 250.00 cop[tikv] gt(test.t2.a, 254), le(test.t2.a, 255) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 250.00 root data:Selection_17 + └─Selection_17 250.00 cop[tikv] gt(test.t2.a, 254), le(test.t2.a, 255) + └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo explain select * from t1 where a >= 0xFE AND a <= 0xFF; -id estRows task operator info -TableReader_8 250.00 root data:Selection_7 -└─Selection_7 250.00 cop[tikv] ge(test.t1.a, 254), le(test.t1.a, 255) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 250.00 root data:Selection_7 +└─Selection_7 250.00 cop[tikv] ge(test.t1.a, 254), le(test.t1.a, 255) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo explain select * from t2 where a >= 0xFE AND a <= 0xFF; -id estRows task operator info -Union_9 750.00 root -├─TableReader_12 250.00 root data:Selection_11 -│ └─Selection_11 250.00 cop[tikv] ge(test.t2.a, 254), le(test.t2.a, 255) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 250.00 root data:Selection_14 -│ └─Selection_14 250.00 cop[tikv] ge(test.t2.a, 254), le(test.t2.a, 255) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 250.00 root data:Selection_17 - └─Selection_17 250.00 cop[tikv] ge(test.t2.a, 254), le(test.t2.a, 255) - └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 750.00 root +├─TableReader_12 250.00 root data:Selection_11 +│ └─Selection_11 250.00 cop[tikv] ge(test.t2.a, 254), le(test.t2.a, 255) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 250.00 root data:Selection_14 +│ └─Selection_14 250.00 cop[tikv] ge(test.t2.a, 254), le(test.t2.a, 255) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 250.00 root data:Selection_17 + └─Selection_17 250.00 cop[tikv] ge(test.t2.a, 254), le(test.t2.a, 255) + └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo explain select * from t1 where a < 64 AND a >= 63; -id estRows task operator info -TableReader_8 250.00 root data:Selection_7 -└─Selection_7 250.00 cop[tikv] ge(test.t1.a, 63), lt(test.t1.a, 64) - └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p0, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 250.00 root data:Selection_7 +└─Selection_7 250.00 cop[tikv] ge(test.t1.a, 63), lt(test.t1.a, 64) + └─TableFullScan_6 10000.00 cop[tikv] table:t1, partition:p0 keep order:false, stats:pseudo explain select * from t2 where a < 64 AND a >= 63; -id estRows task operator info -Union_9 750.00 root -├─TableReader_12 250.00 root data:Selection_11 -│ └─Selection_11 250.00 cop[tikv] ge(test.t2.a, 63), lt(test.t2.a, 64) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 250.00 root data:Selection_14 -│ └─Selection_14 250.00 cop[tikv] ge(test.t2.a, 63), lt(test.t2.a, 64) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 250.00 root data:Selection_17 - └─Selection_17 250.00 cop[tikv] ge(test.t2.a, 63), lt(test.t2.a, 64) - └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 750.00 root +├─TableReader_12 250.00 root data:Selection_11 +│ └─Selection_11 250.00 cop[tikv] ge(test.t2.a, 63), lt(test.t2.a, 64) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 250.00 root data:Selection_14 +│ └─Selection_14 250.00 cop[tikv] ge(test.t2.a, 63), lt(test.t2.a, 64) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 250.00 root data:Selection_17 + └─Selection_17 250.00 cop[tikv] ge(test.t2.a, 63), lt(test.t2.a, 64) + └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo explain select * from t1 where a <= 64 AND a >= 63; -id estRows task operator info -Union_8 500.00 root -├─TableReader_11 250.00 root data:Selection_10 -│ └─Selection_10 250.00 cop[tikv] ge(test.t1.a, 63), le(test.t1.a, 64) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 250.00 root data:Selection_13 - └─Selection_13 250.00 cop[tikv] ge(test.t1.a, 63), le(test.t1.a, 64) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 500.00 root +├─TableReader_11 250.00 root data:Selection_10 +│ └─Selection_10 250.00 cop[tikv] ge(test.t1.a, 63), le(test.t1.a, 64) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 250.00 root data:Selection_13 + └─Selection_13 250.00 cop[tikv] ge(test.t1.a, 63), le(test.t1.a, 64) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo explain select * from t2 where a <= 64 AND a >= 63; -id estRows task operator info -Union_9 750.00 root -├─TableReader_12 250.00 root data:Selection_11 -│ └─Selection_11 250.00 cop[tikv] ge(test.t2.a, 63), le(test.t2.a, 64) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 250.00 root data:Selection_14 -│ └─Selection_14 250.00 cop[tikv] ge(test.t2.a, 63), le(test.t2.a, 64) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 250.00 root data:Selection_17 - └─Selection_17 250.00 cop[tikv] ge(test.t2.a, 63), le(test.t2.a, 64) - └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 750.00 root +├─TableReader_12 250.00 root data:Selection_11 +│ └─Selection_11 250.00 cop[tikv] ge(test.t2.a, 63), le(test.t2.a, 64) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 250.00 root data:Selection_14 +│ └─Selection_14 250.00 cop[tikv] ge(test.t2.a, 63), le(test.t2.a, 64) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 250.00 root data:Selection_17 + └─Selection_17 250.00 cop[tikv] ge(test.t2.a, 63), le(test.t2.a, 64) + └─TableFullScan_16 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo drop table t1; drop table t2; create table t1(a bigint unsigned not null) partition by range(a+0) ( @@ -3963,51 +3963,51 @@ insert into t1 values (9),(19),(0xFFFF0000FFFF000-1), (0xFFFF0000FFFFFFF-1); insert into t1 values (9),(19),(0xFFFF0000FFFF000-1), (0xFFFF0000FFFFFFF-1); explain select * from t1 where a >= 2305561538531885056-10 and a <= 2305561538531885056-8; -id estRows task operator info -Union_10 1000.00 root -├─TableReader_13 250.00 root data:Selection_12 -│ └─Selection_12 250.00 cop[tikv] ge(test.t1.a, 2305561538531885046), le(test.t1.a, 2305561538531885048) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo -├─TableReader_16 250.00 root data:Selection_15 -│ └─Selection_15 250.00 cop[tikv] ge(test.t1.a, 2305561538531885046), le(test.t1.a, 2305561538531885048) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo -├─TableReader_19 250.00 root data:Selection_18 -│ └─Selection_18 250.00 cop[tikv] ge(test.t1.a, 2305561538531885046), le(test.t1.a, 2305561538531885048) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p3, keep order:false, stats:pseudo -└─TableReader_22 250.00 root data:Selection_21 - └─Selection_21 250.00 cop[tikv] ge(test.t1.a, 2305561538531885046), le(test.t1.a, 2305561538531885048) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 1000.00 root +├─TableReader_13 250.00 root data:Selection_12 +│ └─Selection_12 250.00 cop[tikv] ge(test.t1.a, 2305561538531885046), le(test.t1.a, 2305561538531885048) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo +├─TableReader_16 250.00 root data:Selection_15 +│ └─Selection_15 250.00 cop[tikv] ge(test.t1.a, 2305561538531885046), le(test.t1.a, 2305561538531885048) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo +├─TableReader_19 250.00 root data:Selection_18 +│ └─Selection_18 250.00 cop[tikv] ge(test.t1.a, 2305561538531885046), le(test.t1.a, 2305561538531885048) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p3 keep order:false, stats:pseudo +└─TableReader_22 250.00 root data:Selection_21 + └─Selection_21 250.00 cop[tikv] ge(test.t1.a, 2305561538531885046), le(test.t1.a, 2305561538531885048) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p4 keep order:false, stats:pseudo explain select * from t1 where a > 0xFFFFFFFFFFFFFFEC and a < 0xFFFFFFFFFFFFFFEE; -id estRows task operator info -Union_10 1000.00 root -├─TableReader_13 250.00 root data:Selection_12 -│ └─Selection_12 250.00 cop[tikv] gt(test.t1.a, 18446744073709551596), lt(test.t1.a, 18446744073709551598) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo -├─TableReader_16 250.00 root data:Selection_15 -│ └─Selection_15 250.00 cop[tikv] gt(test.t1.a, 18446744073709551596), lt(test.t1.a, 18446744073709551598) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo -├─TableReader_19 250.00 root data:Selection_18 -│ └─Selection_18 250.00 cop[tikv] gt(test.t1.a, 18446744073709551596), lt(test.t1.a, 18446744073709551598) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p3, keep order:false, stats:pseudo -└─TableReader_22 250.00 root data:Selection_21 - └─Selection_21 250.00 cop[tikv] gt(test.t1.a, 18446744073709551596), lt(test.t1.a, 18446744073709551598) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 1000.00 root +├─TableReader_13 250.00 root data:Selection_12 +│ └─Selection_12 250.00 cop[tikv] gt(test.t1.a, 18446744073709551596), lt(test.t1.a, 18446744073709551598) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo +├─TableReader_16 250.00 root data:Selection_15 +│ └─Selection_15 250.00 cop[tikv] gt(test.t1.a, 18446744073709551596), lt(test.t1.a, 18446744073709551598) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo +├─TableReader_19 250.00 root data:Selection_18 +│ └─Selection_18 250.00 cop[tikv] gt(test.t1.a, 18446744073709551596), lt(test.t1.a, 18446744073709551598) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p3 keep order:false, stats:pseudo +└─TableReader_22 250.00 root data:Selection_21 + └─Selection_21 250.00 cop[tikv] gt(test.t1.a, 18446744073709551596), lt(test.t1.a, 18446744073709551598) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p4 keep order:false, stats:pseudo explain select * from t1 where a>=0 and a <= 0xFFFFFFFFFFFFFFFF; -id estRows task operator info -Union_10 1000.00 root -├─TableReader_13 250.00 root data:Selection_12 -│ └─Selection_12 250.00 cop[tikv] ge(test.t1.a, 0), le(test.t1.a, 18446744073709551615) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo -├─TableReader_16 250.00 root data:Selection_15 -│ └─Selection_15 250.00 cop[tikv] ge(test.t1.a, 0), le(test.t1.a, 18446744073709551615) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo -├─TableReader_19 250.00 root data:Selection_18 -│ └─Selection_18 250.00 cop[tikv] ge(test.t1.a, 0), le(test.t1.a, 18446744073709551615) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p3, keep order:false, stats:pseudo -└─TableReader_22 250.00 root data:Selection_21 - └─Selection_21 250.00 cop[tikv] ge(test.t1.a, 0), le(test.t1.a, 18446744073709551615) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 1000.00 root +├─TableReader_13 250.00 root data:Selection_12 +│ └─Selection_12 250.00 cop[tikv] ge(test.t1.a, 0), le(test.t1.a, 18446744073709551615) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo +├─TableReader_16 250.00 root data:Selection_15 +│ └─Selection_15 250.00 cop[tikv] ge(test.t1.a, 0), le(test.t1.a, 18446744073709551615) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo +├─TableReader_19 250.00 root data:Selection_18 +│ └─Selection_18 250.00 cop[tikv] ge(test.t1.a, 0), le(test.t1.a, 18446744073709551615) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p3 keep order:false, stats:pseudo +└─TableReader_22 250.00 root data:Selection_21 + └─Selection_21 250.00 cop[tikv] ge(test.t1.a, 0), le(test.t1.a, 18446744073709551615) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p4 keep order:false, stats:pseudo drop table t1; create table t1 (a bigint) partition by range(a+0) ( partition p1 values less than (-1000), @@ -4017,20 +4017,20 @@ partition p4 values less than (1000) ); insert into t1 values (-15),(-5),(5),(15),(-15),(-5),(5),(15); explain select * from t1 where a>-2 and a <=0; -id estRows task operator info -Union_10 1000.00 root -├─TableReader_13 250.00 root data:Selection_12 -│ └─Selection_12 250.00 cop[tikv] gt(test.t1.a, -2), le(test.t1.a, 0) -│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo -├─TableReader_16 250.00 root data:Selection_15 -│ └─Selection_15 250.00 cop[tikv] gt(test.t1.a, -2), le(test.t1.a, 0) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo -├─TableReader_19 250.00 root data:Selection_18 -│ └─Selection_18 250.00 cop[tikv] gt(test.t1.a, -2), le(test.t1.a, 0) -│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p3, keep order:false, stats:pseudo -└─TableReader_22 250.00 root data:Selection_21 - └─Selection_21 250.00 cop[tikv] gt(test.t1.a, -2), le(test.t1.a, 0) - └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p4, keep order:false, stats:pseudo +id estRows task access object operator info +Union_10 1000.00 root +├─TableReader_13 250.00 root data:Selection_12 +│ └─Selection_12 250.00 cop[tikv] gt(test.t1.a, -2), le(test.t1.a, 0) +│ └─TableFullScan_11 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo +├─TableReader_16 250.00 root data:Selection_15 +│ └─Selection_15 250.00 cop[tikv] gt(test.t1.a, -2), le(test.t1.a, 0) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo +├─TableReader_19 250.00 root data:Selection_18 +│ └─Selection_18 250.00 cop[tikv] gt(test.t1.a, -2), le(test.t1.a, 0) +│ └─TableFullScan_17 10000.00 cop[tikv] table:t1, partition:p3 keep order:false, stats:pseudo +└─TableReader_22 250.00 root data:Selection_21 + └─Selection_21 250.00 cop[tikv] gt(test.t1.a, -2), le(test.t1.a, 0) + └─TableFullScan_20 10000.00 cop[tikv] table:t1, partition:p4 keep order:false, stats:pseudo drop table t1; CREATE TABLE t1 ( recdate DATETIME NOT NULL ) PARTITION BY RANGE( TO_DAYS(recdate) ) ( @@ -4042,14 +4042,14 @@ INSERT INTO t1 VALUES ('2007-03-07 12:00:00'); INSERT INTO t1 VALUES ('2007-03-08 12:00:00'); INSERT INTO t1 VALUES ('2007-03-15 12:00:00'); explain select * from t1 where recdate < '2007-03-08 00:00:00'; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.recdate, 2007-03-08 00:00:00.000000) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] lt(test.t1.recdate, 2007-03-08 00:00:00.000000) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.recdate, 2007-03-08 00:00:00.000000) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] lt(test.t1.recdate, 2007-03-08 00:00:00.000000) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo drop table t1; CREATE TABLE t1 ( recdate DATETIME NOT NULL ) PARTITION BY RANGE( YEAR(recdate) ) ( @@ -4061,14 +4061,14 @@ INSERT INTO t1 VALUES ('2005-03-01 12:00:00'); INSERT INTO t1 VALUES ('2006-03-01 12:00:00'); INSERT INTO t1 VALUES ('2006-03-01 12:00:00'); explain select * from t1 where recdate < '2006-01-01 00:00:00'; -id estRows task operator info -Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 -│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.recdate, 2006-01-01 00:00:00.000000) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 - └─Selection_13 3323.33 cop[tikv] lt(test.t1.recdate, 2006-01-01 00:00:00.000000) - └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 6646.67 root +├─TableReader_11 3323.33 root data:Selection_10 +│ └─Selection_10 3323.33 cop[tikv] lt(test.t1.recdate, 2006-01-01 00:00:00.000000) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 3323.33 root data:Selection_13 + └─Selection_13 3323.33 cop[tikv] lt(test.t1.recdate, 2006-01-01 00:00:00.000000) + └─TableFullScan_12 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo drop table t1; create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); @@ -4080,109 +4080,109 @@ partition p2 values less than (255) ); insert into t1 select A.a + 10*B.a from t0 A, t0 B; explain select * from t1 where a between 10 and 13; -id estRows task operator info -Union_9 750.00 root -├─TableReader_12 250.00 root data:Selection_11 -│ └─Selection_11 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 13) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 250.00 root data:Selection_14 -│ └─Selection_14 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 13) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 250.00 root data:Selection_17 - └─Selection_17 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 13) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 750.00 root +├─TableReader_12 250.00 root data:Selection_11 +│ └─Selection_11 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 13) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 250.00 root data:Selection_14 +│ └─Selection_14 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 13) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 250.00 root data:Selection_17 + └─Selection_17 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 13) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo explain select * from t1 where a between 10 and 10+33; -id estRows task operator info -Union_9 750.00 root -├─TableReader_12 250.00 root data:Selection_11 -│ └─Selection_11 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 43) -│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p0, keep order:false, stats:pseudo -├─TableReader_15 250.00 root data:Selection_14 -│ └─Selection_14 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 43) -│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo -└─TableReader_18 250.00 root data:Selection_17 - └─Selection_17 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 43) - └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_9 750.00 root +├─TableReader_12 250.00 root data:Selection_11 +│ └─Selection_11 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 43) +│ └─TableFullScan_10 10000.00 cop[tikv] table:t1, partition:p0 keep order:false, stats:pseudo +├─TableReader_15 250.00 root data:Selection_14 +│ └─Selection_14 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 43) +│ └─TableFullScan_13 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo +└─TableReader_18 250.00 root data:Selection_17 + └─Selection_17 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 43) + └─TableFullScan_16 10000.00 cop[tikv] table:t1, partition:p2 keep order:false, stats:pseudo drop table t0, t1; drop table if exists t; create table t(a timestamp) partition by range(unix_timestamp(a)) (partition p0 values less than(unix_timestamp('2019-02-16 14:20:00')), partition p1 values less than (maxvalue)); explain select * from t where a between timestamp'2019-02-16 14:19:00' and timestamp'2019-02-16 14:21:00'; -id estRows task operator info -Union_8 500.00 root -├─TableReader_11 250.00 root data:Selection_10 -│ └─Selection_10 250.00 cop[tikv] ge(test.t.a, 2019-02-16 14:19:00), le(test.t.a, 2019-02-16 14:21:00) -│ └─TableFullScan_9 10000.00 cop[tikv] table:t, partition:p0, keep order:false, stats:pseudo -└─TableReader_14 250.00 root data:Selection_13 - └─Selection_13 250.00 cop[tikv] ge(test.t.a, 2019-02-16 14:19:00), le(test.t.a, 2019-02-16 14:21:00) - └─TableFullScan_12 10000.00 cop[tikv] table:t, partition:p1, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 500.00 root +├─TableReader_11 250.00 root data:Selection_10 +│ └─Selection_10 250.00 cop[tikv] ge(test.t.a, 2019-02-16 14:19:00), le(test.t.a, 2019-02-16 14:21:00) +│ └─TableFullScan_9 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo +└─TableReader_14 250.00 root data:Selection_13 + └─Selection_13 250.00 cop[tikv] ge(test.t.a, 2019-02-16 14:19:00), le(test.t.a, 2019-02-16 14:21:00) + └─TableFullScan_12 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo drop table if exists t; create table t(a int) partition by range(a) (partition p0 values less than (100), partition p1 values less than (200), partition p2 values less than (300)); begin; explain select * from t; -id estRows task operator info -Union_8 30000.00 root -├─TableReader_10 10000.00 root data:TableFullScan_9 -│ └─TableFullScan_9 10000.00 cop[tikv] table:t, partition:p0, keep order:false, stats:pseudo -├─TableReader_12 10000.00 root data:TableFullScan_11 -│ └─TableFullScan_11 10000.00 cop[tikv] table:t, partition:p1, keep order:false, stats:pseudo -└─TableReader_14 10000.00 root data:TableFullScan_13 - └─TableFullScan_13 10000.00 cop[tikv] table:t, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 30000.00 root +├─TableReader_10 10000.00 root data:TableFullScan_9 +│ └─TableFullScan_9 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo +├─TableReader_12 10000.00 root data:TableFullScan_11 +│ └─TableFullScan_11 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo +└─TableReader_14 10000.00 root data:TableFullScan_13 + └─TableFullScan_13 10000.00 cop[tikv] table:t, partition:p2 keep order:false, stats:pseudo insert into t values(1); explain select * from t; -id estRows task operator info -Projection_11 30000.00 root test.t.a -└─Union_12 30000.00 root - ├─UnionScan_13 10000.00 root - │ └─TableReader_15 10000.00 root data:TableFullScan_14 - │ └─TableFullScan_14 10000.00 cop[tikv] table:t, partition:p0, keep order:false, stats:pseudo - ├─UnionScan_16 10000.00 root - │ └─TableReader_18 10000.00 root data:TableFullScan_17 - │ └─TableFullScan_17 10000.00 cop[tikv] table:t, partition:p1, keep order:false, stats:pseudo - └─UnionScan_19 10000.00 root - └─TableReader_21 10000.00 root data:TableFullScan_20 - └─TableFullScan_20 10000.00 cop[tikv] table:t, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_11 30000.00 root test.t.a +└─Union_12 30000.00 root + ├─UnionScan_13 10000.00 root + │ └─TableReader_15 10000.00 root data:TableFullScan_14 + │ └─TableFullScan_14 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo + ├─UnionScan_16 10000.00 root + │ └─TableReader_18 10000.00 root data:TableFullScan_17 + │ └─TableFullScan_17 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo + └─UnionScan_19 10000.00 root + └─TableReader_21 10000.00 root data:TableFullScan_20 + └─TableFullScan_20 10000.00 cop[tikv] table:t, partition:p2 keep order:false, stats:pseudo rollback; begin; insert into t values(101); explain select * from t; -id estRows task operator info -Projection_11 30000.00 root test.t.a -└─Union_12 30000.00 root - ├─UnionScan_13 10000.00 root - │ └─TableReader_15 10000.00 root data:TableFullScan_14 - │ └─TableFullScan_14 10000.00 cop[tikv] table:t, partition:p0, keep order:false, stats:pseudo - ├─UnionScan_16 10000.00 root - │ └─TableReader_18 10000.00 root data:TableFullScan_17 - │ └─TableFullScan_17 10000.00 cop[tikv] table:t, partition:p1, keep order:false, stats:pseudo - └─UnionScan_19 10000.00 root - └─TableReader_21 10000.00 root data:TableFullScan_20 - └─TableFullScan_20 10000.00 cop[tikv] table:t, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_11 30000.00 root test.t.a +└─Union_12 30000.00 root + ├─UnionScan_13 10000.00 root + │ └─TableReader_15 10000.00 root data:TableFullScan_14 + │ └─TableFullScan_14 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo + ├─UnionScan_16 10000.00 root + │ └─TableReader_18 10000.00 root data:TableFullScan_17 + │ └─TableFullScan_17 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo + └─UnionScan_19 10000.00 root + └─TableReader_21 10000.00 root data:TableFullScan_20 + └─TableFullScan_20 10000.00 cop[tikv] table:t, partition:p2 keep order:false, stats:pseudo rollback; begin; insert into t values(201); explain select * from t; -id estRows task operator info -Projection_11 30000.00 root test.t.a -└─Union_12 30000.00 root - ├─UnionScan_13 10000.00 root - │ └─TableReader_15 10000.00 root data:TableFullScan_14 - │ └─TableFullScan_14 10000.00 cop[tikv] table:t, partition:p0, keep order:false, stats:pseudo - ├─UnionScan_16 10000.00 root - │ └─TableReader_18 10000.00 root data:TableFullScan_17 - │ └─TableFullScan_17 10000.00 cop[tikv] table:t, partition:p1, keep order:false, stats:pseudo - └─UnionScan_19 10000.00 root - └─TableReader_21 10000.00 root data:TableFullScan_20 - └─TableFullScan_20 10000.00 cop[tikv] table:t, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_11 30000.00 root test.t.a +└─Union_12 30000.00 root + ├─UnionScan_13 10000.00 root + │ └─TableReader_15 10000.00 root data:TableFullScan_14 + │ └─TableFullScan_14 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo + ├─UnionScan_16 10000.00 root + │ └─TableReader_18 10000.00 root data:TableFullScan_17 + │ └─TableFullScan_17 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo + └─UnionScan_19 10000.00 root + └─TableReader_21 10000.00 root data:TableFullScan_20 + └─TableFullScan_20 10000.00 cop[tikv] table:t, partition:p2 keep order:false, stats:pseudo rollback; explain select * from t; -id estRows task operator info -Union_8 30000.00 root -├─TableReader_10 10000.00 root data:TableFullScan_9 -│ └─TableFullScan_9 10000.00 cop[tikv] table:t, partition:p0, keep order:false, stats:pseudo -├─TableReader_12 10000.00 root data:TableFullScan_11 -│ └─TableFullScan_11 10000.00 cop[tikv] table:t, partition:p1, keep order:false, stats:pseudo -└─TableReader_14 10000.00 root data:TableFullScan_13 - └─TableFullScan_13 10000.00 cop[tikv] table:t, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 30000.00 root +├─TableReader_10 10000.00 root data:TableFullScan_9 +│ └─TableFullScan_9 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo +├─TableReader_12 10000.00 root data:TableFullScan_11 +│ └─TableFullScan_11 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo +└─TableReader_14 10000.00 root data:TableFullScan_13 + └─TableFullScan_13 10000.00 cop[tikv] table:t, partition:p2 keep order:false, stats:pseudo drop table if exists t; CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, @@ -4194,7 +4194,7 @@ PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (100) ); desc select * from t where a = 11 and b = 1 or a = 12 and b = 1; -id estRows task operator info -TableReader_8 8000.00 root data:Selection_7 -└─Selection_7 8000.00 cop[tikv] or(and(eq(test.t.a, 11), eq(test.t.b, 1)), and(eq(test.t.a, 12), eq(test.t.b, 1))) - └─TableFullScan_6 10000.00 cop[tikv] table:t, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 8000.00 root data:Selection_7 +└─Selection_7 8000.00 cop[tikv] or(and(eq(test.t.a, 11), eq(test.t.b, 1)), and(eq(test.t.a, 12), eq(test.t.b, 1))) + └─TableFullScan_6 10000.00 cop[tikv] table:t, partition:p2 keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/select.result b/cmd/explaintest/r/select.result index 286b150da6dce..ee594bb672483 100644 --- a/cmd/explaintest/r/select.result +++ b/cmd/explaintest/r/select.result @@ -240,11 +240,11 @@ insert into t1 values(6, 7, 8); insert into t1 values(7, 8, 9); insert into t1 values(9, 10, 11); explain select a, c from t1 use index(idx) order by a limit 5; -id estRows task operator info -TopN_7 5.00 root test.t1.a:asc, offset:0, count:5 -└─IndexReader_15 5.00 root index:TopN_14 - └─TopN_14 5.00 cop[tikv] test.t1.a:asc, offset:0, count:5 - └─IndexFullScan_13 10000.00 cop[tikv] table:t1, index:b, c, keep order:false, stats:pseudo +id estRows task access object operator info +TopN_7 5.00 root test.t1.a:asc, offset:0, count:5 +└─IndexReader_15 5.00 root index:TopN_14 + └─TopN_14 5.00 cop[tikv] test.t1.a:asc, offset:0, count:5 + └─IndexFullScan_13 10000.00 cop[tikv] table:t1, index:idx(b, c) keep order:false, stats:pseudo select c, a from t1 use index(idx) order by a limit 5; c a 3 1 @@ -255,42 +255,42 @@ c a drop table if exists t; create table t (a int, b int, c int, key idx(a, b, c)); explain select count(a) from t; -id estRows task operator info -StreamAgg_20 1.00 root funcs:count(Column#13)->Column#5 -└─TableReader_21 1.00 root data:StreamAgg_8 - └─StreamAgg_8 1.00 cop[tikv] funcs:count(test.t.a)->Column#13 - └─TableFullScan_18 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +StreamAgg_20 1.00 root funcs:count(Column#13)->Column#5 +└─TableReader_21 1.00 root data:StreamAgg_8 + └─StreamAgg_8 1.00 cop[tikv] funcs:count(test.t.a)->Column#13 + └─TableFullScan_18 10000.00 cop[tikv] table:t keep order:false, stats:pseudo select count(a) from t; count(a) 0 insert t values(0,0,0); explain select distinct b from t group by a; -id estRows task operator info -HashAgg_7 8000.00 root group by:test.t.b, funcs:firstrow(test.t.b)->test.t.b -└─StreamAgg_22 8000.00 root group by:test.t.a, funcs:firstrow(Column#9)->test.t.b - └─IndexReader_23 8000.00 root index:StreamAgg_11 - └─StreamAgg_11 8000.00 cop[tikv] group by:test.t.a, funcs:firstrow(test.t.b)->Column#9 - └─IndexFullScan_21 10000.00 cop[tikv] table:t, index:a, b, c, keep order:true, stats:pseudo +id estRows task access object operator info +HashAgg_7 8000.00 root group by:test.t.b, funcs:firstrow(test.t.b)->test.t.b +└─StreamAgg_22 8000.00 root group by:test.t.a, funcs:firstrow(Column#9)->test.t.b + └─IndexReader_23 8000.00 root index:StreamAgg_11 + └─StreamAgg_11 8000.00 cop[tikv] group by:test.t.a, funcs:firstrow(test.t.b)->Column#9 + └─IndexFullScan_21 10000.00 cop[tikv] table:t, index:idx(a, b, c) keep order:true, stats:pseudo select distinct b from t group by a; b 0 explain select count(b) from t group by a; -id estRows task operator info -StreamAgg_19 8000.00 root group by:test.t.a, funcs:count(Column#10)->Column#5 -└─IndexReader_20 8000.00 root index:StreamAgg_8 - └─StreamAgg_8 8000.00 cop[tikv] group by:test.t.a, funcs:count(test.t.b)->Column#10 - └─IndexFullScan_18 10000.00 cop[tikv] table:t, index:a, b, c, keep order:true, stats:pseudo +id estRows task access object operator info +StreamAgg_19 8000.00 root group by:test.t.a, funcs:count(Column#10)->Column#5 +└─IndexReader_20 8000.00 root index:StreamAgg_8 + └─StreamAgg_8 8000.00 cop[tikv] group by:test.t.a, funcs:count(test.t.b)->Column#10 + └─IndexFullScan_18 10000.00 cop[tikv] table:t, index:idx(a, b, c) keep order:true, stats:pseudo select count(b) from t group by a; count(b) 1 insert t values(1,1,1),(3,3,6),(3,2,5),(2,1,4),(1,1,3),(1,1,2); explain select count(a) from t where b>0 group by a, b; -id estRows task operator info -StreamAgg_25 2666.67 root group by:test.t.a, test.t.b, funcs:count(Column#10)->Column#5 -└─IndexReader_26 2666.67 root index:StreamAgg_9 - └─StreamAgg_9 2666.67 cop[tikv] group by:test.t.a, test.t.b, funcs:count(test.t.a)->Column#10 - └─Selection_24 3333.33 cop[tikv] gt(test.t.b, 0) - └─IndexFullScan_23 10000.00 cop[tikv] table:t, index:a, b, c, keep order:true, stats:pseudo +id estRows task access object operator info +StreamAgg_25 2666.67 root group by:test.t.a, test.t.b, funcs:count(Column#10)->Column#5 +└─IndexReader_26 2666.67 root index:StreamAgg_9 + └─StreamAgg_9 2666.67 cop[tikv] group by:test.t.a, test.t.b, funcs:count(test.t.a)->Column#10 + └─Selection_24 3333.33 cop[tikv] gt(test.t.b, 0) + └─IndexFullScan_23 10000.00 cop[tikv] table:t, index:idx(a, b, c) keep order:true, stats:pseudo select count(a) from t where b>0 group by a, b; count(a) 3 @@ -298,13 +298,13 @@ count(a) 1 1 explain select count(a) from t where b>0 group by a, b order by a; -id estRows task operator info -Projection_7 2666.67 root Column#5 -└─StreamAgg_36 2666.67 root group by:test.t.a, test.t.b, funcs:count(Column#15)->Column#5, funcs:firstrow(test.t.a)->test.t.a - └─IndexReader_37 2666.67 root index:StreamAgg_34 - └─StreamAgg_34 2666.67 cop[tikv] group by:test.t.a, test.t.b, funcs:count(test.t.a)->Column#15 - └─Selection_28 3333.33 cop[tikv] gt(test.t.b, 0) - └─IndexFullScan_27 10000.00 cop[tikv] table:t, index:a, b, c, keep order:true, stats:pseudo +id estRows task access object operator info +Projection_7 2666.67 root Column#5 +└─StreamAgg_36 2666.67 root group by:test.t.a, test.t.b, funcs:count(Column#15)->Column#5, funcs:firstrow(test.t.a)->test.t.a + └─IndexReader_37 2666.67 root index:StreamAgg_34 + └─StreamAgg_34 2666.67 cop[tikv] group by:test.t.a, test.t.b, funcs:count(test.t.a)->Column#15 + └─Selection_28 3333.33 cop[tikv] gt(test.t.b, 0) + └─IndexFullScan_27 10000.00 cop[tikv] table:t, index:idx(a, b, c) keep order:true, stats:pseudo select count(a) from t where b>0 group by a, b order by a; count(a) 3 @@ -312,161 +312,161 @@ count(a) 1 1 explain select count(a) from t where b>0 group by a, b order by a limit 1; -id estRows task operator info -Projection_9 1.00 root Column#5 -└─Limit_15 1.00 root offset:0, count:1 - └─StreamAgg_44 1.00 root group by:test.t.a, test.t.b, funcs:count(Column#16)->Column#5, funcs:firstrow(test.t.a)->test.t.a - └─IndexReader_45 1.00 root index:StreamAgg_40 - └─StreamAgg_40 1.00 cop[tikv] group by:test.t.a, test.t.b, funcs:count(test.t.a)->Column#16 - └─Selection_43 1.25 cop[tikv] gt(test.t.b, 0) - └─IndexFullScan_42 3.75 cop[tikv] table:t, index:a, b, c, keep order:true, stats:pseudo +id estRows task access object operator info +Projection_9 1.00 root Column#5 +└─Limit_15 1.00 root offset:0, count:1 + └─StreamAgg_44 1.00 root group by:test.t.a, test.t.b, funcs:count(Column#16)->Column#5, funcs:firstrow(test.t.a)->test.t.a + └─IndexReader_45 1.00 root index:StreamAgg_40 + └─StreamAgg_40 1.00 cop[tikv] group by:test.t.a, test.t.b, funcs:count(test.t.a)->Column#16 + └─Selection_43 1.25 cop[tikv] gt(test.t.b, 0) + └─IndexFullScan_42 3.75 cop[tikv] table:t, index:idx(a, b, c) keep order:true, stats:pseudo select count(a) from t where b>0 group by a, b order by a limit 1; count(a) 3 drop table if exists t; create table t (id int primary key, a int, b int); explain select * from (t t1 left join t t2 on t1.a = t2.a) left join (t t3 left join t t4 on t3.a = t4.a) on t2.b = 1; -id estRows task operator info -HashLeftJoin_10 155937656.25 root CARTESIAN left outer join, left cond:[eq(test.t.b, 1)] -├─HashLeftJoin_19(Build) 12487.50 root left outer join, equal:[eq(test.t.a, test.t.a)] -│ ├─TableReader_25(Build) 9990.00 root data:Selection_24 -│ │ └─Selection_24 9990.00 cop[tikv] not(isnull(test.t.a)) -│ │ └─TableFullScan_23 10000.00 cop[tikv] table:t4, keep order:false, stats:pseudo -│ └─TableReader_22(Probe) 10000.00 root data:TableFullScan_21 -│ └─TableFullScan_21 10000.00 cop[tikv] table:t3, keep order:false, stats:pseudo -└─HashLeftJoin_12(Probe) 12487.50 root left outer join, equal:[eq(test.t.a, test.t.a)] - ├─TableReader_18(Build) 9990.00 root data:Selection_17 - │ └─Selection_17 9990.00 cop[tikv] not(isnull(test.t.a)) - │ └─TableFullScan_16 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo - └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 - └─TableFullScan_14 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_10 155937656.25 root CARTESIAN left outer join, left cond:[eq(test.t.b, 1)] +├─HashJoin_19(Build) 12487.50 root left outer join, equal:[eq(test.t.a, test.t.a)] +│ ├─TableReader_25(Build) 9990.00 root data:Selection_24 +│ │ └─Selection_24 9990.00 cop[tikv] not(isnull(test.t.a)) +│ │ └─TableFullScan_23 10000.00 cop[tikv] table:t4 keep order:false, stats:pseudo +│ └─TableReader_22(Probe) 10000.00 root data:TableFullScan_21 +│ └─TableFullScan_21 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─HashJoin_12(Probe) 12487.50 root left outer join, equal:[eq(test.t.a, test.t.a)] + ├─TableReader_18(Build) 9990.00 root data:Selection_17 + │ └─Selection_17 9990.00 cop[tikv] not(isnull(test.t.a)) + │ └─TableFullScan_16 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 + └─TableFullScan_14 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo drop table if exists t; create table t(a bigint primary key, b bigint); desc select * from t where a = 1; -id estRows task operator info -Point_Get_1 1.00 root table:t, handle:1 +id estRows task access object operator info +Point_Get_1 1.00 root table:t handle:1 desc select * from t where a = '1'; -id estRows task operator info -Point_Get_1 1.00 root table:t, handle:1 +id estRows task access object operator info +Point_Get_1 1.00 root table:t handle:1 desc select sysdate(), sleep(1), sysdate(); -id estRows task operator info -Projection_3 1.00 root sysdate()->Column#1, sleep(1)->Column#2, sysdate()->Column#3 -└─TableDual_4 1.00 root rows:1 +id estRows task access object operator info +Projection_3 1.00 root sysdate()->Column#1, sleep(1)->Column#2, sysdate()->Column#3 +└─TableDual_4 1.00 root rows:1 drop table if exists th; set @@session.tidb_enable_table_partition = '1'; create table th (a int, b int) partition by hash(a) partitions 3; insert into th values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8); insert into th values (-1,-1),(-2,-2),(-3,-3),(-4,-4),(-5,-5),(-6,-6),(-7,-7),(-8,-8); desc select * from th where a=-2; -id estRows task operator info -TableReader_8 10.00 root data:Selection_7 -└─Selection_7 10.00 cop[tikv] eq(test.th.a, -2) - └─TableFullScan_6 10000.00 cop[tikv] table:th, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10.00 root data:Selection_7 +└─Selection_7 10.00 cop[tikv] eq(test.th.a, -2) + └─TableFullScan_6 10000.00 cop[tikv] table:th, partition:p2 keep order:false, stats:pseudo desc select * from th; -id estRows task operator info -Union_8 30000.00 root -├─TableReader_10 10000.00 root data:TableFullScan_9 -│ └─TableFullScan_9 10000.00 cop[tikv] table:th, partition:p0, keep order:false, stats:pseudo -├─TableReader_12 10000.00 root data:TableFullScan_11 -│ └─TableFullScan_11 10000.00 cop[tikv] table:th, partition:p1, keep order:false, stats:pseudo -└─TableReader_14 10000.00 root data:TableFullScan_13 - └─TableFullScan_13 10000.00 cop[tikv] table:th, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_8 30000.00 root +├─TableReader_10 10000.00 root data:TableFullScan_9 +│ └─TableFullScan_9 10000.00 cop[tikv] table:th, partition:p0 keep order:false, stats:pseudo +├─TableReader_12 10000.00 root data:TableFullScan_11 +│ └─TableFullScan_11 10000.00 cop[tikv] table:th, partition:p1 keep order:false, stats:pseudo +└─TableReader_14 10000.00 root data:TableFullScan_13 + └─TableFullScan_13 10000.00 cop[tikv] table:th, partition:p2 keep order:false, stats:pseudo desc select * from th partition (p2,p1); -id estRows task operator info -Union_7 20000.00 root -├─TableReader_9 10000.00 root data:TableFullScan_8 -│ └─TableFullScan_8 10000.00 cop[tikv] table:th, partition:p1, keep order:false, stats:pseudo -└─TableReader_11 10000.00 root data:TableFullScan_10 - └─TableFullScan_10 10000.00 cop[tikv] table:th, partition:p2, keep order:false, stats:pseudo +id estRows task access object operator info +Union_7 20000.00 root +├─TableReader_9 10000.00 root data:TableFullScan_8 +│ └─TableFullScan_8 10000.00 cop[tikv] table:th, partition:p1 keep order:false, stats:pseudo +└─TableReader_11 10000.00 root data:TableFullScan_10 + └─TableFullScan_10 10000.00 cop[tikv] table:th, partition:p2 keep order:false, stats:pseudo drop table if exists t; create table t(a int, b int); explain select a != any (select a from t t2) from t t1; -id estRows task operator info -Projection_8 10000.00 root and(or(or(gt(Column#8, 1), ne(test.t.a, Column#7)), if(ne(Column#9, 0), , 0)), and(ne(Column#10, 0), if(isnull(test.t.a), , 1)))->Column#11 -└─HashLeftJoin_9 10000.00 root CARTESIAN inner join - ├─StreamAgg_16(Build) 1.00 root funcs:firstrow(Column#13)->Column#7, funcs:count(distinct Column#14)->Column#8, funcs:sum(Column#15)->Column#9, funcs:count(1)->Column#10 - │ └─Projection_26 10000.00 root test.t.a, test.t.a, cast(isnull(test.t.a), decimal(65,0) BINARY)->Column#15 - │ └─TableReader_23 10000.00 root data:TableFullScan_22 - │ └─TableFullScan_22 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo - └─TableReader_12(Probe) 10000.00 root data:TableFullScan_11 - └─TableFullScan_11 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_8 10000.00 root and(or(or(gt(Column#8, 1), ne(test.t.a, Column#7)), if(ne(Column#9, 0), , 0)), and(ne(Column#10, 0), if(isnull(test.t.a), , 1)))->Column#11 +└─HashJoin_9 10000.00 root CARTESIAN inner join + ├─StreamAgg_16(Build) 1.00 root funcs:firstrow(Column#13)->Column#7, funcs:count(distinct Column#14)->Column#8, funcs:sum(Column#15)->Column#9, funcs:count(1)->Column#10 + │ └─Projection_26 10000.00 root test.t.a, test.t.a, cast(isnull(test.t.a), decimal(65,0) BINARY)->Column#15 + │ └─TableReader_23 10000.00 root data:TableFullScan_22 + │ └─TableFullScan_22 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader_12(Probe) 10000.00 root data:TableFullScan_11 + └─TableFullScan_11 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select a = all (select a from t t2) from t t1; -id estRows task operator info -Projection_8 10000.00 root or(and(and(le(Column#8, 1), eq(test.t.a, Column#7)), if(ne(Column#9, 0), , 1)), or(eq(Column#10, 0), if(isnull(test.t.a), , 0)))->Column#11 -└─HashLeftJoin_9 10000.00 root CARTESIAN inner join - ├─StreamAgg_16(Build) 1.00 root funcs:firstrow(Column#13)->Column#7, funcs:count(distinct Column#14)->Column#8, funcs:sum(Column#15)->Column#9, funcs:count(1)->Column#10 - │ └─Projection_26 10000.00 root test.t.a, test.t.a, cast(isnull(test.t.a), decimal(65,0) BINARY)->Column#15 - │ └─TableReader_23 10000.00 root data:TableFullScan_22 - │ └─TableFullScan_22 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo - └─TableReader_12(Probe) 10000.00 root data:TableFullScan_11 - └─TableFullScan_11 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_8 10000.00 root or(and(and(le(Column#8, 1), eq(test.t.a, Column#7)), if(ne(Column#9, 0), , 1)), or(eq(Column#10, 0), if(isnull(test.t.a), , 0)))->Column#11 +└─HashJoin_9 10000.00 root CARTESIAN inner join + ├─StreamAgg_16(Build) 1.00 root funcs:firstrow(Column#13)->Column#7, funcs:count(distinct Column#14)->Column#8, funcs:sum(Column#15)->Column#9, funcs:count(1)->Column#10 + │ └─Projection_26 10000.00 root test.t.a, test.t.a, cast(isnull(test.t.a), decimal(65,0) BINARY)->Column#15 + │ └─TableReader_23 10000.00 root data:TableFullScan_22 + │ └─TableFullScan_22 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader_12(Probe) 10000.00 root data:TableFullScan_11 + └─TableFullScan_11 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo drop table if exists t; create table t(a int, b int); drop table if exists s; create table s(a varchar(20), b varchar(20)); explain select a in (select a from s where s.b = t.b) from t; -id estRows task operator info -HashLeftJoin_10 10000.00 root left outer semi join, equal:[eq(Column#8, Column#9)], other cond:eq(cast(test.t.a), cast(test.s.a)) -├─Projection_14(Build) 10000.00 root test.s.a, cast(test.s.b, double BINARY)->Column#9 -│ └─TableReader_16 10000.00 root data:TableFullScan_15 -│ └─TableFullScan_15 10000.00 cop[tikv] table:s, keep order:false, stats:pseudo -└─Projection_11(Probe) 10000.00 root test.t.a, cast(test.t.b, double BINARY)->Column#8 - └─TableReader_13 10000.00 root data:TableFullScan_12 - └─TableFullScan_12 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_10 10000.00 root left outer semi join, equal:[eq(Column#8, Column#9)], other cond:eq(cast(test.t.a), cast(test.s.a)) +├─Projection_14(Build) 10000.00 root test.s.a, cast(test.s.b, double BINARY)->Column#9 +│ └─TableReader_16 10000.00 root data:TableFullScan_15 +│ └─TableFullScan_15 10000.00 cop[tikv] table:s keep order:false, stats:pseudo +└─Projection_11(Probe) 10000.00 root test.t.a, cast(test.t.b, double BINARY)->Column#8 + └─TableReader_13 10000.00 root data:TableFullScan_12 + └─TableFullScan_12 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select a in (select a+b from t t2 where t2.b = t1.b) from t t1; -id estRows task operator info -HashLeftJoin_8 10000.00 root left outer semi join, equal:[eq(test.t.b, test.t.b)], other cond:eq(test.t.a, plus(test.t.a, test.t.b)) -├─TableReader_12(Build) 10000.00 root data:TableFullScan_11 -│ └─TableFullScan_11 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo -└─TableReader_10(Probe) 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_8 10000.00 root left outer semi join, equal:[eq(test.t.b, test.t.b)], other cond:eq(test.t.a, plus(test.t.a, test.t.b)) +├─TableReader_12(Build) 10000.00 root data:TableFullScan_11 +│ └─TableFullScan_11 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader_10(Probe) 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo drop table t; create table t(a int not null, b int); explain select a in (select a from t t2 where t2.b = t1.b) from t t1; -id estRows task operator info -HashLeftJoin_8 10000.00 root left outer semi join, equal:[eq(test.t.b, test.t.b) eq(test.t.a, test.t.a)] -├─TableReader_12(Build) 10000.00 root data:TableFullScan_11 -│ └─TableFullScan_11 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo -└─TableReader_10(Probe) 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_8 10000.00 root left outer semi join, equal:[eq(test.t.b, test.t.b) eq(test.t.a, test.t.a)] +├─TableReader_12(Build) 10000.00 root data:TableFullScan_11 +│ └─TableFullScan_11 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader_10(Probe) 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select 1 from (select sleep(1)) t; -id estRows task operator info -Projection_4 1.00 root 1->Column#2 -└─Projection_5 1.00 root sleep(1)->Column#1 - └─TableDual_6 1.00 root rows:1 +id estRows task access object operator info +Projection_4 1.00 root 1->Column#2 +└─Projection_5 1.00 root sleep(1)->Column#1 + └─TableDual_6 1.00 root rows:1 drop table if exists t; create table t(a int, b int); explain select a from t order by rand(); -id estRows task operator info -Projection_8 10000.00 root test.t.a -└─Sort_4 10000.00 root Column#4:asc - └─Projection_9 10000.00 root test.t.a, rand()->Column#4 - └─TableReader_7 10000.00 root data:TableFullScan_6 - └─TableFullScan_6 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_8 10000.00 root test.t.a +└─Sort_4 10000.00 root Column#4:asc + └─Projection_9 10000.00 root test.t.a, rand()->Column#4 + └─TableReader_7 10000.00 root data:TableFullScan_6 + └─TableFullScan_6 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select a, b from t order by abs(2); -id estRows task operator info -TableReader_8 10000.00 root data:TableFullScan_7 -└─TableFullScan_7 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +TableReader_8 10000.00 root data:TableFullScan_7 +└─TableFullScan_7 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select a from t order by abs(rand())+1; -id estRows task operator info -Projection_8 10000.00 root test.t.a -└─Sort_4 10000.00 root Column#4:asc - └─Projection_9 10000.00 root test.t.a, plus(abs(rand()), 1)->Column#4 - └─TableReader_7 10000.00 root data:TableFullScan_6 - └─TableFullScan_6 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_8 10000.00 root test.t.a +└─Sort_4 10000.00 root Column#4:asc + └─Projection_9 10000.00 root test.t.a, plus(abs(rand()), 1)->Column#4 + └─TableReader_7 10000.00 root data:TableFullScan_6 + └─TableFullScan_6 10000.00 cop[tikv] table:t keep order:false, stats:pseudo drop table if exists t1; create table t1(a int, b int); drop table if exists t2; create table t2(a int, b int); explain select * from t1 where t1.a in (select t2.a as a from t2 where t2.b > t1.b order by t1.b); -id estRows task operator info -HashLeftJoin_10 7984.01 root semi join, equal:[eq(test.t1.a, test.t2.a)], other cond:gt(test.t2.b, test.t1.b) -├─TableReader_16(Build) 9980.01 root data:Selection_15 -│ └─Selection_15 9980.01 cop[tikv] not(isnull(test.t2.a)), not(isnull(test.t2.b)) -│ └─TableFullScan_14 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo -└─TableReader_13(Probe) 9980.01 root data:Selection_12 - └─Selection_12 9980.01 cop[tikv] not(isnull(test.t1.a)), not(isnull(test.t1.b)) - └─TableFullScan_11 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_10 7984.01 root semi join, equal:[eq(test.t1.a, test.t2.a)], other cond:gt(test.t2.b, test.t1.b) +├─TableReader_16(Build) 9980.01 root data:Selection_15 +│ └─Selection_15 9980.01 cop[tikv] not(isnull(test.t2.a)), not(isnull(test.t2.b)) +│ └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader_13(Probe) 9980.01 root data:Selection_12 + └─Selection_12 9980.01 cop[tikv] not(isnull(test.t1.a)), not(isnull(test.t1.b)) + └─TableFullScan_11 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo drop table t; CREATE TABLE t (id int(10) unsigned NOT NULL AUTO_INCREMENT, i int(10) unsigned DEFAULT NULL, @@ -474,9 +474,9 @@ x int(10) unsigned DEFAULT 0, PRIMARY KEY (`id`) ); explain select row_number() over( partition by i ) - x as rnk from t; -id estRows task operator info -Projection_7 10000.00 root minus(Column#5, test.t.x)->Column#7 -└─Window_8 10000.00 root row_number()->Column#5 over(partition by test.t.i) - └─Sort_11 10000.00 root test.t.i:asc - └─TableReader_10 10000.00 root data:TableRangeScan_9 - └─TableRangeScan_9 10000.00 cop[tikv] table:t, range:[0,+inf], keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root minus(Column#5, test.t.x)->Column#7 +└─Window_8 10000.00 root row_number()->Column#5 over(partition by test.t.i) + └─Sort_11 10000.00 root test.t.i:asc + └─TableReader_10 10000.00 root data:TableRangeScan_9 + └─TableRangeScan_9 10000.00 cop[tikv] table:t range:[0,+inf], keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/subquery.result b/cmd/explaintest/r/subquery.result index 70da57898d9fa..488c727bfcc44 100644 --- a/cmd/explaintest/r/subquery.result +++ b/cmd/explaintest/r/subquery.result @@ -5,39 +5,39 @@ create table t2(a bigint, b bigint); set session tidb_hashagg_partial_concurrency = 1; set session tidb_hashagg_final_concurrency = 1; explain select * from t1 where t1.a in (select t1.b + t2.b from t2); -id estRows task operator info -HashLeftJoin_8 8000.00 root CARTESIAN semi join, other cond:eq(test.t1.a, plus(test.t1.b, test.t2.b)) -├─TableReader_12(Build) 10000.00 root data:TableFullScan_11 -│ └─TableFullScan_11 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo -└─TableReader_10(Probe) 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_8 8000.00 root CARTESIAN semi join, other cond:eq(test.t1.a, plus(test.t1.b, test.t2.b)) +├─TableReader_12(Build) 10000.00 root data:TableFullScan_11 +│ └─TableFullScan_11 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader_10(Probe) 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo drop table if exists t; create table t(a int primary key, b int, c int, d int, index idx(b,c,d)); insert into t values(1,1,1,1),(2,2,2,2),(3,2,2,2),(4,2,2,2),(5,2,2,2); analyze table t; explain select t.c in (select count(*) from t s use index(idx), t t1 where s.b = 1 and s.c = 1 and s.d = t.a and s.a = t1.a) from t; -id estRows task operator info -Projection_11 5.00 root Column#14 -└─Apply_13 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#13) - ├─TableReader_15(Build) 5.00 root data:TableFullScan_14 - │ └─TableFullScan_14 5.00 cop[tikv] table:t, keep order:false - └─StreamAgg_22(Probe) 1.00 root funcs:count(1)->Column#13 - └─IndexMergeJoin_29 0.50 root inner join, inner:TableReader_27, outer key:test.t.a, inner key:test.t.a - ├─IndexReader_35(Build) 1.00 root index:IndexRangeScan_34 - │ └─IndexRangeScan_34 1.00 cop[tikv] table:s, index:b, c, d, range: decided by [eq(test.t.b, 1) eq(test.t.c, 1) eq(test.t.d, test.t.a)], keep order:false - └─TableReader_27(Probe) 1.00 root data:TableRangeScan_26 - └─TableRangeScan_26 1.00 cop[tikv] table:t1, range: decided by [test.t.a], keep order:true +id estRows task access object operator info +Projection_11 5.00 root Column#14 +└─Apply_13 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#13) + ├─TableReader_15(Build) 5.00 root data:TableFullScan_14 + │ └─TableFullScan_14 5.00 cop[tikv] table:t keep order:false + └─StreamAgg_22(Probe) 1.00 root funcs:count(1)->Column#13 + └─IndexMergeJoin_29 0.50 root inner join, inner:TableReader_27, outer key:test.t.a, inner key:test.t.a + ├─IndexReader_35(Build) 1.00 root index:IndexRangeScan_34 + │ └─IndexRangeScan_34 1.00 cop[tikv] table:s, index:idx(b, c, d) range: decided by [eq(test.t.b, 1) eq(test.t.c, 1) eq(test.t.d, test.t.a)], keep order:false + └─TableReader_27(Probe) 1.00 root data:TableRangeScan_26 + └─TableRangeScan_26 1.00 cop[tikv] table:t1 range: decided by [test.t.a], keep order:true drop table if exists t; create table t(a int, b int, c int); explain select a from t t1 where t1.a = (select max(t2.a) from t t2 where t1.b=t2.b and t1.c=t2.b); -id estRows task operator info -HashLeftJoin_12 7992.00 root inner join, equal:[eq(test.t.b, test.t.b) eq(test.t.c, test.t.b) eq(test.t.a, Column#9)] -├─Selection_17(Build) 6393.60 root not(isnull(Column#9)) -│ └─HashAgg_23 7992.00 root group by:test.t.b, funcs:max(Column#10)->Column#9, funcs:firstrow(test.t.b)->test.t.b -│ └─TableReader_24 7992.00 root data:HashAgg_18 -│ └─HashAgg_18 7992.00 cop[tikv] group by:test.t.b, funcs:max(test.t.a)->Column#10 -│ └─Selection_22 9990.00 cop[tikv] not(isnull(test.t.b)) -│ └─TableFullScan_21 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo -└─TableReader_16(Probe) 9970.03 root data:Selection_15 - └─Selection_15 9970.03 cop[tikv] not(isnull(test.t.a)), not(isnull(test.t.b)), not(isnull(test.t.c)) - └─TableFullScan_14 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +HashJoin_12 7992.00 root inner join, equal:[eq(test.t.b, test.t.b) eq(test.t.c, test.t.b) eq(test.t.a, Column#9)] +├─Selection_17(Build) 6393.60 root not(isnull(Column#9)) +│ └─HashAgg_23 7992.00 root group by:test.t.b, funcs:max(Column#10)->Column#9, funcs:firstrow(test.t.b)->test.t.b +│ └─TableReader_24 7992.00 root data:HashAgg_18 +│ └─HashAgg_18 7992.00 cop[tikv] group by:test.t.b, funcs:max(test.t.a)->Column#10 +│ └─Selection_22 9990.00 cop[tikv] not(isnull(test.t.b)) +│ └─TableFullScan_21 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader_16(Probe) 9970.03 root data:Selection_15 + └─Selection_15 9970.03 cop[tikv] not(isnull(test.t.a)), not(isnull(test.t.b)), not(isnull(test.t.c)) + └─TableFullScan_14 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/topn_push_down.result b/cmd/explaintest/r/topn_push_down.result index d9dac5b6e5327..2ceef9750a778 100644 --- a/cmd/explaintest/r/topn_push_down.result +++ b/cmd/explaintest/r/topn_push_down.result @@ -166,102 +166,102 @@ tr.trade_type IN (1) AND te.expect_time BETWEEN '2018-04-23 00:00:00.0' AND '2018-04-23 23:59:59.0' ORDER BY te.expect_time asc LIMIT 0, 5; -id estRows task operator info -TopN_15 0.00 root test.te.expect_time:asc, offset:0, count:5 -└─IndexMergeJoin_31 0.00 root inner join, inner:Projection_29, outer key:test.tr.id, inner key:test.te.trade_id - ├─IndexLookUp_78(Build) 0.00 root - │ ├─Selection_76(Build) 0.00 cop[tikv] eq(test.tr.business_type, 18), eq(test.tr.trade_type, 1) - │ │ └─IndexRangeScan_74 10.00 cop[tikv] table:tr, index:shop_identy, trade_status, business_type, trade_pay_status, trade_type, delivery_type, source, biz_date, range:[810094178,810094178], keep order:false, stats:pseudo - │ └─Selection_77(Probe) 0.00 cop[tikv] eq(test.tr.brand_identy, 32314), eq(test.tr.domain_type, 2) - │ └─TableRowIDScan_75 0.00 cop[tikv] table:tr, keep order:false, stats:pseudo - └─Projection_29(Probe) 1.25 root test.te.trade_id, test.te.expect_time - └─IndexLookUp_28 1.25 root - ├─IndexRangeScan_25(Build) 50.00 cop[tikv] table:te, index:trade_id, range: decided by [eq(test.te.trade_id, test.tr.id)], keep order:true, stats:pseudo - └─Selection_27(Probe) 1.25 cop[tikv] ge(test.te.expect_time, 2018-04-23 00:00:00.000000), le(test.te.expect_time, 2018-04-23 23:59:59.000000) - └─TableRowIDScan_26 50.00 cop[tikv] table:te, keep order:false, stats:pseudo +id estRows task access object operator info +TopN_15 0.00 root test.te.expect_time:asc, offset:0, count:5 +└─IndexMergeJoin_31 0.00 root inner join, inner:Projection_29, outer key:test.tr.id, inner key:test.te.trade_id + ├─IndexLookUp_78(Build) 0.00 root + │ ├─Selection_76(Build) 0.00 cop[tikv] eq(test.tr.business_type, 18), eq(test.tr.trade_type, 1) + │ │ └─IndexRangeScan_74 10.00 cop[tikv] table:tr, index:idx_shop_identy_trade_status_business_type(shop_identy, trade_status, business_type, trade_pay_status, trade_type, delivery_type, source, biz_date) range:[810094178,810094178], keep order:false, stats:pseudo + │ └─Selection_77(Probe) 0.00 cop[tikv] eq(test.tr.brand_identy, 32314), eq(test.tr.domain_type, 2) + │ └─TableRowIDScan_75 0.00 cop[tikv] table:tr keep order:false, stats:pseudo + └─Projection_29(Probe) 1.25 root test.te.trade_id, test.te.expect_time + └─IndexLookUp_28 1.25 root + ├─IndexRangeScan_25(Build) 50.00 cop[tikv] table:te, index:idx_trade_id(trade_id) range: decided by [eq(test.te.trade_id, test.tr.id)], keep order:true, stats:pseudo + └─Selection_27(Probe) 1.25 cop[tikv] ge(test.te.expect_time, 2018-04-23 00:00:00.000000), le(test.te.expect_time, 2018-04-23 23:59:59.000000) + └─TableRowIDScan_26 50.00 cop[tikv] table:te keep order:false, stats:pseudo desc select 1 as a from dual order by a limit 1; -id estRows task operator info -Projection_6 1.00 root 1->Column#1 -└─TableDual_7 1.00 root rows:1 +id estRows task access object operator info +Projection_6 1.00 root 1->Column#1 +└─TableDual_7 1.00 root rows:1 drop table if exists t1; drop table if exists t2; create table t1(a bigint, b bigint); create table t2(a bigint, b bigint); desc select * from t1 where t1.a in (select t2.a as a from t2 where t2.b > t1.b order by t1.b limit 1); -id estRows task operator info -Apply_15 9990.00 root semi join, equal:[eq(test.t1.a, test.t2.a)] -├─TableReader_18(Build) 9990.00 root data:Selection_17 -│ └─Selection_17 9990.00 cop[tikv] not(isnull(test.t1.a)) -│ └─TableFullScan_16 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo -└─Selection_19(Probe) 0.80 root not(isnull(test.t2.a)) - └─Limit_20 1.00 root offset:0, count:1 - └─TableReader_26 1.00 root data:Limit_25 - └─Limit_25 1.00 cop[tikv] offset:0, count:1 - └─Selection_24 1.00 cop[tikv] gt(test.t2.b, test.t1.b) - └─TableFullScan_23 1.25 cop[tikv] table:t2, keep order:false, stats:pseudo +id estRows task access object operator info +Apply_15 9990.00 root semi join, equal:[eq(test.t1.a, test.t2.a)] +├─TableReader_18(Build) 9990.00 root data:Selection_17 +│ └─Selection_17 9990.00 cop[tikv] not(isnull(test.t1.a)) +│ └─TableFullScan_16 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─Selection_19(Probe) 0.80 root not(isnull(test.t2.a)) + └─Limit_20 1.00 root offset:0, count:1 + └─TableReader_26 1.00 root data:Limit_25 + └─Limit_25 1.00 cop[tikv] offset:0, count:1 + └─Selection_24 1.00 cop[tikv] gt(test.t2.b, test.t1.b) + └─TableFullScan_23 1.25 cop[tikv] table:t2 keep order:false, stats:pseudo desc select * from t1 where t1.a in (select a from (select t2.a as a, t1.b as b from t2 where t2.b > t1.b) x order by b limit 1); -id estRows task operator info -Apply_17 9990.00 root semi join, equal:[eq(test.t1.a, test.t2.a)] -├─TableReader_20(Build) 9990.00 root data:Selection_19 -│ └─Selection_19 9990.00 cop[tikv] not(isnull(test.t1.a)) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo -└─Selection_21(Probe) 0.80 root not(isnull(test.t2.a)) - └─Projection_22 1.00 root test.t2.a - └─Limit_23 1.00 root offset:0, count:1 - └─TableReader_29 1.00 root data:Limit_28 - └─Limit_28 1.00 cop[tikv] offset:0, count:1 - └─Selection_27 1.00 cop[tikv] gt(test.t2.b, test.t1.b) - └─TableFullScan_26 1.25 cop[tikv] table:t2, keep order:false, stats:pseudo +id estRows task access object operator info +Apply_17 9990.00 root semi join, equal:[eq(test.t1.a, test.t2.a)] +├─TableReader_20(Build) 9990.00 root data:Selection_19 +│ └─Selection_19 9990.00 cop[tikv] not(isnull(test.t1.a)) +│ └─TableFullScan_18 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─Selection_21(Probe) 0.80 root not(isnull(test.t2.a)) + └─Projection_22 1.00 root test.t2.a + └─Limit_23 1.00 root offset:0, count:1 + └─TableReader_29 1.00 root data:Limit_28 + └─Limit_28 1.00 cop[tikv] offset:0, count:1 + └─Selection_27 1.00 cop[tikv] gt(test.t2.b, test.t1.b) + └─TableFullScan_26 1.25 cop[tikv] table:t2 keep order:false, stats:pseudo drop table if exists t; create table t(a int not null, index idx(a)); explain select /*+ TIDB_INLJ(t2) */ * from t t1 join t t2 on t1.a = t2.a limit 5; -id estRows task operator info -Limit_11 5.00 root offset:0, count:5 -└─IndexJoin_15 5.00 root inner join, inner:IndexReader_14, outer key:test.t.a, inner key:test.t.a - ├─TableReader_23(Build) 4.00 root data:TableFullScan_22 - │ └─TableFullScan_22 4.00 cop[tikv] table:t1, keep order:false, stats:pseudo - └─IndexReader_14(Probe) 1.25 root index:IndexRangeScan_13 - └─IndexRangeScan_13 1.25 cop[tikv] table:t2, index:a, range: decided by [eq(test.t.a, test.t.a)], keep order:false, stats:pseudo +id estRows task access object operator info +Limit_11 5.00 root offset:0, count:5 +└─IndexJoin_15 5.00 root inner join, inner:IndexReader_14, outer key:test.t.a, inner key:test.t.a + ├─TableReader_23(Build) 4.00 root data:TableFullScan_22 + │ └─TableFullScan_22 4.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─IndexReader_14(Probe) 1.25 root index:IndexRangeScan_13 + └─IndexRangeScan_13 1.25 cop[tikv] table:t2, index:idx(a) range: decided by [eq(test.t.a, test.t.a)], keep order:false, stats:pseudo explain select /*+ TIDB_INLJ(t2) */ * from t t1 left join t t2 on t1.a = t2.a where t2.a is null limit 5; -id estRows task operator info -Limit_12 5.00 root offset:0, count:5 -└─Selection_13 5.00 root isnull(test.t.a) - └─IndexJoin_17 5.00 root left outer join, inner:IndexReader_16, outer key:test.t.a, inner key:test.t.a - ├─TableReader_25(Build) 4.00 root data:TableFullScan_24 - │ └─TableFullScan_24 4.00 cop[tikv] table:t1, keep order:false, stats:pseudo - └─IndexReader_16(Probe) 1.25 root index:IndexRangeScan_15 - └─IndexRangeScan_15 1.25 cop[tikv] table:t2, index:a, range: decided by [eq(test.t.a, test.t.a)], keep order:false, stats:pseudo +id estRows task access object operator info +Limit_12 5.00 root offset:0, count:5 +└─Selection_13 5.00 root isnull(test.t.a) + └─IndexJoin_17 5.00 root left outer join, inner:IndexReader_16, outer key:test.t.a, inner key:test.t.a + ├─TableReader_25(Build) 4.00 root data:TableFullScan_24 + │ └─TableFullScan_24 4.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─IndexReader_16(Probe) 1.25 root index:IndexRangeScan_15 + └─IndexRangeScan_15 1.25 cop[tikv] table:t2, index:idx(a) range: decided by [eq(test.t.a, test.t.a)], keep order:false, stats:pseudo explain select /*+ TIDB_SMJ(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a limit 5; -id estRows task operator info -Limit_11 5.00 root offset:0, count:5 -└─MergeJoin_12 5.00 root inner join, left key:test.t.a, right key:test.t.a - ├─IndexReader_17(Build) 4.00 root index:IndexFullScan_16 - │ └─IndexFullScan_16 4.00 cop[tikv] table:t2, index:a, keep order:true, stats:pseudo - └─IndexReader_15(Probe) 4.00 root index:IndexFullScan_14 - └─IndexFullScan_14 4.00 cop[tikv] table:t1, index:a, keep order:true, stats:pseudo +id estRows task access object operator info +Limit_11 5.00 root offset:0, count:5 +└─MergeJoin_12 5.00 root inner join, left key:test.t.a, right key:test.t.a + ├─IndexReader_17(Build) 4.00 root index:IndexFullScan_16 + │ └─IndexFullScan_16 4.00 cop[tikv] table:t2, index:idx(a) keep order:true, stats:pseudo + └─IndexReader_15(Probe) 4.00 root index:IndexFullScan_14 + └─IndexFullScan_14 4.00 cop[tikv] table:t1, index:idx(a) keep order:true, stats:pseudo explain select /*+ TIDB_SMJ(t1, t2) */ * from t t1 left join t t2 on t1.a = t2.a where t2.a is null limit 5; -id estRows task operator info -Limit_12 5.00 root offset:0, count:5 -└─Selection_13 5.00 root isnull(test.t.a) - └─MergeJoin_14 5.00 root left outer join, left key:test.t.a, right key:test.t.a - ├─IndexReader_19(Build) 4.00 root index:IndexFullScan_18 - │ └─IndexFullScan_18 4.00 cop[tikv] table:t2, index:a, keep order:true, stats:pseudo - └─IndexReader_17(Probe) 4.00 root index:IndexFullScan_16 - └─IndexFullScan_16 4.00 cop[tikv] table:t1, index:a, keep order:true, stats:pseudo +id estRows task access object operator info +Limit_12 5.00 root offset:0, count:5 +└─Selection_13 5.00 root isnull(test.t.a) + └─MergeJoin_14 5.00 root left outer join, left key:test.t.a, right key:test.t.a + ├─IndexReader_19(Build) 4.00 root index:IndexFullScan_18 + │ └─IndexFullScan_18 4.00 cop[tikv] table:t2, index:idx(a) keep order:true, stats:pseudo + └─IndexReader_17(Probe) 4.00 root index:IndexFullScan_16 + └─IndexFullScan_16 4.00 cop[tikv] table:t1, index:idx(a) keep order:true, stats:pseudo explain select /*+ TIDB_HJ(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a limit 5; -id estRows task operator info -Limit_11 5.00 root offset:0, count:5 -└─HashLeftJoin_31 5.00 root inner join, equal:[eq(test.t.a, test.t.a)] - ├─TableReader_38(Build) 10000.00 root data:TableFullScan_37 - │ └─TableFullScan_37 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo - └─TableReader_34(Probe) 4.00 root data:TableFullScan_33 - └─TableFullScan_33 4.00 cop[tikv] table:t1, keep order:false, stats:pseudo +id estRows task access object operator info +Limit_11 5.00 root offset:0, count:5 +└─HashJoin_31 5.00 root inner join, equal:[eq(test.t.a, test.t.a)] + ├─TableReader_38(Build) 10000.00 root data:TableFullScan_37 + │ └─TableFullScan_37 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader_34(Probe) 4.00 root data:TableFullScan_33 + └─TableFullScan_33 4.00 cop[tikv] table:t1 keep order:false, stats:pseudo explain select /*+ TIDB_HJ(t1, t2) */ * from t t1 left join t t2 on t1.a = t2.a where t2.a is null limit 5; -id estRows task operator info -Limit_12 5.00 root offset:0, count:5 -└─Selection_13 5.00 root isnull(test.t.a) - └─HashLeftJoin_25 5.00 root left outer join, equal:[eq(test.t.a, test.t.a)] - ├─TableReader_27(Build) 4.00 root data:TableFullScan_26 - │ └─TableFullScan_26 4.00 cop[tikv] table:t1, keep order:false, stats:pseudo - └─TableReader_31(Probe) 10000.00 root data:TableFullScan_30 - └─TableFullScan_30 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo +id estRows task access object operator info +Limit_12 5.00 root offset:0, count:5 +└─Selection_13 5.00 root isnull(test.t.a) + └─HashJoin_25 5.00 root left outer join, equal:[eq(test.t.a, test.t.a)] + ├─TableReader_27(Build) 4.00 root data:TableFullScan_26 + │ └─TableFullScan_26 4.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─TableReader_31(Probe) 10000.00 root data:TableFullScan_30 + └─TableFullScan_30 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/topn_pushdown.result b/cmd/explaintest/r/topn_pushdown.result index faa038c0e6c05..ce87bbd941792 100644 --- a/cmd/explaintest/r/topn_pushdown.result +++ b/cmd/explaintest/r/topn_pushdown.result @@ -1,8 +1,8 @@ explain select * from ((select 4 as a) union all (select 33 as a)) tmp order by a desc limit 1; -id estRows task operator info -TopN_17 1.00 root Column#3:desc, offset:0, count:1 -└─Union_21 2.00 root - ├─Projection_22 1.00 root 4->Column#3 - │ └─TableDual_23 1.00 root rows:1 - └─Projection_24 1.00 root 33->Column#3 - └─TableDual_25 1.00 root rows:1 +id estRows task access object operator info +TopN_17 1.00 root Column#3:desc, offset:0, count:1 +└─Union_21 2.00 root + ├─Projection_22 1.00 root 4->Column#3 + │ └─TableDual_23 1.00 root rows:1 + └─Projection_24 1.00 root 33->Column#3 + └─TableDual_25 1.00 root rows:1 diff --git a/cmd/explaintest/r/tpch.result b/cmd/explaintest/r/tpch.result index 58da900c598ab..6e2e543b5d356 100644 --- a/cmd/explaintest/r/tpch.result +++ b/cmd/explaintest/r/tpch.result @@ -118,14 +118,14 @@ l_linestatus order by l_returnflag, l_linestatus; -id estRows task operator info -Sort_6 2.94 root tpch.lineitem.l_returnflag:asc, tpch.lineitem.l_linestatus:asc -└─Projection_8 2.94 root tpch.lineitem.l_returnflag, tpch.lineitem.l_linestatus, Column#18, Column#19, Column#20, Column#21, Column#22, Column#23, Column#24, Column#25 - └─HashAgg_14 2.94 root group by:tpch.lineitem.l_linestatus, tpch.lineitem.l_returnflag, funcs:sum(Column#26)->Column#18, funcs:sum(Column#27)->Column#19, funcs:sum(Column#28)->Column#20, funcs:sum(Column#29)->Column#21, funcs:avg(Column#30, Column#31)->Column#22, funcs:avg(Column#32, Column#33)->Column#23, funcs:avg(Column#34, Column#35)->Column#24, funcs:count(Column#36)->Column#25, funcs:firstrow(tpch.lineitem.l_returnflag)->tpch.lineitem.l_returnflag, funcs:firstrow(tpch.lineitem.l_linestatus)->tpch.lineitem.l_linestatus - └─TableReader_15 2.94 root data:HashAgg_9 - └─HashAgg_9 2.94 cop[tikv] group by:tpch.lineitem.l_linestatus, tpch.lineitem.l_returnflag, funcs:sum(tpch.lineitem.l_quantity)->Column#26, funcs:sum(tpch.lineitem.l_extendedprice)->Column#27, funcs:sum(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)))->Column#28, funcs:sum(mul(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)), plus(1, tpch.lineitem.l_tax)))->Column#29, funcs:count(tpch.lineitem.l_quantity)->Column#30, funcs:sum(tpch.lineitem.l_quantity)->Column#31, funcs:count(tpch.lineitem.l_extendedprice)->Column#32, funcs:sum(tpch.lineitem.l_extendedprice)->Column#33, funcs:count(tpch.lineitem.l_discount)->Column#34, funcs:sum(tpch.lineitem.l_discount)->Column#35, funcs:count(1)->Column#36 - └─Selection_13 293795345.00 cop[tikv] le(tpch.lineitem.l_shipdate, 1998-08-15) - └─TableFullScan_12 300005811.00 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Sort_6 2.94 root tpch.lineitem.l_returnflag:asc, tpch.lineitem.l_linestatus:asc +└─Projection_8 2.94 root tpch.lineitem.l_returnflag, tpch.lineitem.l_linestatus, Column#18, Column#19, Column#20, Column#21, Column#22, Column#23, Column#24, Column#25 + └─HashAgg_14 2.94 root group by:tpch.lineitem.l_linestatus, tpch.lineitem.l_returnflag, funcs:sum(Column#26)->Column#18, funcs:sum(Column#27)->Column#19, funcs:sum(Column#28)->Column#20, funcs:sum(Column#29)->Column#21, funcs:avg(Column#30, Column#31)->Column#22, funcs:avg(Column#32, Column#33)->Column#23, funcs:avg(Column#34, Column#35)->Column#24, funcs:count(Column#36)->Column#25, funcs:firstrow(tpch.lineitem.l_returnflag)->tpch.lineitem.l_returnflag, funcs:firstrow(tpch.lineitem.l_linestatus)->tpch.lineitem.l_linestatus + └─TableReader_15 2.94 root data:HashAgg_9 + └─HashAgg_9 2.94 cop[tikv] group by:tpch.lineitem.l_linestatus, tpch.lineitem.l_returnflag, funcs:sum(tpch.lineitem.l_quantity)->Column#26, funcs:sum(tpch.lineitem.l_extendedprice)->Column#27, funcs:sum(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)))->Column#28, funcs:sum(mul(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)), plus(1, tpch.lineitem.l_tax)))->Column#29, funcs:count(tpch.lineitem.l_quantity)->Column#30, funcs:sum(tpch.lineitem.l_quantity)->Column#31, funcs:count(tpch.lineitem.l_extendedprice)->Column#32, funcs:sum(tpch.lineitem.l_extendedprice)->Column#33, funcs:count(tpch.lineitem.l_discount)->Column#34, funcs:sum(tpch.lineitem.l_discount)->Column#35, funcs:count(1)->Column#36 + └─Selection_13 293795345.00 cop[tikv] le(tpch.lineitem.l_shipdate, 1998-08-15) + └─TableFullScan_12 300005811.00 cop[tikv] table:lineitem keep order:false /* Q2 Minimum Cost Supplier Query This query finds which supplier should be selected to place an order for a given part in a given region. @@ -181,40 +181,40 @@ n_name, s_name, p_partkey limit 100; -id estRows task operator info -Projection_37 100.00 root tpch.supplier.s_acctbal, tpch.supplier.s_name, tpch.nation.n_name, tpch.part.p_partkey, tpch.part.p_mfgr, tpch.supplier.s_address, tpch.supplier.s_phone, tpch.supplier.s_comment -└─TopN_40 100.00 root tpch.supplier.s_acctbal:desc, tpch.nation.n_name:asc, tpch.supplier.s_name:asc, tpch.part.p_partkey:asc, offset:0, count:100 - └─HashRightJoin_46 155496.00 root inner join, equal:[eq(tpch.part.p_partkey, tpch.partsupp.ps_partkey) eq(tpch.partsupp.ps_supplycost, Column#50)] - ├─HashLeftJoin_60(Build) 155496.00 root inner join, equal:[eq(tpch.partsupp.ps_partkey, tpch.part.p_partkey)] - │ ├─TableReader_90(Build) 155496.00 root data:Selection_89 - │ │ └─Selection_89 155496.00 cop[tikv] eq(tpch.part.p_size, 30), like(tpch.part.p_type, "%STEEL", 92) - │ │ └─TableFullScan_88 10000000.00 cop[tikv] table:part, keep order:false - │ └─HashRightJoin_63(Probe) 8155010.44 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.partsupp.ps_suppkey)] - │ ├─HashRightJoin_65(Build) 100000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] - │ │ ├─HashRightJoin_78(Build) 5.00 root inner join, equal:[eq(tpch.region.r_regionkey, tpch.nation.n_regionkey)] - │ │ │ ├─TableReader_83(Build) 1.00 root data:Selection_82 - │ │ │ │ └─Selection_82 1.00 cop[tikv] eq(tpch.region.r_name, "ASIA") - │ │ │ │ └─TableFullScan_81 5.00 cop[tikv] table:region, keep order:false - │ │ │ └─TableReader_80(Probe) 25.00 root data:TableFullScan_79 - │ │ │ └─TableFullScan_79 25.00 cop[tikv] table:nation, keep order:false - │ │ └─TableReader_85(Probe) 500000.00 root data:TableFullScan_84 - │ │ └─TableFullScan_84 500000.00 cop[tikv] table:supplier, keep order:false - │ └─TableReader_87(Probe) 40000000.00 root data:TableFullScan_86 - │ └─TableFullScan_86 40000000.00 cop[tikv] table:partsupp, keep order:false - └─Selection_91(Probe) 6524008.35 root not(isnull(Column#50)) - └─HashAgg_94 8155010.44 root group by:tpch.partsupp.ps_partkey, funcs:min(tpch.partsupp.ps_supplycost)->Column#50, funcs:firstrow(tpch.partsupp.ps_partkey)->tpch.partsupp.ps_partkey - └─HashRightJoin_98 8155010.44 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.partsupp.ps_suppkey)] - ├─HashRightJoin_100(Build) 100000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] - │ ├─HashRightJoin_113(Build) 5.00 root inner join, equal:[eq(tpch.region.r_regionkey, tpch.nation.n_regionkey)] - │ │ ├─TableReader_118(Build) 1.00 root data:Selection_117 - │ │ │ └─Selection_117 1.00 cop[tikv] eq(tpch.region.r_name, "ASIA") - │ │ │ └─TableFullScan_116 5.00 cop[tikv] table:region, keep order:false - │ │ └─TableReader_115(Probe) 25.00 root data:TableFullScan_114 - │ │ └─TableFullScan_114 25.00 cop[tikv] table:nation, keep order:false - │ └─TableReader_120(Probe) 500000.00 root data:TableFullScan_119 - │ └─TableFullScan_119 500000.00 cop[tikv] table:supplier, keep order:false - └─TableReader_122(Probe) 40000000.00 root data:TableFullScan_121 - └─TableFullScan_121 40000000.00 cop[tikv] table:partsupp, keep order:false +id estRows task access object operator info +Projection_37 100.00 root tpch.supplier.s_acctbal, tpch.supplier.s_name, tpch.nation.n_name, tpch.part.p_partkey, tpch.part.p_mfgr, tpch.supplier.s_address, tpch.supplier.s_phone, tpch.supplier.s_comment +└─TopN_40 100.00 root tpch.supplier.s_acctbal:desc, tpch.nation.n_name:asc, tpch.supplier.s_name:asc, tpch.part.p_partkey:asc, offset:0, count:100 + └─HashJoin_46 155496.00 root inner join, equal:[eq(tpch.part.p_partkey, tpch.partsupp.ps_partkey) eq(tpch.partsupp.ps_supplycost, Column#50)] + ├─HashJoin_60(Build) 155496.00 root inner join, equal:[eq(tpch.partsupp.ps_partkey, tpch.part.p_partkey)] + │ ├─TableReader_90(Build) 155496.00 root data:Selection_89 + │ │ └─Selection_89 155496.00 cop[tikv] eq(tpch.part.p_size, 30), like(tpch.part.p_type, "%STEEL", 92) + │ │ └─TableFullScan_88 10000000.00 cop[tikv] table:part keep order:false + │ └─HashJoin_63(Probe) 8155010.44 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.partsupp.ps_suppkey)] + │ ├─HashJoin_65(Build) 100000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] + │ │ ├─HashJoin_78(Build) 5.00 root inner join, equal:[eq(tpch.region.r_regionkey, tpch.nation.n_regionkey)] + │ │ │ ├─TableReader_83(Build) 1.00 root data:Selection_82 + │ │ │ │ └─Selection_82 1.00 cop[tikv] eq(tpch.region.r_name, "ASIA") + │ │ │ │ └─TableFullScan_81 5.00 cop[tikv] table:region keep order:false + │ │ │ └─TableReader_80(Probe) 25.00 root data:TableFullScan_79 + │ │ │ └─TableFullScan_79 25.00 cop[tikv] table:nation keep order:false + │ │ └─TableReader_85(Probe) 500000.00 root data:TableFullScan_84 + │ │ └─TableFullScan_84 500000.00 cop[tikv] table:supplier keep order:false + │ └─TableReader_87(Probe) 40000000.00 root data:TableFullScan_86 + │ └─TableFullScan_86 40000000.00 cop[tikv] table:partsupp keep order:false + └─Selection_91(Probe) 6524008.35 root not(isnull(Column#50)) + └─HashAgg_94 8155010.44 root group by:tpch.partsupp.ps_partkey, funcs:min(tpch.partsupp.ps_supplycost)->Column#50, funcs:firstrow(tpch.partsupp.ps_partkey)->tpch.partsupp.ps_partkey + └─HashJoin_98 8155010.44 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.partsupp.ps_suppkey)] + ├─HashJoin_100(Build) 100000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] + │ ├─HashJoin_113(Build) 5.00 root inner join, equal:[eq(tpch.region.r_regionkey, tpch.nation.n_regionkey)] + │ │ ├─TableReader_118(Build) 1.00 root data:Selection_117 + │ │ │ └─Selection_117 1.00 cop[tikv] eq(tpch.region.r_name, "ASIA") + │ │ │ └─TableFullScan_116 5.00 cop[tikv] table:region keep order:false + │ │ └─TableReader_115(Probe) 25.00 root data:TableFullScan_114 + │ │ └─TableFullScan_114 25.00 cop[tikv] table:nation keep order:false + │ └─TableReader_120(Probe) 500000.00 root data:TableFullScan_119 + │ └─TableFullScan_119 500000.00 cop[tikv] table:supplier keep order:false + └─TableReader_122(Probe) 40000000.00 root data:TableFullScan_121 + └─TableFullScan_121 40000000.00 cop[tikv] table:partsupp keep order:false /* Q3 Shipping Priority Query This query retrieves the 10 unshipped orders with the highest value. @@ -248,22 +248,22 @@ order by revenue desc, o_orderdate limit 10; -id estRows task operator info -Projection_14 10.00 root tpch.lineitem.l_orderkey, Column#35, tpch.orders.o_orderdate, tpch.orders.o_shippriority -└─TopN_17 10.00 root Column#35:desc, tpch.orders.o_orderdate:asc, offset:0, count:10 - └─HashAgg_23 40252367.98 root group by:Column#48, Column#49, Column#50, funcs:sum(Column#44)->Column#35, funcs:firstrow(Column#45)->tpch.orders.o_orderdate, funcs:firstrow(Column#46)->tpch.orders.o_shippriority, funcs:firstrow(Column#47)->tpch.lineitem.l_orderkey - └─Projection_81 91515927.49 root mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#44, tpch.orders.o_orderdate, tpch.orders.o_shippriority, tpch.lineitem.l_orderkey, tpch.lineitem.l_orderkey, tpch.orders.o_orderdate, tpch.orders.o_shippriority - └─HashRightJoin_40 91515927.49 root inner join, equal:[eq(tpch.orders.o_orderkey, tpch.lineitem.l_orderkey)] - ├─HashRightJoin_71(Build) 22592975.51 root inner join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] - │ ├─TableReader_77(Build) 1498236.00 root data:Selection_76 - │ │ └─Selection_76 1498236.00 cop[tikv] eq(tpch.customer.c_mktsegment, "AUTOMOBILE") - │ │ └─TableFullScan_75 7500000.00 cop[tikv] table:customer, keep order:false - │ └─TableReader_74(Probe) 36870000.00 root data:Selection_73 - │ └─Selection_73 36870000.00 cop[tikv] lt(tpch.orders.o_orderdate, 1995-03-13 00:00:00.000000) - │ └─TableFullScan_72 75000000.00 cop[tikv] table:orders, keep order:false - └─TableReader_80(Probe) 163047704.27 root data:Selection_79 - └─Selection_79 163047704.27 cop[tikv] gt(tpch.lineitem.l_shipdate, 1995-03-13 00:00:00.000000) - └─TableFullScan_78 300005811.00 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Projection_14 10.00 root tpch.lineitem.l_orderkey, Column#35, tpch.orders.o_orderdate, tpch.orders.o_shippriority +└─TopN_17 10.00 root Column#35:desc, tpch.orders.o_orderdate:asc, offset:0, count:10 + └─HashAgg_23 40252367.98 root group by:Column#48, Column#49, Column#50, funcs:sum(Column#44)->Column#35, funcs:firstrow(Column#45)->tpch.orders.o_orderdate, funcs:firstrow(Column#46)->tpch.orders.o_shippriority, funcs:firstrow(Column#47)->tpch.lineitem.l_orderkey + └─Projection_81 91515927.49 root mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#44, tpch.orders.o_orderdate, tpch.orders.o_shippriority, tpch.lineitem.l_orderkey, tpch.lineitem.l_orderkey, tpch.orders.o_orderdate, tpch.orders.o_shippriority + └─HashJoin_40 91515927.49 root inner join, equal:[eq(tpch.orders.o_orderkey, tpch.lineitem.l_orderkey)] + ├─HashJoin_71(Build) 22592975.51 root inner join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] + │ ├─TableReader_77(Build) 1498236.00 root data:Selection_76 + │ │ └─Selection_76 1498236.00 cop[tikv] eq(tpch.customer.c_mktsegment, "AUTOMOBILE") + │ │ └─TableFullScan_75 7500000.00 cop[tikv] table:customer keep order:false + │ └─TableReader_74(Probe) 36870000.00 root data:Selection_73 + │ └─Selection_73 36870000.00 cop[tikv] lt(tpch.orders.o_orderdate, 1995-03-13 00:00:00.000000) + │ └─TableFullScan_72 75000000.00 cop[tikv] table:orders keep order:false + └─TableReader_80(Probe) 163047704.27 root data:Selection_79 + └─Selection_79 163047704.27 cop[tikv] gt(tpch.lineitem.l_shipdate, 1995-03-13 00:00:00.000000) + └─TableFullScan_78 300005811.00 cop[tikv] table:lineitem keep order:false /* Q4 Order Priority Checking Query This query determines how well the order priority system is working and gives an assessment of customer satisfaction. @@ -293,18 +293,18 @@ group by o_orderpriority order by o_orderpriority; -id estRows task operator info -Sort_10 1.00 root tpch.orders.o_orderpriority:asc -└─Projection_12 1.00 root tpch.orders.o_orderpriority, Column#27 - └─HashAgg_15 1.00 root group by:tpch.orders.o_orderpriority, funcs:count(1)->Column#27, funcs:firstrow(tpch.orders.o_orderpriority)->tpch.orders.o_orderpriority - └─IndexHashJoin_30 2340750.00 root semi join, inner:IndexLookUp_20, outer key:tpch.orders.o_orderkey, inner key:tpch.lineitem.l_orderkey - ├─TableReader_42(Build) 2925937.50 root data:Selection_41 - │ └─Selection_41 2925937.50 cop[tikv] ge(tpch.orders.o_orderdate, 1995-01-01 00:00:00.000000), lt(tpch.orders.o_orderdate, 1995-04-01) - │ └─TableFullScan_40 75000000.00 cop[tikv] table:orders, keep order:false - └─IndexLookUp_20(Probe) 4.05 root - ├─IndexRangeScan_17(Build) 5.06 cop[tikv] table:lineitem, index:L_ORDERKEY, L_LINENUMBER, range: decided by [eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)], keep order:false - └─Selection_19(Probe) 4.05 cop[tikv] lt(tpch.lineitem.l_commitdate, tpch.lineitem.l_receiptdate) - └─TableRowIDScan_18 5.06 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Sort_10 1.00 root tpch.orders.o_orderpriority:asc +└─Projection_12 1.00 root tpch.orders.o_orderpriority, Column#27 + └─HashAgg_15 1.00 root group by:tpch.orders.o_orderpriority, funcs:count(1)->Column#27, funcs:firstrow(tpch.orders.o_orderpriority)->tpch.orders.o_orderpriority + └─IndexHashJoin_30 2340750.00 root semi join, inner:IndexLookUp_20, outer key:tpch.orders.o_orderkey, inner key:tpch.lineitem.l_orderkey + ├─TableReader_42(Build) 2925937.50 root data:Selection_41 + │ └─Selection_41 2925937.50 cop[tikv] ge(tpch.orders.o_orderdate, 1995-01-01 00:00:00.000000), lt(tpch.orders.o_orderdate, 1995-04-01) + │ └─TableFullScan_40 75000000.00 cop[tikv] table:orders keep order:false + └─IndexLookUp_20(Probe) 4.05 root + ├─IndexRangeScan_17(Build) 5.06 cop[tikv] table:lineitem, index:PRIMARY(L_ORDERKEY, L_LINENUMBER) range: decided by [eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)], keep order:false + └─Selection_19(Probe) 4.05 cop[tikv] lt(tpch.lineitem.l_commitdate, tpch.lineitem.l_receiptdate) + └─TableRowIDScan_18 5.06 cop[tikv] table:lineitem keep order:false /* Q5 Local Supplier Volume Query This query lists the revenue volume done through local suppliers. @@ -341,30 +341,30 @@ group by n_name order by revenue desc; -id estRows task operator info -Sort_23 5.00 root Column#49:desc -└─Projection_25 5.00 root tpch.nation.n_name, Column#49 - └─HashAgg_28 5.00 root group by:Column#52, funcs:sum(Column#50)->Column#49, funcs:firstrow(Column#51)->tpch.nation.n_name - └─Projection_86 11822812.50 root mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#50, tpch.nation.n_name, tpch.nation.n_name - └─HashLeftJoin_38 11822812.50 root inner join, equal:[eq(tpch.supplier.s_nationkey, tpch.customer.c_nationkey) eq(tpch.orders.o_custkey, tpch.customer.c_custkey)] - ├─TableReader_84(Build) 7500000.00 root data:TableFullScan_83 - │ └─TableFullScan_83 7500000.00 cop[tikv] table:customer, keep order:false - └─HashLeftJoin_52(Probe) 11822812.50 root inner join, equal:[eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)] - ├─TableReader_82(Build) 11822812.50 root data:Selection_81 - │ └─Selection_81 11822812.50 cop[tikv] ge(tpch.orders.o_orderdate, 1994-01-01 00:00:00.000000), lt(tpch.orders.o_orderdate, 1995-01-01) - │ └─TableFullScan_80 75000000.00 cop[tikv] table:orders, keep order:false - └─HashRightJoin_55(Probe) 61163763.01 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.lineitem.l_suppkey)] - ├─HashRightJoin_57(Build) 100000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] - │ ├─HashRightJoin_70(Build) 5.00 root inner join, equal:[eq(tpch.region.r_regionkey, tpch.nation.n_regionkey)] - │ │ ├─TableReader_75(Build) 1.00 root data:Selection_74 - │ │ │ └─Selection_74 1.00 cop[tikv] eq(tpch.region.r_name, "MIDDLE EAST") - │ │ │ └─TableFullScan_73 5.00 cop[tikv] table:region, keep order:false - │ │ └─TableReader_72(Probe) 25.00 root data:TableFullScan_71 - │ │ └─TableFullScan_71 25.00 cop[tikv] table:nation, keep order:false - │ └─TableReader_77(Probe) 500000.00 root data:TableFullScan_76 - │ └─TableFullScan_76 500000.00 cop[tikv] table:supplier, keep order:false - └─TableReader_79(Probe) 300005811.00 root data:TableFullScan_78 - └─TableFullScan_78 300005811.00 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Sort_23 5.00 root Column#49:desc +└─Projection_25 5.00 root tpch.nation.n_name, Column#49 + └─HashAgg_28 5.00 root group by:Column#52, funcs:sum(Column#50)->Column#49, funcs:firstrow(Column#51)->tpch.nation.n_name + └─Projection_86 11822812.50 root mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#50, tpch.nation.n_name, tpch.nation.n_name + └─HashJoin_38 11822812.50 root inner join, equal:[eq(tpch.supplier.s_nationkey, tpch.customer.c_nationkey) eq(tpch.orders.o_custkey, tpch.customer.c_custkey)] + ├─TableReader_84(Build) 7500000.00 root data:TableFullScan_83 + │ └─TableFullScan_83 7500000.00 cop[tikv] table:customer keep order:false + └─HashJoin_52(Probe) 11822812.50 root inner join, equal:[eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)] + ├─TableReader_82(Build) 11822812.50 root data:Selection_81 + │ └─Selection_81 11822812.50 cop[tikv] ge(tpch.orders.o_orderdate, 1994-01-01 00:00:00.000000), lt(tpch.orders.o_orderdate, 1995-01-01) + │ └─TableFullScan_80 75000000.00 cop[tikv] table:orders keep order:false + └─HashJoin_55(Probe) 61163763.01 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.lineitem.l_suppkey)] + ├─HashJoin_57(Build) 100000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] + │ ├─HashJoin_70(Build) 5.00 root inner join, equal:[eq(tpch.region.r_regionkey, tpch.nation.n_regionkey)] + │ │ ├─TableReader_75(Build) 1.00 root data:Selection_74 + │ │ │ └─Selection_74 1.00 cop[tikv] eq(tpch.region.r_name, "MIDDLE EAST") + │ │ │ └─TableFullScan_73 5.00 cop[tikv] table:region keep order:false + │ │ └─TableReader_72(Probe) 25.00 root data:TableFullScan_71 + │ │ └─TableFullScan_71 25.00 cop[tikv] table:nation keep order:false + │ └─TableReader_77(Probe) 500000.00 root data:TableFullScan_76 + │ └─TableFullScan_76 500000.00 cop[tikv] table:supplier keep order:false + └─TableReader_79(Probe) 300005811.00 root data:TableFullScan_78 + └─TableFullScan_78 300005811.00 cop[tikv] table:lineitem keep order:false /* Q6 Forecasting Revenue Change Query This query quantifies the amount of revenue increase that would have resulted from eliminating certain companywide @@ -386,12 +386,12 @@ l_shipdate >= '1994-01-01' and l_shipdate < date_add('1994-01-01', interval '1' year) and l_discount between 0.06 - 0.01 and 0.06 + 0.01 and l_quantity < 24; -id estRows task operator info -StreamAgg_20 1.00 root funcs:sum(Column#20)->Column#18 -└─TableReader_21 1.00 root data:StreamAgg_9 - └─StreamAgg_9 1.00 cop[tikv] funcs:sum(mul(tpch.lineitem.l_extendedprice, tpch.lineitem.l_discount))->Column#20 - └─Selection_19 3713857.91 cop[tikv] ge(tpch.lineitem.l_discount, 0.05), ge(tpch.lineitem.l_shipdate, 1994-01-01 00:00:00.000000), le(tpch.lineitem.l_discount, 0.07), lt(tpch.lineitem.l_quantity, 24), lt(tpch.lineitem.l_shipdate, 1995-01-01) - └─TableFullScan_18 300005811.00 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +StreamAgg_20 1.00 root funcs:sum(Column#20)->Column#18 +└─TableReader_21 1.00 root data:StreamAgg_9 + └─StreamAgg_9 1.00 cop[tikv] funcs:sum(mul(tpch.lineitem.l_extendedprice, tpch.lineitem.l_discount))->Column#20 + └─Selection_19 3713857.91 cop[tikv] ge(tpch.lineitem.l_discount, 0.05), ge(tpch.lineitem.l_shipdate, 1994-01-01 00:00:00.000000), le(tpch.lineitem.l_discount, 0.07), lt(tpch.lineitem.l_quantity, 24), lt(tpch.lineitem.l_shipdate, 1995-01-01) + └─TableFullScan_18 300005811.00 cop[tikv] table:lineitem keep order:false /* Q7 Volume Shipping Query This query determines the value of goods shipped between certain nations to help in the re-negotiation of shipping @@ -442,31 +442,31 @@ order by supp_nation, cust_nation, l_year; -id estRows task operator info -Sort_22 769.96 root tpch.nation.n_name:asc, tpch.nation.n_name:asc, Column#50:asc -└─Projection_24 769.96 root tpch.nation.n_name, tpch.nation.n_name, Column#50, Column#52 - └─HashAgg_27 769.96 root group by:Column#50, tpch.nation.n_name, tpch.nation.n_name, funcs:sum(Column#51)->Column#52, funcs:firstrow(tpch.nation.n_name)->tpch.nation.n_name, funcs:firstrow(tpch.nation.n_name)->tpch.nation.n_name, funcs:firstrow(Column#50)->Column#50 - └─Projection_28 1957240.42 root tpch.nation.n_name, tpch.nation.n_name, extract(YEAR, tpch.lineitem.l_shipdate)->Column#50, mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#51 - └─HashLeftJoin_40 1957240.42 root inner join, equal:[eq(tpch.customer.c_nationkey, tpch.nation.n_nationkey)], other cond:or(and(eq(tpch.nation.n_name, "JAPAN"), eq(tpch.nation.n_name, "INDIA")), and(eq(tpch.nation.n_name, "INDIA"), eq(tpch.nation.n_name, "JAPAN"))) - ├─TableReader_94(Build) 2.00 root data:Selection_93 - │ └─Selection_93 2.00 cop[tikv] or(eq(tpch.nation.n_name, "INDIA"), eq(tpch.nation.n_name, "JAPAN")) - │ └─TableFullScan_92 25.00 cop[tikv] table:n2, keep order:false - └─HashLeftJoin_51(Probe) 24465505.20 root inner join, equal:[eq(tpch.orders.o_custkey, tpch.customer.c_custkey)] - ├─TableReader_91(Build) 7500000.00 root data:TableFullScan_90 - │ └─TableFullScan_90 7500000.00 cop[tikv] table:customer, keep order:false - └─IndexMergeJoin_60(Probe) 24465505.20 root inner join, inner:TableReader_58, outer key:tpch.lineitem.l_orderkey, inner key:tpch.orders.o_orderkey - ├─HashRightJoin_66(Build) 24465505.20 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.lineitem.l_suppkey)] - │ ├─HashRightJoin_79(Build) 40000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] - │ │ ├─TableReader_84(Build) 2.00 root data:Selection_83 - │ │ │ └─Selection_83 2.00 cop[tikv] or(eq(tpch.nation.n_name, "JAPAN"), eq(tpch.nation.n_name, "INDIA")) - │ │ │ └─TableFullScan_82 25.00 cop[tikv] table:n1, keep order:false - │ │ └─TableReader_81(Probe) 500000.00 root data:TableFullScan_80 - │ │ └─TableFullScan_80 500000.00 cop[tikv] table:supplier, keep order:false - │ └─TableReader_87(Probe) 91446230.29 root data:Selection_86 - │ └─Selection_86 91446230.29 cop[tikv] ge(tpch.lineitem.l_shipdate, 1995-01-01 00:00:00.000000), le(tpch.lineitem.l_shipdate, 1996-12-31 00:00:00.000000) - │ └─TableFullScan_85 300005811.00 cop[tikv] table:lineitem, keep order:false - └─TableReader_58(Probe) 1.00 root data:TableRangeScan_57 - └─TableRangeScan_57 1.00 cop[tikv] table:orders, range: decided by [tpch.lineitem.l_orderkey], keep order:true +id estRows task access object operator info +Sort_22 769.96 root tpch.nation.n_name:asc, tpch.nation.n_name:asc, Column#50:asc +└─Projection_24 769.96 root tpch.nation.n_name, tpch.nation.n_name, Column#50, Column#52 + └─HashAgg_27 769.96 root group by:Column#50, tpch.nation.n_name, tpch.nation.n_name, funcs:sum(Column#51)->Column#52, funcs:firstrow(tpch.nation.n_name)->tpch.nation.n_name, funcs:firstrow(tpch.nation.n_name)->tpch.nation.n_name, funcs:firstrow(Column#50)->Column#50 + └─Projection_28 1957240.42 root tpch.nation.n_name, tpch.nation.n_name, extract(YEAR, tpch.lineitem.l_shipdate)->Column#50, mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#51 + └─HashJoin_40 1957240.42 root inner join, equal:[eq(tpch.customer.c_nationkey, tpch.nation.n_nationkey)], other cond:or(and(eq(tpch.nation.n_name, "JAPAN"), eq(tpch.nation.n_name, "INDIA")), and(eq(tpch.nation.n_name, "INDIA"), eq(tpch.nation.n_name, "JAPAN"))) + ├─TableReader_94(Build) 2.00 root data:Selection_93 + │ └─Selection_93 2.00 cop[tikv] or(eq(tpch.nation.n_name, "INDIA"), eq(tpch.nation.n_name, "JAPAN")) + │ └─TableFullScan_92 25.00 cop[tikv] table:n2 keep order:false + └─HashJoin_51(Probe) 24465505.20 root inner join, equal:[eq(tpch.orders.o_custkey, tpch.customer.c_custkey)] + ├─TableReader_91(Build) 7500000.00 root data:TableFullScan_90 + │ └─TableFullScan_90 7500000.00 cop[tikv] table:customer keep order:false + └─IndexMergeJoin_60(Probe) 24465505.20 root inner join, inner:TableReader_58, outer key:tpch.lineitem.l_orderkey, inner key:tpch.orders.o_orderkey + ├─HashJoin_66(Build) 24465505.20 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.lineitem.l_suppkey)] + │ ├─HashJoin_79(Build) 40000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] + │ │ ├─TableReader_84(Build) 2.00 root data:Selection_83 + │ │ │ └─Selection_83 2.00 cop[tikv] or(eq(tpch.nation.n_name, "JAPAN"), eq(tpch.nation.n_name, "INDIA")) + │ │ │ └─TableFullScan_82 25.00 cop[tikv] table:n1 keep order:false + │ │ └─TableReader_81(Probe) 500000.00 root data:TableFullScan_80 + │ │ └─TableFullScan_80 500000.00 cop[tikv] table:supplier keep order:false + │ └─TableReader_87(Probe) 91446230.29 root data:Selection_86 + │ └─Selection_86 91446230.29 cop[tikv] ge(tpch.lineitem.l_shipdate, 1995-01-01 00:00:00.000000), le(tpch.lineitem.l_shipdate, 1996-12-31 00:00:00.000000) + │ └─TableFullScan_85 300005811.00 cop[tikv] table:lineitem keep order:false + └─TableReader_58(Probe) 1.00 root data:TableRangeScan_57 + └─TableRangeScan_57 1.00 cop[tikv] table:orders range: decided by [tpch.lineitem.l_orderkey], keep order:true /* Q8 National Market Share Query This query determines how the market share of a given nation within a given region has changed over two years for @@ -514,39 +514,39 @@ group by o_year order by o_year; -id estRows task operator info -Sort_29 719.02 root Column#62:asc -└─Projection_31 719.02 root Column#62, div(Column#64, Column#65)->Column#66 - └─HashAgg_34 719.02 root group by:Column#78, funcs:sum(Column#75)->Column#64, funcs:sum(Column#76)->Column#65, funcs:firstrow(Column#77)->Column#62 - └─Projection_123 563136.02 root case(eq(tpch.nation.n_name, INDIA), Column#63, 0)->Column#75, Column#63, Column#62, Column#62 - └─Projection_35 563136.02 root extract(YEAR, tpch.orders.o_orderdate)->Column#62, mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#63, tpch.nation.n_name - └─HashLeftJoin_45 563136.02 root inner join, equal:[eq(tpch.supplier.s_nationkey, tpch.nation.n_nationkey)] - ├─TableReader_121(Build) 25.00 root data:TableFullScan_120 - │ └─TableFullScan_120 25.00 cop[tikv] table:n2, keep order:false - └─HashLeftJoin_56(Probe) 563136.02 root inner join, equal:[eq(tpch.lineitem.l_suppkey, tpch.supplier.s_suppkey)] - ├─TableReader_119(Build) 500000.00 root data:TableFullScan_118 - │ └─TableFullScan_118 500000.00 cop[tikv] table:supplier, keep order:false - └─HashLeftJoin_69(Probe) 563136.02 root inner join, equal:[eq(tpch.lineitem.l_partkey, tpch.part.p_partkey)] - ├─TableReader_117(Build) 61674.00 root data:Selection_116 - │ └─Selection_116 61674.00 cop[tikv] eq(tpch.part.p_type, "SMALL PLATED COPPER") - │ └─TableFullScan_115 10000000.00 cop[tikv] table:part, keep order:false - └─IndexHashJoin_83(Probe) 90788402.51 root inner join, inner:IndexLookUp_74, outer key:tpch.orders.o_orderkey, inner key:tpch.lineitem.l_orderkey - ├─HashRightJoin_87(Build) 22413367.93 root inner join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] - │ ├─HashRightJoin_89(Build) 1500000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.customer.c_nationkey)] - │ │ ├─HashRightJoin_102(Build) 5.00 root inner join, equal:[eq(tpch.region.r_regionkey, tpch.nation.n_regionkey)] - │ │ │ ├─TableReader_107(Build) 1.00 root data:Selection_106 - │ │ │ │ └─Selection_106 1.00 cop[tikv] eq(tpch.region.r_name, "ASIA") - │ │ │ │ └─TableFullScan_105 5.00 cop[tikv] table:region, keep order:false - │ │ │ └─TableReader_104(Probe) 25.00 root data:TableFullScan_103 - │ │ │ └─TableFullScan_103 25.00 cop[tikv] table:n1, keep order:false - │ │ └─TableReader_109(Probe) 7500000.00 root data:TableFullScan_108 - │ │ └─TableFullScan_108 7500000.00 cop[tikv] table:customer, keep order:false - │ └─TableReader_112(Probe) 22413367.93 root data:Selection_111 - │ └─Selection_111 22413367.93 cop[tikv] ge(tpch.orders.o_orderdate, 1995-01-01 00:00:00.000000), le(tpch.orders.o_orderdate, 1996-12-31 00:00:00.000000) - │ └─TableFullScan_110 75000000.00 cop[tikv] table:orders, keep order:false - └─IndexLookUp_74(Probe) 4.05 root - ├─IndexRangeScan_72(Build) 4.05 cop[tikv] table:lineitem, index:L_ORDERKEY, L_LINENUMBER, range: decided by [eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)], keep order:false - └─TableRowIDScan_73(Probe) 4.05 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Sort_29 719.02 root Column#62:asc +└─Projection_31 719.02 root Column#62, div(Column#64, Column#65)->Column#66 + └─HashAgg_34 719.02 root group by:Column#78, funcs:sum(Column#75)->Column#64, funcs:sum(Column#76)->Column#65, funcs:firstrow(Column#77)->Column#62 + └─Projection_123 563136.02 root case(eq(tpch.nation.n_name, INDIA), Column#63, 0)->Column#75, Column#63, Column#62, Column#62 + └─Projection_35 563136.02 root extract(YEAR, tpch.orders.o_orderdate)->Column#62, mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#63, tpch.nation.n_name + └─HashJoin_45 563136.02 root inner join, equal:[eq(tpch.supplier.s_nationkey, tpch.nation.n_nationkey)] + ├─TableReader_121(Build) 25.00 root data:TableFullScan_120 + │ └─TableFullScan_120 25.00 cop[tikv] table:n2 keep order:false + └─HashJoin_56(Probe) 563136.02 root inner join, equal:[eq(tpch.lineitem.l_suppkey, tpch.supplier.s_suppkey)] + ├─TableReader_119(Build) 500000.00 root data:TableFullScan_118 + │ └─TableFullScan_118 500000.00 cop[tikv] table:supplier keep order:false + └─HashJoin_69(Probe) 563136.02 root inner join, equal:[eq(tpch.lineitem.l_partkey, tpch.part.p_partkey)] + ├─TableReader_117(Build) 61674.00 root data:Selection_116 + │ └─Selection_116 61674.00 cop[tikv] eq(tpch.part.p_type, "SMALL PLATED COPPER") + │ └─TableFullScan_115 10000000.00 cop[tikv] table:part keep order:false + └─IndexHashJoin_83(Probe) 90788402.51 root inner join, inner:IndexLookUp_74, outer key:tpch.orders.o_orderkey, inner key:tpch.lineitem.l_orderkey + ├─HashJoin_87(Build) 22413367.93 root inner join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] + │ ├─HashJoin_89(Build) 1500000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.customer.c_nationkey)] + │ │ ├─HashJoin_102(Build) 5.00 root inner join, equal:[eq(tpch.region.r_regionkey, tpch.nation.n_regionkey)] + │ │ │ ├─TableReader_107(Build) 1.00 root data:Selection_106 + │ │ │ │ └─Selection_106 1.00 cop[tikv] eq(tpch.region.r_name, "ASIA") + │ │ │ │ └─TableFullScan_105 5.00 cop[tikv] table:region keep order:false + │ │ │ └─TableReader_104(Probe) 25.00 root data:TableFullScan_103 + │ │ │ └─TableFullScan_103 25.00 cop[tikv] table:n1 keep order:false + │ │ └─TableReader_109(Probe) 7500000.00 root data:TableFullScan_108 + │ │ └─TableFullScan_108 7500000.00 cop[tikv] table:customer keep order:false + │ └─TableReader_112(Probe) 22413367.93 root data:Selection_111 + │ └─Selection_111 22413367.93 cop[tikv] ge(tpch.orders.o_orderdate, 1995-01-01 00:00:00.000000), le(tpch.orders.o_orderdate, 1996-12-31 00:00:00.000000) + │ └─TableFullScan_110 75000000.00 cop[tikv] table:orders keep order:false + └─IndexLookUp_74(Probe) 4.05 root + ├─IndexRangeScan_72(Build) 4.05 cop[tikv] table:lineitem, index:PRIMARY(L_ORDERKEY, L_LINENUMBER) range: decided by [eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)], keep order:false + └─TableRowIDScan_73(Probe) 4.05 cop[tikv] table:lineitem keep order:false /* Q9 Product Type Profit Measure Query This query determines how much profit is made on a given line of parts, broken out by supplier nation and year. @@ -590,29 +590,29 @@ o_year order by nation, o_year desc; -id estRows task operator info -Sort_25 2406.00 root tpch.nation.n_name:asc, Column#53:desc -└─Projection_27 2406.00 root tpch.nation.n_name, Column#53, Column#55 - └─HashAgg_30 2406.00 root group by:Column#53, tpch.nation.n_name, funcs:sum(Column#54)->Column#55, funcs:firstrow(tpch.nation.n_name)->tpch.nation.n_name, funcs:firstrow(Column#53)->Column#53 - └─Projection_31 971049283.51 root tpch.nation.n_name, extract(YEAR, tpch.orders.o_orderdate)->Column#53, minus(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)), mul(tpch.partsupp.ps_supplycost, tpch.lineitem.l_quantity))->Column#54 - └─HashLeftJoin_44 971049283.51 root inner join, equal:[eq(tpch.lineitem.l_suppkey, tpch.partsupp.ps_suppkey) eq(tpch.lineitem.l_partkey, tpch.partsupp.ps_partkey)] - ├─TableReader_106(Build) 40000000.00 root data:TableFullScan_105 - │ └─TableFullScan_105 40000000.00 cop[tikv] table:partsupp, keep order:false - └─HashLeftJoin_56(Probe) 241379546.70 root inner join, equal:[eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)] - ├─TableReader_104(Build) 75000000.00 root data:TableFullScan_103 - │ └─TableFullScan_103 75000000.00 cop[tikv] table:orders, keep order:false - └─HashLeftJoin_79(Probe) 241379546.70 root inner join, equal:[eq(tpch.lineitem.l_partkey, tpch.part.p_partkey)] - ├─TableReader_102(Build) 8000000.00 root data:Selection_101 - │ └─Selection_101 8000000.00 cop[tikv] like(tpch.part.p_name, "%dim%", 92) - │ └─TableFullScan_100 10000000.00 cop[tikv] table:part, keep order:false - └─HashRightJoin_82(Probe) 300005811.00 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.lineitem.l_suppkey)] - ├─HashRightJoin_93(Build) 500000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] - │ ├─TableReader_97(Build) 25.00 root data:TableFullScan_96 - │ │ └─TableFullScan_96 25.00 cop[tikv] table:nation, keep order:false - │ └─TableReader_95(Probe) 500000.00 root data:TableFullScan_94 - │ └─TableFullScan_94 500000.00 cop[tikv] table:supplier, keep order:false - └─TableReader_99(Probe) 300005811.00 root data:TableFullScan_98 - └─TableFullScan_98 300005811.00 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Sort_25 2406.00 root tpch.nation.n_name:asc, Column#53:desc +└─Projection_27 2406.00 root tpch.nation.n_name, Column#53, Column#55 + └─HashAgg_30 2406.00 root group by:Column#53, tpch.nation.n_name, funcs:sum(Column#54)->Column#55, funcs:firstrow(tpch.nation.n_name)->tpch.nation.n_name, funcs:firstrow(Column#53)->Column#53 + └─Projection_31 971049283.51 root tpch.nation.n_name, extract(YEAR, tpch.orders.o_orderdate)->Column#53, minus(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)), mul(tpch.partsupp.ps_supplycost, tpch.lineitem.l_quantity))->Column#54 + └─HashJoin_44 971049283.51 root inner join, equal:[eq(tpch.lineitem.l_suppkey, tpch.partsupp.ps_suppkey) eq(tpch.lineitem.l_partkey, tpch.partsupp.ps_partkey)] + ├─TableReader_106(Build) 40000000.00 root data:TableFullScan_105 + │ └─TableFullScan_105 40000000.00 cop[tikv] table:partsupp keep order:false + └─HashJoin_56(Probe) 241379546.70 root inner join, equal:[eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)] + ├─TableReader_104(Build) 75000000.00 root data:TableFullScan_103 + │ └─TableFullScan_103 75000000.00 cop[tikv] table:orders keep order:false + └─HashJoin_79(Probe) 241379546.70 root inner join, equal:[eq(tpch.lineitem.l_partkey, tpch.part.p_partkey)] + ├─TableReader_102(Build) 8000000.00 root data:Selection_101 + │ └─Selection_101 8000000.00 cop[tikv] like(tpch.part.p_name, "%dim%", 92) + │ └─TableFullScan_100 10000000.00 cop[tikv] table:part keep order:false + └─HashJoin_82(Probe) 300005811.00 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.lineitem.l_suppkey)] + ├─HashJoin_93(Build) 500000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] + │ ├─TableReader_97(Build) 25.00 root data:TableFullScan_96 + │ │ └─TableFullScan_96 25.00 cop[tikv] table:nation keep order:false + │ └─TableReader_95(Probe) 500000.00 root data:TableFullScan_94 + │ └─TableFullScan_94 500000.00 cop[tikv] table:supplier keep order:false + └─TableReader_99(Probe) 300005811.00 root data:TableFullScan_98 + └─TableFullScan_98 300005811.00 cop[tikv] table:lineitem keep order:false /* Q10 Returned Item Reporting Query The query identifies customers who might be having problems with the parts that are shipped to them. @@ -656,25 +656,25 @@ c_comment order by revenue desc limit 20; -id estRows task operator info -Projection_17 20.00 root tpch.customer.c_custkey, tpch.customer.c_name, Column#39, tpch.customer.c_acctbal, tpch.nation.n_name, tpch.customer.c_address, tpch.customer.c_phone, tpch.customer.c_comment -└─TopN_20 20.00 root Column#39:desc, offset:0, count:20 - └─HashAgg_26 3017307.69 root group by:Column#53, Column#54, Column#55, Column#56, Column#57, Column#58, Column#59, funcs:sum(Column#45)->Column#39, funcs:firstrow(Column#46)->tpch.customer.c_custkey, funcs:firstrow(Column#47)->tpch.customer.c_name, funcs:firstrow(Column#48)->tpch.customer.c_address, funcs:firstrow(Column#49)->tpch.customer.c_phone, funcs:firstrow(Column#50)->tpch.customer.c_acctbal, funcs:firstrow(Column#51)->tpch.customer.c_comment, funcs:firstrow(Column#52)->tpch.nation.n_name - └─Projection_67 12222016.17 root mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#45, tpch.customer.c_custkey, tpch.customer.c_name, tpch.customer.c_address, tpch.customer.c_phone, tpch.customer.c_acctbal, tpch.customer.c_comment, tpch.nation.n_name, tpch.customer.c_custkey, tpch.customer.c_name, tpch.customer.c_acctbal, tpch.customer.c_phone, tpch.nation.n_name, tpch.customer.c_address, tpch.customer.c_comment - └─IndexHashJoin_41 12222016.17 root inner join, inner:IndexLookUp_31, outer key:tpch.orders.o_orderkey, inner key:tpch.lineitem.l_orderkey - ├─HashLeftJoin_44(Build) 3017307.69 root inner join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] - │ ├─TableReader_63(Build) 3017307.69 root data:Selection_62 - │ │ └─Selection_62 3017307.69 cop[tikv] ge(tpch.orders.o_orderdate, 1993-08-01 00:00:00.000000), lt(tpch.orders.o_orderdate, 1993-11-01) - │ │ └─TableFullScan_61 75000000.00 cop[tikv] table:orders, keep order:false - │ └─HashRightJoin_56(Probe) 7500000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.customer.c_nationkey)] - │ ├─TableReader_60(Build) 25.00 root data:TableFullScan_59 - │ │ └─TableFullScan_59 25.00 cop[tikv] table:nation, keep order:false - │ └─TableReader_58(Probe) 7500000.00 root data:TableFullScan_57 - │ └─TableFullScan_57 7500000.00 cop[tikv] table:customer, keep order:false - └─IndexLookUp_31(Probe) 4.05 root - ├─IndexRangeScan_28(Build) 16.44 cop[tikv] table:lineitem, index:L_ORDERKEY, L_LINENUMBER, range: decided by [eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)], keep order:false - └─Selection_30(Probe) 4.05 cop[tikv] eq(tpch.lineitem.l_returnflag, "R") - └─TableRowIDScan_29 16.44 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Projection_17 20.00 root tpch.customer.c_custkey, tpch.customer.c_name, Column#39, tpch.customer.c_acctbal, tpch.nation.n_name, tpch.customer.c_address, tpch.customer.c_phone, tpch.customer.c_comment +└─TopN_20 20.00 root Column#39:desc, offset:0, count:20 + └─HashAgg_26 3017307.69 root group by:Column#53, Column#54, Column#55, Column#56, Column#57, Column#58, Column#59, funcs:sum(Column#45)->Column#39, funcs:firstrow(Column#46)->tpch.customer.c_custkey, funcs:firstrow(Column#47)->tpch.customer.c_name, funcs:firstrow(Column#48)->tpch.customer.c_address, funcs:firstrow(Column#49)->tpch.customer.c_phone, funcs:firstrow(Column#50)->tpch.customer.c_acctbal, funcs:firstrow(Column#51)->tpch.customer.c_comment, funcs:firstrow(Column#52)->tpch.nation.n_name + └─Projection_67 12222016.17 root mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#45, tpch.customer.c_custkey, tpch.customer.c_name, tpch.customer.c_address, tpch.customer.c_phone, tpch.customer.c_acctbal, tpch.customer.c_comment, tpch.nation.n_name, tpch.customer.c_custkey, tpch.customer.c_name, tpch.customer.c_acctbal, tpch.customer.c_phone, tpch.nation.n_name, tpch.customer.c_address, tpch.customer.c_comment + └─IndexHashJoin_41 12222016.17 root inner join, inner:IndexLookUp_31, outer key:tpch.orders.o_orderkey, inner key:tpch.lineitem.l_orderkey + ├─HashJoin_44(Build) 3017307.69 root inner join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] + │ ├─TableReader_63(Build) 3017307.69 root data:Selection_62 + │ │ └─Selection_62 3017307.69 cop[tikv] ge(tpch.orders.o_orderdate, 1993-08-01 00:00:00.000000), lt(tpch.orders.o_orderdate, 1993-11-01) + │ │ └─TableFullScan_61 75000000.00 cop[tikv] table:orders keep order:false + │ └─HashJoin_56(Probe) 7500000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.customer.c_nationkey)] + │ ├─TableReader_60(Build) 25.00 root data:TableFullScan_59 + │ │ └─TableFullScan_59 25.00 cop[tikv] table:nation keep order:false + │ └─TableReader_58(Probe) 7500000.00 root data:TableFullScan_57 + │ └─TableFullScan_57 7500000.00 cop[tikv] table:customer keep order:false + └─IndexLookUp_31(Probe) 4.05 root + ├─IndexRangeScan_28(Build) 16.44 cop[tikv] table:lineitem, index:PRIMARY(L_ORDERKEY, L_LINENUMBER) range: decided by [eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey)], keep order:false + └─Selection_30(Probe) 4.05 cop[tikv] eq(tpch.lineitem.l_returnflag, "R") + └─TableRowIDScan_29 16.44 cop[tikv] table:lineitem keep order:false /* Q11 Important Stock Identification Query This query finds the most important subset of suppliers' stock in a given nation. @@ -710,21 +710,21 @@ and n_name = 'MOZAMBIQUE' ) order by value desc; -id estRows task operator info -Projection_57 1304801.67 root tpch.partsupp.ps_partkey, Column#18 -└─Sort_58 1304801.67 root Column#18:desc - └─Selection_60 1304801.67 root gt(Column#18, NULL) - └─HashAgg_63 1631002.09 root group by:Column#44, funcs:sum(Column#42)->Column#18, funcs:firstrow(Column#43)->tpch.partsupp.ps_partkey - └─Projection_89 1631002.09 root mul(tpch.partsupp.ps_supplycost, cast(tpch.partsupp.ps_availqty, decimal(20,0) BINARY))->Column#42, tpch.partsupp.ps_partkey, tpch.partsupp.ps_partkey - └─HashRightJoin_67 1631002.09 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.partsupp.ps_suppkey)] - ├─HashRightJoin_80(Build) 20000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] - │ ├─TableReader_85(Build) 1.00 root data:Selection_84 - │ │ └─Selection_84 1.00 cop[tikv] eq(tpch.nation.n_name, "MOZAMBIQUE") - │ │ └─TableFullScan_83 25.00 cop[tikv] table:nation, keep order:false - │ └─TableReader_82(Probe) 500000.00 root data:TableFullScan_81 - │ └─TableFullScan_81 500000.00 cop[tikv] table:supplier, keep order:false - └─TableReader_87(Probe) 40000000.00 root data:TableFullScan_86 - └─TableFullScan_86 40000000.00 cop[tikv] table:partsupp, keep order:false +id estRows task access object operator info +Projection_57 1304801.67 root tpch.partsupp.ps_partkey, Column#18 +└─Sort_58 1304801.67 root Column#18:desc + └─Selection_60 1304801.67 root gt(Column#18, NULL) + └─HashAgg_63 1631002.09 root group by:Column#44, funcs:sum(Column#42)->Column#18, funcs:firstrow(Column#43)->tpch.partsupp.ps_partkey + └─Projection_89 1631002.09 root mul(tpch.partsupp.ps_supplycost, cast(tpch.partsupp.ps_availqty, decimal(20,0) BINARY))->Column#42, tpch.partsupp.ps_partkey, tpch.partsupp.ps_partkey + └─HashJoin_67 1631002.09 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.partsupp.ps_suppkey)] + ├─HashJoin_80(Build) 20000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] + │ ├─TableReader_85(Build) 1.00 root data:Selection_84 + │ │ └─Selection_84 1.00 cop[tikv] eq(tpch.nation.n_name, "MOZAMBIQUE") + │ │ └─TableFullScan_83 25.00 cop[tikv] table:nation keep order:false + │ └─TableReader_82(Probe) 500000.00 root data:TableFullScan_81 + │ └─TableFullScan_81 500000.00 cop[tikv] table:supplier keep order:false + └─TableReader_87(Probe) 40000000.00 root data:TableFullScan_86 + └─TableFullScan_86 40000000.00 cop[tikv] table:partsupp keep order:false /* Q12 Shipping Modes and Order Priority Query This query determines whether selecting less expensive modes of shipping is negatively affecting the critical-priority @@ -764,17 +764,17 @@ group by l_shipmode order by l_shipmode; -id estRows task operator info -Sort_9 1.00 root tpch.lineitem.l_shipmode:asc -└─Projection_11 1.00 root tpch.lineitem.l_shipmode, Column#27, Column#28 - └─HashAgg_14 1.00 root group by:Column#40, funcs:sum(Column#37)->Column#27, funcs:sum(Column#38)->Column#28, funcs:firstrow(Column#39)->tpch.lineitem.l_shipmode - └─Projection_54 10023369.01 root cast(case(or(eq(tpch.orders.o_orderpriority, 1-URGENT), eq(tpch.orders.o_orderpriority, 2-HIGH)), 1, 0), decimal(65,0) BINARY)->Column#37, cast(case(and(ne(tpch.orders.o_orderpriority, 1-URGENT), ne(tpch.orders.o_orderpriority, 2-HIGH)), 1, 0), decimal(65,0) BINARY)->Column#38, tpch.lineitem.l_shipmode, tpch.lineitem.l_shipmode - └─IndexMergeJoin_22 10023369.01 root inner join, inner:TableReader_20, outer key:tpch.lineitem.l_orderkey, inner key:tpch.orders.o_orderkey - ├─TableReader_50(Build) 10023369.01 root data:Selection_49 - │ └─Selection_49 10023369.01 cop[tikv] ge(tpch.lineitem.l_receiptdate, 1997-01-01 00:00:00.000000), in(tpch.lineitem.l_shipmode, "RAIL", "FOB"), lt(tpch.lineitem.l_commitdate, tpch.lineitem.l_receiptdate), lt(tpch.lineitem.l_receiptdate, 1998-01-01), lt(tpch.lineitem.l_shipdate, tpch.lineitem.l_commitdate) - │ └─TableFullScan_48 300005811.00 cop[tikv] table:lineitem, keep order:false - └─TableReader_20(Probe) 1.00 root data:TableRangeScan_19 - └─TableRangeScan_19 1.00 cop[tikv] table:orders, range: decided by [tpch.lineitem.l_orderkey], keep order:true +id estRows task access object operator info +Sort_9 1.00 root tpch.lineitem.l_shipmode:asc +└─Projection_11 1.00 root tpch.lineitem.l_shipmode, Column#27, Column#28 + └─HashAgg_14 1.00 root group by:Column#40, funcs:sum(Column#37)->Column#27, funcs:sum(Column#38)->Column#28, funcs:firstrow(Column#39)->tpch.lineitem.l_shipmode + └─Projection_54 10023369.01 root cast(case(or(eq(tpch.orders.o_orderpriority, 1-URGENT), eq(tpch.orders.o_orderpriority, 2-HIGH)), 1, 0), decimal(65,0) BINARY)->Column#37, cast(case(and(ne(tpch.orders.o_orderpriority, 1-URGENT), ne(tpch.orders.o_orderpriority, 2-HIGH)), 1, 0), decimal(65,0) BINARY)->Column#38, tpch.lineitem.l_shipmode, tpch.lineitem.l_shipmode + └─IndexMergeJoin_22 10023369.01 root inner join, inner:TableReader_20, outer key:tpch.lineitem.l_orderkey, inner key:tpch.orders.o_orderkey + ├─TableReader_50(Build) 10023369.01 root data:Selection_49 + │ └─Selection_49 10023369.01 cop[tikv] ge(tpch.lineitem.l_receiptdate, 1997-01-01 00:00:00.000000), in(tpch.lineitem.l_shipmode, "RAIL", "FOB"), lt(tpch.lineitem.l_commitdate, tpch.lineitem.l_receiptdate), lt(tpch.lineitem.l_receiptdate, 1998-01-01), lt(tpch.lineitem.l_shipdate, tpch.lineitem.l_commitdate) + │ └─TableFullScan_48 300005811.00 cop[tikv] table:lineitem keep order:false + └─TableReader_20(Probe) 1.00 root data:TableRangeScan_19 + └─TableRangeScan_19 1.00 cop[tikv] table:orders range: decided by [tpch.lineitem.l_orderkey], keep order:true /* Q13 Customer Distribution Query This query seeks relationships between customers and the size of their orders. @@ -804,17 +804,17 @@ c_count order by custdist desc, c_count desc; -id estRows task operator info -Sort_9 7500000.00 root Column#19:desc, Column#18:desc -└─Projection_11 7500000.00 root Column#18, Column#19 - └─HashAgg_14 7500000.00 root group by:Column#18, funcs:count(1)->Column#19, funcs:firstrow(Column#18)->Column#18 - └─HashAgg_17 7500000.00 root group by:tpch.customer.c_custkey, funcs:count(tpch.orders.o_orderkey)->Column#18 - └─HashLeftJoin_21 60000000.00 root left outer join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] - ├─TableReader_23(Build) 7500000.00 root data:TableFullScan_22 - │ └─TableFullScan_22 7500000.00 cop[tikv] table:customer, keep order:false - └─TableReader_26(Probe) 60000000.00 root data:Selection_25 - └─Selection_25 60000000.00 cop[tikv] not(like(tpch.orders.o_comment, "%pending%deposits%", 92)) - └─TableFullScan_24 75000000.00 cop[tikv] table:orders, keep order:false +id estRows task access object operator info +Sort_9 7500000.00 root Column#19:desc, Column#18:desc +└─Projection_11 7500000.00 root Column#18, Column#19 + └─HashAgg_14 7500000.00 root group by:Column#18, funcs:count(1)->Column#19, funcs:firstrow(Column#18)->Column#18 + └─HashAgg_17 7500000.00 root group by:tpch.customer.c_custkey, funcs:count(tpch.orders.o_orderkey)->Column#18 + └─HashJoin_21 60000000.00 root left outer join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] + ├─TableReader_23(Build) 7500000.00 root data:TableFullScan_22 + │ └─TableFullScan_22 7500000.00 cop[tikv] table:customer keep order:false + └─TableReader_26(Probe) 60000000.00 root data:Selection_25 + └─Selection_25 60000000.00 cop[tikv] not(like(tpch.orders.o_comment, "%pending%deposits%", 92)) + └─TableFullScan_24 75000000.00 cop[tikv] table:orders keep order:false /* Q14 Promotion Effect Query This query monitors the market response to a promotion such as TV advertisements or a special campaign. @@ -836,16 +836,16 @@ where l_partkey = p_partkey and l_shipdate >= '1996-12-01' and l_shipdate < date_add('1996-12-01', interval '1' month); -id estRows task operator info -Projection_8 1.00 root div(mul(100.00, Column#27), Column#28)->Column#29 -└─StreamAgg_13 1.00 root funcs:sum(Column#31)->Column#27, funcs:sum(Column#32)->Column#28 - └─Projection_41 4121984.49 root case(like(tpch.part.p_type, PROMO%, 92), mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)), 0)->Column#31, mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#32 - └─IndexMergeJoin_36 4121984.49 root inner join, inner:TableReader_34, outer key:tpch.lineitem.l_partkey, inner key:tpch.part.p_partkey - ├─TableReader_27(Build) 4121984.49 root data:Selection_26 - │ └─Selection_26 4121984.49 cop[tikv] ge(tpch.lineitem.l_shipdate, 1996-12-01 00:00:00.000000), lt(tpch.lineitem.l_shipdate, 1997-01-01) - │ └─TableFullScan_25 300005811.00 cop[tikv] table:lineitem, keep order:false - └─TableReader_34(Probe) 1.00 root data:TableRangeScan_33 - └─TableRangeScan_33 1.00 cop[tikv] table:part, range: decided by [tpch.lineitem.l_partkey], keep order:true +id estRows task access object operator info +Projection_8 1.00 root div(mul(100.00, Column#27), Column#28)->Column#29 +└─StreamAgg_13 1.00 root funcs:sum(Column#31)->Column#27, funcs:sum(Column#32)->Column#28 + └─Projection_41 4121984.49 root case(like(tpch.part.p_type, PROMO%, 92), mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)), 0)->Column#31, mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#32 + └─IndexMergeJoin_36 4121984.49 root inner join, inner:TableReader_34, outer key:tpch.lineitem.l_partkey, inner key:tpch.part.p_partkey + ├─TableReader_27(Build) 4121984.49 root data:Selection_26 + │ └─Selection_26 4121984.49 cop[tikv] ge(tpch.lineitem.l_shipdate, 1996-12-01 00:00:00.000000), lt(tpch.lineitem.l_shipdate, 1997-01-01) + │ └─TableFullScan_25 300005811.00 cop[tikv] table:lineitem keep order:false + └─TableReader_34(Probe) 1.00 root data:TableRangeScan_33 + └─TableRangeScan_33 1.00 cop[tikv] table:part range: decided by [tpch.lineitem.l_partkey], keep order:true /* Q15 Top Supplier Query This query determines the top supplier so it can be rewarded, given more business, or identified for special recognition. @@ -925,20 +925,20 @@ supplier_cnt desc, p_brand, p_type, p_size; -id estRows task operator info -Sort_13 14.41 root Column#23:desc, tpch.part.p_brand:asc, tpch.part.p_type:asc, tpch.part.p_size:asc -└─Projection_15 14.41 root tpch.part.p_brand, tpch.part.p_type, tpch.part.p_size, Column#23 - └─HashAgg_18 14.41 root group by:tpch.part.p_brand, tpch.part.p_size, tpch.part.p_type, funcs:count(distinct tpch.partsupp.ps_suppkey)->Column#23, funcs:firstrow(tpch.part.p_brand)->tpch.part.p_brand, funcs:firstrow(tpch.part.p_type)->tpch.part.p_type, funcs:firstrow(tpch.part.p_size)->tpch.part.p_size - └─HashLeftJoin_30 3863988.24 root anti semi join, equal:[eq(tpch.partsupp.ps_suppkey, tpch.supplier.s_suppkey)] - ├─TableReader_68(Build) 400000.00 root data:Selection_67 - │ └─Selection_67 400000.00 cop[tikv] like(tpch.supplier.s_comment, "%Customer%Complaints%", 92) - │ └─TableFullScan_66 500000.00 cop[tikv] table:supplier, keep order:false - └─IndexMergeJoin_38(Probe) 4829985.30 root inner join, inner:IndexReader_36, outer key:tpch.part.p_partkey, inner key:tpch.partsupp.ps_partkey - ├─TableReader_61(Build) 1200618.43 root data:Selection_60 - │ └─Selection_60 1200618.43 cop[tikv] in(tpch.part.p_size, 48, 19, 12, 4, 41, 7, 21, 39), ne(tpch.part.p_brand, "Brand#34"), not(like(tpch.part.p_type, "LARGE BRUSHED%", 92)) - │ └─TableFullScan_59 10000000.00 cop[tikv] table:part, keep order:false - └─IndexReader_36(Probe) 4.02 root index:IndexRangeScan_35 - └─IndexRangeScan_35 4.02 cop[tikv] table:partsupp, index:PS_PARTKEY, PS_SUPPKEY, range: decided by [eq(tpch.partsupp.ps_partkey, tpch.part.p_partkey)], keep order:true +id estRows task access object operator info +Sort_13 14.41 root Column#23:desc, tpch.part.p_brand:asc, tpch.part.p_type:asc, tpch.part.p_size:asc +└─Projection_15 14.41 root tpch.part.p_brand, tpch.part.p_type, tpch.part.p_size, Column#23 + └─HashAgg_18 14.41 root group by:tpch.part.p_brand, tpch.part.p_size, tpch.part.p_type, funcs:count(distinct tpch.partsupp.ps_suppkey)->Column#23, funcs:firstrow(tpch.part.p_brand)->tpch.part.p_brand, funcs:firstrow(tpch.part.p_type)->tpch.part.p_type, funcs:firstrow(tpch.part.p_size)->tpch.part.p_size + └─HashJoin_30 3863988.24 root anti semi join, equal:[eq(tpch.partsupp.ps_suppkey, tpch.supplier.s_suppkey)] + ├─TableReader_68(Build) 400000.00 root data:Selection_67 + │ └─Selection_67 400000.00 cop[tikv] like(tpch.supplier.s_comment, "%Customer%Complaints%", 92) + │ └─TableFullScan_66 500000.00 cop[tikv] table:supplier keep order:false + └─IndexMergeJoin_38(Probe) 4829985.30 root inner join, inner:IndexReader_36, outer key:tpch.part.p_partkey, inner key:tpch.partsupp.ps_partkey + ├─TableReader_61(Build) 1200618.43 root data:Selection_60 + │ └─Selection_60 1200618.43 cop[tikv] in(tpch.part.p_size, 48, 19, 12, 4, 41, 7, 21, 39), ne(tpch.part.p_brand, "Brand#34"), not(like(tpch.part.p_type, "LARGE BRUSHED%", 92)) + │ └─TableFullScan_59 10000000.00 cop[tikv] table:part keep order:false + └─IndexReader_36(Probe) 4.02 root index:IndexRangeScan_35 + └─IndexRangeScan_35 4.02 cop[tikv] table:partsupp, index:PRIMARY(PS_PARTKEY, PS_SUPPKEY) range: decided by [eq(tpch.partsupp.ps_partkey, tpch.part.p_partkey)], keep order:true /* Q17 Small-Quantity-Order Revenue Query This query determines how much average yearly revenue would be lost if orders were no longer filled for small @@ -967,20 +967,20 @@ lineitem where l_partkey = p_partkey ); -id estRows task operator info -Projection_16 1.00 root div(Column#46, 7.0)->Column#47 -└─StreamAgg_21 1.00 root funcs:sum(tpch.lineitem.l_extendedprice)->Column#46 - └─HashRightJoin_53 293773.83 root inner join, equal:[eq(tpch.part.p_partkey, tpch.lineitem.l_partkey)], other cond:lt(tpch.lineitem.l_quantity, mul(0.2, Column#44)) - ├─HashRightJoin_37(Build) 293773.83 root inner join, equal:[eq(tpch.part.p_partkey, tpch.lineitem.l_partkey)] - │ ├─TableReader_42(Build) 9736.49 root data:Selection_41 - │ │ └─Selection_41 9736.49 cop[tikv] eq(tpch.part.p_brand, "Brand#44"), eq(tpch.part.p_container, "WRAP PKG") - │ │ └─TableFullScan_40 10000000.00 cop[tikv] table:part, keep order:false - │ └─TableReader_39(Probe) 300005811.00 root data:TableFullScan_38 - │ └─TableFullScan_38 300005811.00 cop[tikv] table:lineitem, keep order:false - └─HashAgg_47(Probe) 9943040.00 root group by:tpch.lineitem.l_partkey, funcs:avg(Column#50, Column#51)->Column#44, funcs:firstrow(tpch.lineitem.l_partkey)->tpch.lineitem.l_partkey - └─TableReader_48 9943040.00 root data:HashAgg_43 - └─HashAgg_43 9943040.00 cop[tikv] group by:tpch.lineitem.l_partkey, funcs:count(tpch.lineitem.l_quantity)->Column#50, funcs:sum(tpch.lineitem.l_quantity)->Column#51 - └─TableFullScan_46 300005811.00 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Projection_16 1.00 root div(Column#46, 7.0)->Column#47 +└─StreamAgg_21 1.00 root funcs:sum(tpch.lineitem.l_extendedprice)->Column#46 + └─HashJoin_53 293773.83 root inner join, equal:[eq(tpch.part.p_partkey, tpch.lineitem.l_partkey)], other cond:lt(tpch.lineitem.l_quantity, mul(0.2, Column#44)) + ├─HashJoin_37(Build) 293773.83 root inner join, equal:[eq(tpch.part.p_partkey, tpch.lineitem.l_partkey)] + │ ├─TableReader_42(Build) 9736.49 root data:Selection_41 + │ │ └─Selection_41 9736.49 cop[tikv] eq(tpch.part.p_brand, "Brand#44"), eq(tpch.part.p_container, "WRAP PKG") + │ │ └─TableFullScan_40 10000000.00 cop[tikv] table:part keep order:false + │ └─TableReader_39(Probe) 300005811.00 root data:TableFullScan_38 + │ └─TableFullScan_38 300005811.00 cop[tikv] table:lineitem keep order:false + └─HashAgg_47(Probe) 9943040.00 root group by:tpch.lineitem.l_partkey, funcs:avg(Column#50, Column#51)->Column#44, funcs:firstrow(tpch.lineitem.l_partkey)->tpch.lineitem.l_partkey + └─TableReader_48 9943040.00 root data:HashAgg_43 + └─HashAgg_43 9943040.00 cop[tikv] group by:tpch.lineitem.l_partkey, funcs:count(tpch.lineitem.l_quantity)->Column#50, funcs:sum(tpch.lineitem.l_quantity)->Column#51 + └─TableFullScan_46 300005811.00 cop[tikv] table:lineitem keep order:false /* Q18 Large Volume Customer Query The Large Volume Customer Query ranks customers based on their having placed a large quantity order. Large @@ -1023,24 +1023,24 @@ order by o_totalprice desc, o_orderdate limit 100; -id estRows task operator info -Projection_24 100.00 root tpch.customer.c_name, tpch.customer.c_custkey, tpch.orders.o_orderkey, tpch.orders.o_orderdate, tpch.orders.o_totalprice, Column#54 -└─TopN_27 100.00 root tpch.orders.o_totalprice:desc, tpch.orders.o_orderdate:asc, offset:0, count:100 - └─HashAgg_33 59251097.60 root group by:tpch.customer.c_custkey, tpch.customer.c_name, tpch.orders.o_orderdate, tpch.orders.o_orderkey, tpch.orders.o_totalprice, funcs:sum(tpch.lineitem.l_quantity)->Column#54, funcs:firstrow(tpch.customer.c_custkey)->tpch.customer.c_custkey, funcs:firstrow(tpch.customer.c_name)->tpch.customer.c_name, funcs:firstrow(tpch.orders.o_orderkey)->tpch.orders.o_orderkey, funcs:firstrow(tpch.orders.o_totalprice)->tpch.orders.o_totalprice, funcs:firstrow(tpch.orders.o_orderdate)->tpch.orders.o_orderdate - └─HashRightJoin_48 240004648.80 root inner join, equal:[eq(tpch.orders.o_orderkey, tpch.lineitem.l_orderkey)] - ├─HashLeftJoin_72(Build) 59251097.60 root inner join, equal:[eq(tpch.orders.o_orderkey, tpch.lineitem.l_orderkey)] - │ ├─Selection_89(Build) 59251097.60 root gt(Column#52, 314) - │ │ └─HashAgg_96 74063872.00 root group by:tpch.lineitem.l_orderkey, funcs:sum(Column#66)->Column#52, funcs:firstrow(tpch.lineitem.l_orderkey)->tpch.lineitem.l_orderkey - │ │ └─TableReader_97 74063872.00 root data:HashAgg_90 - │ │ └─HashAgg_90 74063872.00 cop[tikv] group by:tpch.lineitem.l_orderkey, funcs:sum(tpch.lineitem.l_quantity)->Column#66 - │ │ └─TableFullScan_95 300005811.00 cop[tikv] table:lineitem, keep order:false - │ └─HashRightJoin_84(Probe) 75000000.00 root inner join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] - │ ├─TableReader_88(Build) 7500000.00 root data:TableFullScan_87 - │ │ └─TableFullScan_87 7500000.00 cop[tikv] table:customer, keep order:false - │ └─TableReader_86(Probe) 75000000.00 root data:TableFullScan_85 - │ └─TableFullScan_85 75000000.00 cop[tikv] table:orders, keep order:false - └─TableReader_101(Probe) 300005811.00 root data:TableFullScan_100 - └─TableFullScan_100 300005811.00 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Projection_24 100.00 root tpch.customer.c_name, tpch.customer.c_custkey, tpch.orders.o_orderkey, tpch.orders.o_orderdate, tpch.orders.o_totalprice, Column#54 +└─TopN_27 100.00 root tpch.orders.o_totalprice:desc, tpch.orders.o_orderdate:asc, offset:0, count:100 + └─HashAgg_33 59251097.60 root group by:tpch.customer.c_custkey, tpch.customer.c_name, tpch.orders.o_orderdate, tpch.orders.o_orderkey, tpch.orders.o_totalprice, funcs:sum(tpch.lineitem.l_quantity)->Column#54, funcs:firstrow(tpch.customer.c_custkey)->tpch.customer.c_custkey, funcs:firstrow(tpch.customer.c_name)->tpch.customer.c_name, funcs:firstrow(tpch.orders.o_orderkey)->tpch.orders.o_orderkey, funcs:firstrow(tpch.orders.o_totalprice)->tpch.orders.o_totalprice, funcs:firstrow(tpch.orders.o_orderdate)->tpch.orders.o_orderdate + └─HashJoin_48 240004648.80 root inner join, equal:[eq(tpch.orders.o_orderkey, tpch.lineitem.l_orderkey)] + ├─HashJoin_72(Build) 59251097.60 root inner join, equal:[eq(tpch.orders.o_orderkey, tpch.lineitem.l_orderkey)] + │ ├─Selection_89(Build) 59251097.60 root gt(Column#52, 314) + │ │ └─HashAgg_96 74063872.00 root group by:tpch.lineitem.l_orderkey, funcs:sum(Column#66)->Column#52, funcs:firstrow(tpch.lineitem.l_orderkey)->tpch.lineitem.l_orderkey + │ │ └─TableReader_97 74063872.00 root data:HashAgg_90 + │ │ └─HashAgg_90 74063872.00 cop[tikv] group by:tpch.lineitem.l_orderkey, funcs:sum(tpch.lineitem.l_quantity)->Column#66 + │ │ └─TableFullScan_95 300005811.00 cop[tikv] table:lineitem keep order:false + │ └─HashJoin_84(Probe) 75000000.00 root inner join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] + │ ├─TableReader_88(Build) 7500000.00 root data:TableFullScan_87 + │ │ └─TableFullScan_87 7500000.00 cop[tikv] table:customer keep order:false + │ └─TableReader_86(Probe) 75000000.00 root data:TableFullScan_85 + │ └─TableFullScan_85 75000000.00 cop[tikv] table:orders keep order:false + └─TableReader_101(Probe) 300005811.00 root data:TableFullScan_100 + └─TableFullScan_100 300005811.00 cop[tikv] table:lineitem keep order:false /* Q19 Discounted Revenue Query The Discounted Revenue Query reports the gross discounted revenue attributed to the sale of selected parts handled @@ -1086,16 +1086,16 @@ and p_size between 1 and 15 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ); -id estRows task operator info -StreamAgg_13 1.00 root funcs:sum(Column#28)->Column#27 -└─Projection_46 6286493.79 root mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#28 - └─IndexMergeJoin_41 6286493.79 root inner join, inner:TableReader_39, outer key:tpch.lineitem.l_partkey, inner key:tpch.part.p_partkey, other cond:or(and(and(eq(tpch.part.p_brand, "Brand#52"), in(tpch.part.p_container, "SM CASE", "SM BOX", "SM PACK", "SM PKG")), and(ge(tpch.lineitem.l_quantity, 4), and(le(tpch.lineitem.l_quantity, 14), le(tpch.part.p_size, 5)))), or(and(and(eq(tpch.part.p_brand, "Brand#11"), in(tpch.part.p_container, "MED BAG", "MED BOX", "MED PKG", "MED PACK")), and(ge(tpch.lineitem.l_quantity, 18), and(le(tpch.lineitem.l_quantity, 28), le(tpch.part.p_size, 10)))), and(and(eq(tpch.part.p_brand, "Brand#51"), in(tpch.part.p_container, "LG CASE", "LG BOX", "LG PACK", "LG PKG")), and(ge(tpch.lineitem.l_quantity, 29), and(le(tpch.lineitem.l_quantity, 39), le(tpch.part.p_size, 15)))))) - ├─TableReader_29(Build) 6286493.79 root data:Selection_28 - │ └─Selection_28 6286493.79 cop[tikv] eq(tpch.lineitem.l_shipinstruct, "DELIVER IN PERSON"), in(tpch.lineitem.l_shipmode, "AIR", "AIR REG"), or(and(ge(tpch.lineitem.l_quantity, 4), le(tpch.lineitem.l_quantity, 14)), or(and(ge(tpch.lineitem.l_quantity, 18), le(tpch.lineitem.l_quantity, 28)), and(ge(tpch.lineitem.l_quantity, 29), le(tpch.lineitem.l_quantity, 39)))) - │ └─TableFullScan_27 300005811.00 cop[tikv] table:lineitem, keep order:false - └─TableReader_39(Probe) 0.80 root data:Selection_38 - └─Selection_38 0.80 cop[tikv] ge(tpch.part.p_size, 1), or(and(eq(tpch.part.p_brand, "Brand#52"), and(in(tpch.part.p_container, "SM CASE", "SM BOX", "SM PACK", "SM PKG"), le(tpch.part.p_size, 5))), or(and(eq(tpch.part.p_brand, "Brand#11"), and(in(tpch.part.p_container, "MED BAG", "MED BOX", "MED PKG", "MED PACK"), le(tpch.part.p_size, 10))), and(eq(tpch.part.p_brand, "Brand#51"), and(in(tpch.part.p_container, "LG CASE", "LG BOX", "LG PACK", "LG PKG"), le(tpch.part.p_size, 15))))) - └─TableRangeScan_37 1.00 cop[tikv] table:part, range: decided by [tpch.lineitem.l_partkey], keep order:true +id estRows task access object operator info +StreamAgg_13 1.00 root funcs:sum(Column#28)->Column#27 +└─Projection_46 6286493.79 root mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))->Column#28 + └─IndexMergeJoin_41 6286493.79 root inner join, inner:TableReader_39, outer key:tpch.lineitem.l_partkey, inner key:tpch.part.p_partkey, other cond:or(and(and(eq(tpch.part.p_brand, "Brand#52"), in(tpch.part.p_container, "SM CASE", "SM BOX", "SM PACK", "SM PKG")), and(ge(tpch.lineitem.l_quantity, 4), and(le(tpch.lineitem.l_quantity, 14), le(tpch.part.p_size, 5)))), or(and(and(eq(tpch.part.p_brand, "Brand#11"), in(tpch.part.p_container, "MED BAG", "MED BOX", "MED PKG", "MED PACK")), and(ge(tpch.lineitem.l_quantity, 18), and(le(tpch.lineitem.l_quantity, 28), le(tpch.part.p_size, 10)))), and(and(eq(tpch.part.p_brand, "Brand#51"), in(tpch.part.p_container, "LG CASE", "LG BOX", "LG PACK", "LG PKG")), and(ge(tpch.lineitem.l_quantity, 29), and(le(tpch.lineitem.l_quantity, 39), le(tpch.part.p_size, 15)))))) + ├─TableReader_29(Build) 6286493.79 root data:Selection_28 + │ └─Selection_28 6286493.79 cop[tikv] eq(tpch.lineitem.l_shipinstruct, "DELIVER IN PERSON"), in(tpch.lineitem.l_shipmode, "AIR", "AIR REG"), or(and(ge(tpch.lineitem.l_quantity, 4), le(tpch.lineitem.l_quantity, 14)), or(and(ge(tpch.lineitem.l_quantity, 18), le(tpch.lineitem.l_quantity, 28)), and(ge(tpch.lineitem.l_quantity, 29), le(tpch.lineitem.l_quantity, 39)))) + │ └─TableFullScan_27 300005811.00 cop[tikv] table:lineitem keep order:false + └─TableReader_39(Probe) 0.80 root data:Selection_38 + └─Selection_38 0.80 cop[tikv] ge(tpch.part.p_size, 1), or(and(eq(tpch.part.p_brand, "Brand#52"), and(in(tpch.part.p_container, "SM CASE", "SM BOX", "SM PACK", "SM PKG"), le(tpch.part.p_size, 5))), or(and(eq(tpch.part.p_brand, "Brand#11"), and(in(tpch.part.p_container, "MED BAG", "MED BOX", "MED PKG", "MED PACK"), le(tpch.part.p_size, 10))), and(eq(tpch.part.p_brand, "Brand#51"), and(in(tpch.part.p_container, "LG CASE", "LG BOX", "LG PACK", "LG PKG"), le(tpch.part.p_size, 15))))) + └─TableRangeScan_37 1.00 cop[tikv] table:part range: decided by [tpch.lineitem.l_partkey], keep order:true /* Q20 Potential Part Promotion Query The Potential Part Promotion Query identifies suppliers in a particular nation having selected parts that may be candidates @@ -1142,30 +1142,30 @@ and s_nationkey = n_nationkey and n_name = 'ALGERIA' order by s_name; -id estRows task operator info -Sort_28 20000.00 root tpch.supplier.s_name:asc -└─HashRightJoin_32 20000.00 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.partsupp.ps_suppkey)] - ├─HashRightJoin_45(Build) 20000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] - │ ├─TableReader_50(Build) 1.00 root data:Selection_49 - │ │ └─Selection_49 1.00 cop[tikv] eq(tpch.nation.n_name, "ALGERIA") - │ │ └─TableFullScan_48 25.00 cop[tikv] table:nation, keep order:false - │ └─TableReader_47(Probe) 500000.00 root data:TableFullScan_46 - │ └─TableFullScan_46 500000.00 cop[tikv] table:supplier, keep order:false - └─HashAgg_53(Probe) 257492.04 root group by:tpch.partsupp.ps_suppkey, funcs:firstrow(tpch.partsupp.ps_suppkey)->tpch.partsupp.ps_suppkey - └─Projection_54 257492.04 root tpch.partsupp.ps_suppkey - └─Selection_55 257492.04 root gt(cast(tpch.partsupp.ps_availqty), mul(0.5, Column#44)) - └─HashAgg_58 321865.05 root group by:tpch.partsupp.ps_partkey, tpch.partsupp.ps_suppkey, funcs:firstrow(tpch.partsupp.ps_suppkey)->tpch.partsupp.ps_suppkey, funcs:firstrow(tpch.partsupp.ps_availqty)->tpch.partsupp.ps_availqty, funcs:sum(tpch.lineitem.l_quantity)->Column#44 - └─HashLeftJoin_62 9711455.06 root left outer join, equal:[eq(tpch.partsupp.ps_partkey, tpch.lineitem.l_partkey) eq(tpch.partsupp.ps_suppkey, tpch.lineitem.l_suppkey)] - ├─IndexHashJoin_75(Build) 321865.05 root inner join, inner:IndexLookUp_66, outer key:tpch.part.p_partkey, inner key:tpch.partsupp.ps_partkey - │ ├─TableReader_98(Build) 80007.93 root data:Selection_97 - │ │ └─Selection_97 80007.93 cop[tikv] like(tpch.part.p_name, "green%", 92) - │ │ └─TableFullScan_96 10000000.00 cop[tikv] table:part, keep order:false - │ └─IndexLookUp_66(Probe) 4.02 root - │ ├─IndexRangeScan_64(Build) 4.02 cop[tikv] table:partsupp, index:PS_PARTKEY, PS_SUPPKEY, range: decided by [eq(tpch.partsupp.ps_partkey, tpch.part.p_partkey)], keep order:false - │ └─TableRowIDScan_65(Probe) 4.02 cop[tikv] table:partsupp, keep order:false - └─TableReader_103(Probe) 44189356.65 root data:Selection_102 - └─Selection_102 44189356.65 cop[tikv] ge(tpch.lineitem.l_shipdate, 1993-01-01 00:00:00.000000), lt(tpch.lineitem.l_shipdate, 1994-01-01) - └─TableFullScan_101 300005811.00 cop[tikv] table:lineitem, keep order:false +id estRows task access object operator info +Sort_28 20000.00 root tpch.supplier.s_name:asc +└─HashJoin_32 20000.00 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.partsupp.ps_suppkey)] + ├─HashJoin_45(Build) 20000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] + │ ├─TableReader_50(Build) 1.00 root data:Selection_49 + │ │ └─Selection_49 1.00 cop[tikv] eq(tpch.nation.n_name, "ALGERIA") + │ │ └─TableFullScan_48 25.00 cop[tikv] table:nation keep order:false + │ └─TableReader_47(Probe) 500000.00 root data:TableFullScan_46 + │ └─TableFullScan_46 500000.00 cop[tikv] table:supplier keep order:false + └─HashAgg_53(Probe) 257492.04 root group by:tpch.partsupp.ps_suppkey, funcs:firstrow(tpch.partsupp.ps_suppkey)->tpch.partsupp.ps_suppkey + └─Projection_54 257492.04 root tpch.partsupp.ps_suppkey + └─Selection_55 257492.04 root gt(cast(tpch.partsupp.ps_availqty), mul(0.5, Column#44)) + └─HashAgg_58 321865.05 root group by:tpch.partsupp.ps_partkey, tpch.partsupp.ps_suppkey, funcs:firstrow(tpch.partsupp.ps_suppkey)->tpch.partsupp.ps_suppkey, funcs:firstrow(tpch.partsupp.ps_availqty)->tpch.partsupp.ps_availqty, funcs:sum(tpch.lineitem.l_quantity)->Column#44 + └─HashJoin_62 9711455.06 root left outer join, equal:[eq(tpch.partsupp.ps_partkey, tpch.lineitem.l_partkey) eq(tpch.partsupp.ps_suppkey, tpch.lineitem.l_suppkey)] + ├─IndexHashJoin_75(Build) 321865.05 root inner join, inner:IndexLookUp_66, outer key:tpch.part.p_partkey, inner key:tpch.partsupp.ps_partkey + │ ├─TableReader_98(Build) 80007.93 root data:Selection_97 + │ │ └─Selection_97 80007.93 cop[tikv] like(tpch.part.p_name, "green%", 92) + │ │ └─TableFullScan_96 10000000.00 cop[tikv] table:part keep order:false + │ └─IndexLookUp_66(Probe) 4.02 root + │ ├─IndexRangeScan_64(Build) 4.02 cop[tikv] table:partsupp, index:PRIMARY(PS_PARTKEY, PS_SUPPKEY) range: decided by [eq(tpch.partsupp.ps_partkey, tpch.part.p_partkey)], keep order:false + │ └─TableRowIDScan_65(Probe) 4.02 cop[tikv] table:partsupp keep order:false + └─TableReader_103(Probe) 44189356.65 root data:Selection_102 + └─Selection_102 44189356.65 cop[tikv] ge(tpch.lineitem.l_shipdate, 1993-01-01 00:00:00.000000), lt(tpch.lineitem.l_shipdate, 1994-01-01) + └─TableFullScan_101 300005811.00 cop[tikv] table:lineitem keep order:false /* Q21 Suppliers Who Kept Orders Waiting Query This query identifies certain suppliers who were not able to ship required parts in a timely manner. @@ -1214,33 +1214,33 @@ order by numwait desc, s_name limit 100; -id estRows task operator info -Projection_25 100.00 root tpch.supplier.s_name, Column#72 -└─TopN_28 100.00 root Column#72:desc, tpch.supplier.s_name:asc, offset:0, count:100 - └─HashAgg_34 12800.00 root group by:tpch.supplier.s_name, funcs:count(1)->Column#72, funcs:firstrow(tpch.supplier.s_name)->tpch.supplier.s_name - └─IndexHashJoin_49 7828961.66 root anti semi join, inner:IndexLookUp_39, outer key:tpch.lineitem.l_orderkey, inner key:tpch.lineitem.l_orderkey, other cond:ne(tpch.lineitem.l_suppkey, tpch.lineitem.l_suppkey) - ├─IndexHashJoin_88(Build) 9786202.08 root semi join, inner:IndexLookUp_79, outer key:tpch.lineitem.l_orderkey, inner key:tpch.lineitem.l_orderkey, other cond:ne(tpch.lineitem.l_suppkey, tpch.lineitem.l_suppkey), ne(tpch.lineitem.l_suppkey, tpch.supplier.s_suppkey) - │ ├─IndexMergeJoin_99(Build) 12232752.60 root inner join, inner:TableReader_97, outer key:tpch.lineitem.l_orderkey, inner key:tpch.orders.o_orderkey - │ │ ├─HashRightJoin_105(Build) 12232752.60 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.lineitem.l_suppkey)] - │ │ │ ├─HashRightJoin_118(Build) 20000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] - │ │ │ │ ├─TableReader_123(Build) 1.00 root data:Selection_122 - │ │ │ │ │ └─Selection_122 1.00 cop[tikv] eq(tpch.nation.n_name, "EGYPT") - │ │ │ │ │ └─TableFullScan_121 25.00 cop[tikv] table:nation, keep order:false - │ │ │ │ └─TableReader_120(Probe) 500000.00 root data:TableFullScan_119 - │ │ │ │ └─TableFullScan_119 500000.00 cop[tikv] table:supplier, keep order:false - │ │ │ └─TableReader_126(Probe) 240004648.80 root data:Selection_125 - │ │ │ └─Selection_125 240004648.80 cop[tikv] gt(tpch.lineitem.l_receiptdate, tpch.lineitem.l_commitdate) - │ │ │ └─TableFullScan_124 300005811.00 cop[tikv] table:l1, keep order:false - │ │ └─TableReader_97(Probe) 0.49 root data:Selection_96 - │ │ └─Selection_96 0.49 cop[tikv] eq(tpch.orders.o_orderstatus, "F") - │ │ └─TableRangeScan_95 1.00 cop[tikv] table:orders, range: decided by [tpch.lineitem.l_orderkey], keep order:true - │ └─IndexLookUp_79(Probe) 4.05 root - │ ├─IndexRangeScan_77(Build) 4.05 cop[tikv] table:l2, index:L_ORDERKEY, L_LINENUMBER, range: decided by [eq(tpch.lineitem.l_orderkey, tpch.lineitem.l_orderkey)], keep order:false - │ └─TableRowIDScan_78(Probe) 4.05 cop[tikv] table:l2, keep order:false - └─IndexLookUp_39(Probe) 4.05 root - ├─IndexRangeScan_36(Build) 5.06 cop[tikv] table:l3, index:L_ORDERKEY, L_LINENUMBER, range: decided by [eq(tpch.lineitem.l_orderkey, tpch.lineitem.l_orderkey)], keep order:false - └─Selection_38(Probe) 4.05 cop[tikv] gt(tpch.lineitem.l_receiptdate, tpch.lineitem.l_commitdate) - └─TableRowIDScan_37 5.06 cop[tikv] table:l3, keep order:false +id estRows task access object operator info +Projection_25 100.00 root tpch.supplier.s_name, Column#72 +└─TopN_28 100.00 root Column#72:desc, tpch.supplier.s_name:asc, offset:0, count:100 + └─HashAgg_34 12800.00 root group by:tpch.supplier.s_name, funcs:count(1)->Column#72, funcs:firstrow(tpch.supplier.s_name)->tpch.supplier.s_name + └─IndexHashJoin_49 7828961.66 root anti semi join, inner:IndexLookUp_39, outer key:tpch.lineitem.l_orderkey, inner key:tpch.lineitem.l_orderkey, other cond:ne(tpch.lineitem.l_suppkey, tpch.lineitem.l_suppkey) + ├─IndexHashJoin_88(Build) 9786202.08 root semi join, inner:IndexLookUp_79, outer key:tpch.lineitem.l_orderkey, inner key:tpch.lineitem.l_orderkey, other cond:ne(tpch.lineitem.l_suppkey, tpch.lineitem.l_suppkey), ne(tpch.lineitem.l_suppkey, tpch.supplier.s_suppkey) + │ ├─IndexMergeJoin_99(Build) 12232752.60 root inner join, inner:TableReader_97, outer key:tpch.lineitem.l_orderkey, inner key:tpch.orders.o_orderkey + │ │ ├─HashJoin_105(Build) 12232752.60 root inner join, equal:[eq(tpch.supplier.s_suppkey, tpch.lineitem.l_suppkey)] + │ │ │ ├─HashJoin_118(Build) 20000.00 root inner join, equal:[eq(tpch.nation.n_nationkey, tpch.supplier.s_nationkey)] + │ │ │ │ ├─TableReader_123(Build) 1.00 root data:Selection_122 + │ │ │ │ │ └─Selection_122 1.00 cop[tikv] eq(tpch.nation.n_name, "EGYPT") + │ │ │ │ │ └─TableFullScan_121 25.00 cop[tikv] table:nation keep order:false + │ │ │ │ └─TableReader_120(Probe) 500000.00 root data:TableFullScan_119 + │ │ │ │ └─TableFullScan_119 500000.00 cop[tikv] table:supplier keep order:false + │ │ │ └─TableReader_126(Probe) 240004648.80 root data:Selection_125 + │ │ │ └─Selection_125 240004648.80 cop[tikv] gt(tpch.lineitem.l_receiptdate, tpch.lineitem.l_commitdate) + │ │ │ └─TableFullScan_124 300005811.00 cop[tikv] table:l1 keep order:false + │ │ └─TableReader_97(Probe) 0.49 root data:Selection_96 + │ │ └─Selection_96 0.49 cop[tikv] eq(tpch.orders.o_orderstatus, "F") + │ │ └─TableRangeScan_95 1.00 cop[tikv] table:orders range: decided by [tpch.lineitem.l_orderkey], keep order:true + │ └─IndexLookUp_79(Probe) 4.05 root + │ ├─IndexRangeScan_77(Build) 4.05 cop[tikv] table:l2, index:PRIMARY(L_ORDERKEY, L_LINENUMBER) range: decided by [eq(tpch.lineitem.l_orderkey, tpch.lineitem.l_orderkey)], keep order:false + │ └─TableRowIDScan_78(Probe) 4.05 cop[tikv] table:l2 keep order:false + └─IndexLookUp_39(Probe) 4.05 root + ├─IndexRangeScan_36(Build) 5.06 cop[tikv] table:l3, index:PRIMARY(L_ORDERKEY, L_LINENUMBER) range: decided by [eq(tpch.lineitem.l_orderkey, tpch.lineitem.l_orderkey)], keep order:false + └─Selection_38(Probe) 4.05 cop[tikv] gt(tpch.lineitem.l_receiptdate, tpch.lineitem.l_commitdate) + └─TableRowIDScan_37 5.06 cop[tikv] table:l3 keep order:false /* Q22 Global Sales Opportunity Query The Global Sales Opportunity Query identifies geographies where there are customers who may be likely to make a @@ -1287,15 +1287,15 @@ group by cntrycode order by cntrycode; -id estRows task operator info -Sort_39 1.00 root Column#27:asc -└─Projection_41 1.00 root Column#27, Column#28, Column#29 - └─HashAgg_44 1.00 root group by:Column#27, funcs:count(1)->Column#28, funcs:sum(tpch.customer.c_acctbal)->Column#29, funcs:firstrow(Column#27)->Column#27 - └─Projection_45 0.00 root substring(tpch.customer.c_phone, 1, 2)->Column#27, tpch.customer.c_acctbal - └─HashLeftJoin_46 0.00 root anti semi join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] - ├─TableReader_52(Build) 75000000.00 root data:TableFullScan_51 - │ └─TableFullScan_51 75000000.00 cop[tikv] table:orders, keep order:false - └─Selection_50(Probe) 0.00 root in(substring(tpch.customer.c_phone, 1, 2), "20", "40", "22", "30", "39", "42", "21") - └─TableReader_49 0.00 root data:Selection_48 - └─Selection_48 0.00 cop[tikv] gt(tpch.customer.c_acctbal, NULL) - └─TableFullScan_47 7500000.00 cop[tikv] table:customer, keep order:false +id estRows task access object operator info +Sort_39 1.00 root Column#27:asc +└─Projection_41 1.00 root Column#27, Column#28, Column#29 + └─HashAgg_44 1.00 root group by:Column#27, funcs:count(1)->Column#28, funcs:sum(tpch.customer.c_acctbal)->Column#29, funcs:firstrow(Column#27)->Column#27 + └─Projection_45 0.00 root substring(tpch.customer.c_phone, 1, 2)->Column#27, tpch.customer.c_acctbal + └─HashJoin_46 0.00 root anti semi join, equal:[eq(tpch.customer.c_custkey, tpch.orders.o_custkey)] + ├─TableReader_52(Build) 75000000.00 root data:TableFullScan_51 + │ └─TableFullScan_51 75000000.00 cop[tikv] table:orders keep order:false + └─Selection_50(Probe) 0.00 root in(substring(tpch.customer.c_phone, 1, 2), "20", "40", "22", "30", "39", "42", "21") + └─TableReader_49 0.00 root data:Selection_48 + └─Selection_48 0.00 cop[tikv] gt(tpch.customer.c_acctbal, NULL) + └─TableFullScan_47 7500000.00 cop[tikv] table:customer keep order:false diff --git a/cmd/explaintest/r/window_function.result b/cmd/explaintest/r/window_function.result index 8bc79153fe0af..79727f4fb0c9a 100644 --- a/cmd/explaintest/r/window_function.result +++ b/cmd/explaintest/r/window_function.result @@ -4,123 +4,123 @@ create table t (a int, b int, c timestamp, index idx(a)); set @@tidb_enable_window_function = 1; set @@session.tidb_window_concurrency = 1; explain select sum(a) over() from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over() - └─IndexReader_12 10000.00 root index:IndexFullScan_11 - └─IndexFullScan_11 10000.00 cop[tikv] table:t, index:a, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over() + └─IndexReader_12 10000.00 root index:IndexFullScan_11 + └─IndexFullScan_11 10000.00 cop[tikv] table:t, index:idx(a) keep order:false, stats:pseudo explain select sum(a) over(partition by a) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a) - └─IndexReader_10 10000.00 root index:IndexFullScan_9 - └─IndexFullScan_9 10000.00 cop[tikv] table:t, index:a, keep order:true, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a) + └─IndexReader_10 10000.00 root index:IndexFullScan_9 + └─IndexFullScan_9 10000.00 cop[tikv] table:t, index:idx(a) keep order:true, stats:pseudo explain select sum(a) over(partition by a order by b) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc range between unbounded preceding and current row) - └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc range between unbounded preceding and current row) + └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select sum(a) over(partition by a order by b rows unbounded preceding) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc rows between unbounded preceding and current row) - └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc rows between unbounded preceding and current row) + └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select sum(a) over(partition by a order by b rows between 1 preceding and 1 following) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc rows between 1 preceding and 1 following) - └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc rows between 1 preceding and 1 following) + └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select sum(a) over(partition by a order by b range between 1 preceding and 1 following) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc range between 1 preceding and 1 following) - └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc range between 1 preceding and 1 following) + └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select sum(a) over(partition by a order by c range between interval '2:30' minute_second preceding and interval '2:30' minute_second following) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.c asc range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following) - └─Sort_11 10000.00 root test.t.a:asc, test.t.c:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.c asc range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following) + └─Sort_11 10000.00 root test.t.a:asc, test.t.c:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo set @@session.tidb_window_concurrency = 4; explain select sum(a) over() from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over() - └─IndexReader_12 10000.00 root index:IndexFullScan_11 - └─IndexFullScan_11 10000.00 cop[tikv] table:t, index:a, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over() + └─IndexReader_12 10000.00 root index:IndexFullScan_11 + └─IndexFullScan_11 10000.00 cop[tikv] table:t, index:idx(a) keep order:false, stats:pseudo explain select sum(a) over(partition by a) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a) - └─IndexReader_10 10000.00 root index:IndexFullScan_9 - └─IndexFullScan_9 10000.00 cop[tikv] table:t, index:a, keep order:true, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a) + └─IndexReader_10 10000.00 root index:IndexFullScan_9 + └─IndexFullScan_9 10000.00 cop[tikv] table:t, index:idx(a) keep order:true, stats:pseudo explain select sum(a) over(partition by a order by b) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 - └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc range between unbounded preceding and current row) - └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 + └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc range between unbounded preceding and current row) + └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select sum(a) over(partition by a order by b rows unbounded preceding) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 - └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc rows between unbounded preceding and current row) - └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 + └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc rows between unbounded preceding and current row) + └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select sum(a) over(partition by a order by b rows between 1 preceding and 1 following) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 - └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc rows between 1 preceding and 1 following) - └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 + └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc rows between 1 preceding and 1 following) + └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select sum(a) over(partition by a order by b range between 1 preceding and 1 following) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 - └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc range between 1 preceding and 1 following) - └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 + └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b asc range between 1 preceding and 1 following) + └─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain select sum(a) over(partition by a order by c range between interval '2:30' minute_second preceding and interval '2:30' minute_second following) from t; -id estRows task operator info -Projection_7 10000.00 root Column#6 -└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 - └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.c asc range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following) - └─Sort_11 10000.00 root test.t.a:asc, test.t.c:asc - └─TableReader_10 10000.00 root data:TableFullScan_9 - └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo +id estRows task access object operator info +Projection_7 10000.00 root Column#6 +└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10 + └─Window_8 10000.00 root sum(cast(test.t.a, decimal(65,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.c asc range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following) + └─Sort_11 10000.00 root test.t.a:asc, test.t.c:asc + └─TableReader_10 10000.00 root data:TableFullScan_9 + └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo drop table if exists t1; create table t1(a int primary key, b int); insert into t1 values(1, 1), (2, 1); analyze table t1; explain select sum(a) over(partition by b) from t1; -id estRows task operator info -Projection_7 2.00 root Column#4 -└─Window_8 2.00 root sum(cast(test.t1.a, decimal(65,0) BINARY))->Column#4 over(partition by test.t1.b) - └─Sort_11 2.00 root test.t1.b:asc - └─TableReader_10 2.00 root data:TableFullScan_9 - └─TableFullScan_9 2.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +Projection_7 2.00 root Column#4 +└─Window_8 2.00 root sum(cast(test.t1.a, decimal(65,0) BINARY))->Column#4 over(partition by test.t1.b) + └─Sort_11 2.00 root test.t1.b:asc + └─TableReader_10 2.00 root data:TableFullScan_9 + └─TableFullScan_9 2.00 cop[tikv] table:t1 keep order:false insert into t1 values(3, 3); analyze table t1; explain select sum(a) over(partition by b) from t1; -id estRows task operator info -Projection_7 3.00 root Column#4 -└─Shuffle_12 3.00 root execution info: concurrency:2, data source:TableReader_10 - └─Window_8 3.00 root sum(cast(test.t1.a, decimal(65,0) BINARY))->Column#4 over(partition by test.t1.b) - └─Sort_11 3.00 root test.t1.b:asc - └─TableReader_10 3.00 root data:TableFullScan_9 - └─TableFullScan_9 3.00 cop[tikv] table:t1, keep order:false +id estRows task access object operator info +Projection_7 3.00 root Column#4 +└─Shuffle_12 3.00 root execution info: concurrency:2, data source:TableReader_10 + └─Window_8 3.00 root sum(cast(test.t1.a, decimal(65,0) BINARY))->Column#4 over(partition by test.t1.b) + └─Sort_11 3.00 root test.t1.b:asc + └─TableReader_10 3.00 root data:TableFullScan_9 + └─TableFullScan_9 3.00 cop[tikv] table:t1 keep order:false diff --git a/cmd/explaintest/t/generated_columns.test b/cmd/explaintest/t/generated_columns.test index 0c47ddb796bd7..7ee7ee7090ad7 100644 --- a/cmd/explaintest/t/generated_columns.test +++ b/cmd/explaintest/t/generated_columns.test @@ -128,3 +128,12 @@ EXPLAIN SELECT sum(b) FROM t1 GROUP BY a; EXPLAIN SELECT sum(b) FROM t1 GROUP BY c; EXPLAIN SELECT sum(c) FROM t1 GROUP BY a; EXPLAIN SELECT sum(c) FROM t1 GROUP BY b; + +-- Virtual generated column for point get and batch point get +DROP TABLE IF EXISTS tu; +CREATE TABLE tu (a INT, b INT, c INT GENERATED ALWAYS AS (a + b) VIRTUAL, primary key (a), unique key uk(c)); +INSERT INTO tu(a, b) VALUES(1, 2); +EXPLAIN SELECT * FROM tu WHERE c = 1; +EXPLAIN SELECT a, c FROM tu WHERE c = 1; +EXPLAIN SELECT * FROM tu WHERE c in(1, 2, 3); +EXPLAIN SELECT c, a FROM tu WHERE c in(1, 2, 3); diff --git a/config/config.go b/config/config.go index dde68bb12945d..cce5a209a1f6b 100644 --- a/config/config.go +++ b/config/config.go @@ -473,6 +473,8 @@ type PessimisticTxn struct { type StmtSummary struct { // Enable statement summary or not. Enable bool `toml:"enable" json:"enable"` + // Enable summary internal query. + EnableInternalQuery bool `toml:"enable-internal-query" json:"enable-internal-query"` // The maximum number of statements kept in memory. MaxStmtCount uint `toml:"max-stmt-count" json:"max-stmt-count"` // The maximum length of displayed normalized SQL and sample SQL. @@ -494,6 +496,8 @@ type IsolationRead struct { type Experimental struct { // Whether enable the syntax like `auto_random(3)` on the primary key column. AllowAutoRandom bool `toml:"allow-auto-random" json:"allow-auto-random"` + // Whether enable creating expression index. + AllowsExpressionIndex bool `toml:"allow-expression-index" json:"allow-expression-index"` } var defaultConf = Config{ @@ -622,17 +626,19 @@ var defaultConf = Config{ MaxRetryCount: 256, }, StmtSummary: StmtSummary{ - Enable: true, - MaxStmtCount: 200, - MaxSQLLength: 4096, - RefreshInterval: 1800, - HistorySize: 24, + Enable: true, + EnableInternalQuery: false, + MaxStmtCount: 200, + MaxSQLLength: 4096, + RefreshInterval: 1800, + HistorySize: 24, }, IsolationRead: IsolationRead{ Engines: []string{"tikv", "tiflash", "tidb"}, }, Experimental: Experimental{ - AllowAutoRandom: false, + AllowAutoRandom: false, + AllowsExpressionIndex: false, }, EnableDynamicConfig: true, } diff --git a/config/config.toml.example b/config/config.toml.example index 6296d0adc75e6..24a5c0aadc329 100644 --- a/config/config.toml.example +++ b/config/config.toml.example @@ -82,8 +82,8 @@ split-region-max-num = 1000 enable-dynamic-config = true # alter-primary-key is used to control alter primary key feature. Default is false, indicate the alter primary key feature is disabled. -# If it is true, we can add the primary key by "alter table", but we may not be able to drop the primary key. -# In order to support "drop primary key" operation , this flag must be true and the table does not have the pkIsHandle flag. +# If it is true, we can add the primary key by "alter table". However, if a table already exists before the switch is turned true and the data type of its primary key column is an integer, +# the primary key cannot be dropped. alter-primary-key = false # server-version is used to change the version string of TiDB in the following scenarios: @@ -371,6 +371,8 @@ max-retry-count = 256 [stmt-summary] # enable statement summary. enable = true +# enable statement summary for TiDB internal query, default is false. +enable-internal-query = false # max number of statements kept in memory. max-stmt-count = 200 @@ -389,6 +391,8 @@ history-size = 24 [experimental] # enable column attribute `auto_random` to be defined on the primary key column. allow-auto-random = false +# enable creating expression index. +allow-expression-index = false # server level isolation read by engines and labels [isolation-read] diff --git a/config/config_handler.go b/config/config_handler.go index e44eee07b4e01..f93bb771e9cb1 100644 --- a/config/config_handler.go +++ b/config/config_handler.go @@ -190,7 +190,7 @@ func (ch *pdConfHandler) writeConfig() { } } -func (ch *pdConfHandler) updateConfig(newConfContent string, newVersion *configpb.Version) (ok bool) { +func (ch *pdConfHandler) updateConfig(newConfContent string, newVersion *configpb.Version) (updated bool) { newConf, err := decodeConfig(newConfContent) if err != nil { logutil.Logger(context.Background()).Warn("decode config error", zap.Error(err)) @@ -212,7 +212,7 @@ func (ch *pdConfHandler) updateConfig(newConfContent string, newVersion *configp logutil.Logger(context.Background()).Info("PDConfHandler updates config successfully", zap.String("new_version", newVersion.String()), zap.Any("accepted_conf_items", as), zap.Any("rejected_conf_items", rs)) - return true + return len(as) > 0 } func (ch *pdConfHandler) run() { @@ -253,8 +253,9 @@ func (ch *pdConfHandler) run() { continue } - ch.updateConfig(newConfContent, version) - ch.writeConfig() + if ch.updateConfig(newConfContent, version) { + ch.writeConfig() + } case <-ch.exit: return } diff --git a/config/config_test.go b/config/config_test.go index e5cc3a95cd240..abdc65dec92b2 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -196,12 +196,14 @@ region-cache-ttl=6000 store-limit=0 [stmt-summary] enable=false +enable-internal-query=true max-stmt-count=1000 max-sql-length=1024 refresh-interval=100 history-size=100 [experimental] allow-auto-random = true +allow-expression-index = true [isolation-read] engines = ["tiflash"] `) @@ -230,6 +232,7 @@ engines = ["tiflash"] c.Assert(conf.DelayCleanTableLock, Equals, uint64(5)) c.Assert(conf.SplitRegionMaxNum, Equals, uint64(10000)) c.Assert(conf.StmtSummary.Enable, Equals, false) + c.Assert(conf.StmtSummary.EnableInternalQuery, Equals, true) c.Assert(conf.StmtSummary.MaxStmtCount, Equals, uint(1000)) c.Assert(conf.StmtSummary.MaxSQLLength, Equals, uint(1024)) c.Assert(conf.StmtSummary.RefreshInterval, Equals, 100) @@ -238,6 +241,7 @@ engines = ["tiflash"] c.Assert(conf.RepairMode, Equals, true) c.Assert(conf.MaxServerConnections, Equals, uint32(200)) c.Assert(conf.MemQuotaQuery, Equals, int64(10000)) + c.Assert(conf.Experimental.AllowsExpressionIndex, IsTrue) c.Assert(conf.Experimental.AllowAutoRandom, IsTrue) c.Assert(conf.IsolationRead.Engines, DeepEquals, []string{"tiflash"}) c.Assert(conf.MaxIndexLength, Equals, 3080) diff --git a/ddl/column_test.go b/ddl/column_test.go index 141befc85425c..0ba5d3ca46887 100644 --- a/ddl/column_test.go +++ b/ddl/column_test.go @@ -946,7 +946,7 @@ func (s *testColumnSuite) TestModifyColumn(c *C) { for _, tt := range tests { ftA := s.colDefStrToFieldType(c, tt.origin) ftB := s.colDefStrToFieldType(c, tt.to) - err := modifiable(ftA, ftB) + err := checkModifyTypes(ftA, ftB, false) if err == nil { c.Assert(tt.err, IsNil) } else { diff --git a/ddl/db_change_test.go b/ddl/db_change_test.go index 7daa5c765d897..c72378dddc0a9 100644 --- a/ddl/db_change_test.go +++ b/ddl/db_change_test.go @@ -29,6 +29,7 @@ import ( "github.com/pingcap/parser/ast" "github.com/pingcap/parser/model" "github.com/pingcap/parser/terror" + "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/ddl" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/executor" @@ -90,7 +91,8 @@ func (s *testStateChangeSuiteBase) TearDownSuite(c *C) { } // TestShowCreateTable tests the result of "show create table" when we are running "add index" or "add column". -func (s *testStateChangeSuite) TestShowCreateTable(c *C) { +func (s *serialTestStateChangeSuite) TestShowCreateTable(c *C) { + config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("create table t (id int)") @@ -512,7 +514,7 @@ func (s *testStateChangeSuite) TestWriteOnlyWriteNULL(c *C) { addColumnSQL := "alter table t add column c5 int not null default 1 after c4" expectQuery := &expectQuery{"select c4, c5 from t", []string{"8 1"}} // TODO: This case should always fail in write-only state, but it doesn't. We use write-reorganization state here to keep it running stable. It need a double check. - s.runTestInSchemaState(c, model.StateWriteReorganization, "", addColumnSQL, sqls, expectQuery) + s.runTestInSchemaState(c, model.StateWriteReorganization, true, addColumnSQL, sqls, expectQuery) } func (s *testStateChangeSuite) TestWriteOnlyOnDupUpdate(c *C) { @@ -523,7 +525,7 @@ func (s *testStateChangeSuite) TestWriteOnlyOnDupUpdate(c *C) { addColumnSQL := "alter table t add column c5 int not null default 1 after c4" expectQuery := &expectQuery{"select c4, c5 from t", []string{"2 1"}} // TODO: This case should always fail in write-only state, but it doesn't. We use write-reorganization state here to keep it running stable. It need a double check. - s.runTestInSchemaState(c, model.StateWriteReorganization, "", addColumnSQL, sqls, expectQuery) + s.runTestInSchemaState(c, model.StateWriteReorganization, true, addColumnSQL, sqls, expectQuery) } // TestWriteOnly tests whether the correct columns is used in PhysicalIndexScan's ToPB function. @@ -533,7 +535,7 @@ func (s *testStateChangeSuite) TestWriteOnly(c *C) { sqls[1] = sqlWithErr{"update t use index(idx2) set c1 = 'c1_update' where c1 = 'a'", nil} sqls[2] = sqlWithErr{"insert t set c1 = 'c1_insert', c3 = '2018-02-12', c4 = 1", nil} addColumnSQL := "alter table t add column c5 int not null default 1 first" - s.runTestInSchemaState(c, model.StateWriteOnly, "", addColumnSQL, sqls, nil) + s.runTestInSchemaState(c, model.StateWriteOnly, true, addColumnSQL, sqls, nil) } // TestDeletaOnly tests whether the correct columns is used in PhysicalIndexScan's ToPB function. @@ -542,17 +544,37 @@ func (s *testStateChangeSuite) TestDeleteOnly(c *C) { sqls[0] = sqlWithErr{"insert t set c1 = 'c1_insert', c3 = '2018-02-12', c4 = 1", errors.Errorf("Can't find column c1")} dropColumnSQL := "alter table t drop column c1" - s.runTestInSchemaState(c, model.StateDeleteOnly, "", dropColumnSQL, sqls, nil) + s.runTestInSchemaState(c, model.StateDeleteOnly, true, dropColumnSQL, sqls, nil) } -func (s *testStateChangeSuiteBase) runTestInSchemaState(c *C, state model.SchemaState, tableName, alterTableSQL string, +func (s *testStateChangeSuite) TestWriteOnlyForDropColumn(c *C) { + _, err := s.se.Execute(context.Background(), "use test_db_state") + c.Assert(err, IsNil) + _, err = s.se.Execute(context.Background(), `create table tt (c1 int, c4 int)`) + c.Assert(err, IsNil) + _, err = s.se.Execute(context.Background(), "insert into tt (c1, c4) values(8, 8)") + c.Assert(err, IsNil) + defer s.se.Execute(context.Background(), "drop table tt") + + sqls := make([]sqlWithErr, 2) + sqls[0] = sqlWithErr{"update t set c1='5', c3='2020-03-01';", errors.New("[planner:1054]Unknown column 'c3' in 'field list'")} + sqls[1] = sqlWithErr{"update t t1, tt t2 set t1.c1='5', t1.c3='2020-03-01', t2.c1='10' where t1.c4=t2.c4", + errors.New("[planner:1054]Unknown column 'c3' in 'field list'")} + // TODO: Fix the case of sqls[2]. + // sqls[2] = sqlWithErr{"update t set c1='5' where c3='2017-07-01';", errors.New("[planner:1054]Unknown column 'c3' in 'field list'")} + dropColumnSQL := "alter table t drop column c3" + query := &expectQuery{sql: "select * from t;", rows: []string{"a N 8"}} + s.runTestInSchemaState(c, model.StateWriteOnly, false, dropColumnSQL, sqls, query) +} + +func (s *testStateChangeSuiteBase) runTestInSchemaState(c *C, state model.SchemaState, isOnJobUpdated bool, alterTableSQL string, sqlWithErrs []sqlWithErr, expectQuery *expectQuery) { _, err := s.se.Execute(context.Background(), `create table t ( - c1 varchar(64), - c2 enum('N','Y') not null default 'N', - c3 timestamp on update current_timestamp, - c4 int primary key, - unique key idx2 (c2, c3))`) + c1 varchar(64), + c2 enum('N','Y') not null default 'N', + c3 timestamp on update current_timestamp, + c4 int primary key, + unique key idx2 (c2))`) c.Assert(err, IsNil) defer s.se.Execute(context.Background(), "drop table t") _, err = s.se.Execute(context.Background(), "insert into t values('a', 'N', '2017-07-01', 8)") @@ -569,7 +591,7 @@ func (s *testStateChangeSuiteBase) runTestInSchemaState(c *C, state model.Schema c.Assert(err, IsNil) _, err = se.Execute(context.Background(), "use test_db_state") c.Assert(err, IsNil) - callback.OnJobUpdatedExported = func(job *model.Job) { + cbFunc := func(job *model.Job) { if job.SchemaState == prevState || checkErr != nil || times >= 3 { return } @@ -581,10 +603,18 @@ func (s *testStateChangeSuiteBase) runTestInSchemaState(c *C, state model.Schema _, err = se.Execute(context.Background(), sqlWithErr.sql) if !terror.ErrorEqual(err, sqlWithErr.expectErr) { checkErr = err + if checkErr == nil { + checkErr = errors.New("err can't be nil") + } break } } } + if isOnJobUpdated { + callback.OnJobUpdatedExported = cbFunc + } else { + callback.OnJobRunBeforeExported = cbFunc + } d := s.dom.DDL() originalCallback := d.GetHook() d.(ddl.DDLForTest).SetHook(callback) @@ -776,7 +806,8 @@ func (s *testStateChangeSuite) TestParallelAlterAddIndex(c *C) { s.testControlParallelExecSQL(c, sql1, sql2, f) } -func (s *testStateChangeSuite) TestParallelAlterAddExpressionIndex(c *C) { +func (s *serialTestStateChangeSuite) TestParallelAlterAddExpressionIndex(c *C) { + config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true sql1 := "ALTER TABLE t add index expr_index_b((b+1));" sql2 := "CREATE INDEX expr_index_b ON t ((c+1));" f := func(c *C, err1, err2 error) { diff --git a/ddl/db_integration_test.go b/ddl/db_integration_test.go index 24d269c1f6244..f1adc44c75e49 100644 --- a/ddl/db_integration_test.go +++ b/ddl/db_integration_test.go @@ -53,6 +53,7 @@ var _ = Suite(&testIntegrationSuite3{&testIntegrationSuite{}}) var _ = Suite(&testIntegrationSuite4{&testIntegrationSuite{}}) var _ = Suite(&testIntegrationSuite5{&testIntegrationSuite{}}) var _ = Suite(&testIntegrationSuite6{&testIntegrationSuite{}}) +var _ = SerialSuites(&testIntegrationSuite7{&testIntegrationSuite{}}) type testIntegrationSuite struct { lease time.Duration @@ -124,6 +125,7 @@ type testIntegrationSuite3 struct{ *testIntegrationSuite } type testIntegrationSuite4 struct{ *testIntegrationSuite } type testIntegrationSuite5 struct{ *testIntegrationSuite } type testIntegrationSuite6 struct{ *testIntegrationSuite } +type testIntegrationSuite7 struct{ *testIntegrationSuite } func (s *testIntegrationSuite5) TestNoZeroDateMode(c *C) { tk := testkit.NewTestKit(c, s.store) @@ -1090,7 +1092,7 @@ func (s *testIntegrationSuite5) TestBackwardCompatibility(c *C) { ticker := time.NewTicker(s.lease) defer ticker.Stop() for range ticker.C { - historyJob, err := s.getHistoryDDLJob(job.ID) + historyJob, err := getHistoryDDLJob(s.store, job.ID) c.Assert(err, IsNil) if historyJob == nil { @@ -1173,10 +1175,10 @@ func checkGetMaxTableRowID(ctx *testMaxTableRowIDContext, store kv.Storage, expe c.Assert(maxID, Equals, expectMaxID) } -func (s *testIntegrationSuite) getHistoryDDLJob(id int64) (*model.Job, error) { +func getHistoryDDLJob(store kv.Storage, id int64) (*model.Job, error) { var job *model.Job - err := kv.RunInNewTxn(s.store, false, func(txn kv.Transaction) error { + err := kv.RunInNewTxn(store, false, func(txn kv.Transaction) error { t := meta.NewMeta(txn) var err1 error job, err1 = t.GetHistoryDDLJob(id) @@ -1942,7 +1944,8 @@ func (s *testIntegrationSuite3) TestParserIssue284(c *C) { tk.MustExec("drop table test.t_parser_issue_284_2") } -func (s *testIntegrationSuite6) TestAddExpressionIndex(c *C) { +func (s *testIntegrationSuite7) TestAddExpressionIndex(c *C) { + config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("drop table if exists t;") @@ -1986,9 +1989,15 @@ func (s *testIntegrationSuite6) TestAddExpressionIndex(c *C) { c.Assert(len(columns), Equals, 2) tk.MustQuery("select * from t;").Check(testkit.Rows("1 2.1")) + + // Test experiment switch. + config.GetGlobalConfig().Experimental.AllowsExpressionIndex = false + tk.MustGetErrMsg("create index d on t((a+1))", "[ddl:8200]Unsupported creating expression index without allow-expression-index in config") } -func (s *testIntegrationSuite6) TestCreateExpressionIndexError(c *C) { +func (s *testIntegrationSuite7) TestCreateExpressionIndexError(c *C) { + config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true + tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("drop table if exists t;") @@ -2018,7 +2027,7 @@ func (s *testIntegrationSuite6) TestCreateExpressionIndexError(c *C) { tk.MustGetErrCode("alter table t add column e int as (_V$_expression_index_0 + 1);", errno.ErrBadField) } -func (s *testIntegrationSuite6) TestAddExpressionIndexOnPartition(c *C) { +func (s *testIntegrationSuite7) TestAddExpressionIndexOnPartition(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("drop table if exists t;") diff --git a/ddl/db_test.go b/ddl/db_test.go index d470a78a7d127..6c70e1b400928 100644 --- a/ddl/db_test.go +++ b/ddl/db_test.go @@ -37,6 +37,7 @@ import ( "github.com/pingcap/tidb/errno" "github.com/pingcap/tidb/infoschema" "github.com/pingcap/tidb/kv" + "github.com/pingcap/tidb/meta" "github.com/pingcap/tidb/meta/autoid" "github.com/pingcap/tidb/session" "github.com/pingcap/tidb/sessionctx" @@ -251,7 +252,8 @@ func (s *testDBSuite2) TestAddUniqueIndexRollback(c *C) { testAddIndexRollback(c, s.store, s.lease, idxName, addIdxSQL, errMsg, hasNullValsInKey) } -func (s *testDBSuite6) TestAddExpressionIndexRollback(c *C) { +func (s *testSerialDBSuite) TestAddExpressionIndexRollback(c *C) { + config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test_db") tk.MustExec("drop table if exists t1") @@ -4478,6 +4480,61 @@ func (s *testDBSuite6) TestAlterOrderBy(c *C) { s.tk.MustExec("drop table if exists ob") } +func (s *testSerialDBSuite) TestDDLJobErrorCount(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists ddl_error_table, new_ddl_error_table") + tk.MustExec("create table ddl_error_table(a int)") + is := s.dom.InfoSchema() + schemaName := model.NewCIStr("test") + tableName := model.NewCIStr("ddl_error_table") + schema, ok := is.SchemaByName(schemaName) + c.Assert(ok, IsTrue) + tbl, err := is.TableByName(schemaName, tableName) + c.Assert(err, IsNil) + + newTableName := model.NewCIStr("new_ddl_error_table") + job := &model.Job{ + SchemaID: schema.ID, + TableID: tbl.Meta().ID, + SchemaName: schema.Name.L, + Type: model.ActionRenameTable, + BinlogInfo: &model.HistoryInfo{}, + Args: []interface{}{schema.ID, newTableName}, + } + + c.Assert(failpoint.Enable("github.com/pingcap/tidb/ddl/mockErrEntrySizeTooLarge", `return(true)`), IsNil) + defer func() { + c.Assert(failpoint.Disable("github.com/pingcap/tidb/ddl/mockErrEntrySizeTooLarge"), IsNil) + }() + + txn, err := s.store.Begin() + c.Assert(err, IsNil) + t := meta.NewMeta(txn) + job.ID, err = t.GenGlobalID() + c.Assert(err, IsNil) + job.Version = 1 + job.StartTS = txn.StartTS() + + err = t.EnQueueDDLJob(job) + c.Assert(err, IsNil) + err = txn.Commit(context.Background()) + c.Assert(err, IsNil) + + ticker := time.NewTicker(s.lease) + defer ticker.Stop() + for range ticker.C { + historyJob, err := getHistoryDDLJob(s.store, job.ID) + c.Assert(err, IsNil) + if historyJob == nil { + continue + } + c.Assert(historyJob.ErrorCount, Equals, int64(1)) + kv.ErrEntryTooLarge.Equal(historyJob.Error) + break + } +} + func init() { // Make sure it will only be executed once. domain.SchemaOutOfDateRetryInterval = int64(50 * time.Millisecond) diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go index b2e813a856ad6..068212f7d2741 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -48,6 +48,7 @@ import ( driver "github.com/pingcap/tidb/types/parser_driver" "github.com/pingcap/tidb/util" "github.com/pingcap/tidb/util/chunk" + "github.com/pingcap/tidb/util/collate" "github.com/pingcap/tidb/util/domainutil" "github.com/pingcap/tidb/util/logutil" "github.com/pingcap/tidb/util/mock" @@ -112,7 +113,7 @@ func (d *ddl) AlterSchema(ctx sessionctx.Context, stmt *ast.AlterDatabaseStmt) ( return ErrConflictingDeclarations.GenWithStackByArgs(toCharset, val.Value) } case ast.DatabaseOptionCollate: - info, err := charset.GetCollationByName(val.Value) + info, err := collate.GetCollationByName(val.Value) if err != nil { return errors.Trace(err) } @@ -142,7 +143,7 @@ func (d *ddl) AlterSchema(ctx sessionctx.Context, stmt *ast.AlterDatabaseStmt) ( } // Check the current TiDB limitations. - if err = modifiableCharsetAndCollation(toCharset, toCollate, dbInfo.Charset, dbInfo.Collate); err != nil { + if err = checkModifyCharsetAndCollation(toCharset, toCollate, dbInfo.Charset, dbInfo.Collate, false); err != nil { return errors.Trace(err) } @@ -345,7 +346,7 @@ func setCharsetCollationFlenDecimal(tp *types.FieldType, specifiedCollates []str // We should derive charset from it's collate specified rather than getting from table and db. // It is handled like mysql's logic, use derived charset to judge conflict with next collate. for _, spc := range specifiedCollates { - derivedCollation, err := charset.GetCollationByName(spc) + derivedCollation, err := collate.GetCollationByName(spc) if err != nil { return errors.Trace(err) } @@ -376,7 +377,7 @@ func setCharsetCollationFlenDecimal(tp *types.FieldType, specifiedCollates []str } else { // Both the charset and collate are specified. for _, spc := range specifiedCollates { - derivedCollation, err := charset.GetCollationByName(spc) + derivedCollation, err := collate.GetCollationByName(spc) if err != nil { return errors.Trace(err) } @@ -1828,6 +1829,11 @@ func checkCharsetAndCollation(cs string, co string) error { if !charset.ValidCharsetAndCollation(cs, co) { return ErrUnknownCharacterSet.GenWithStackByArgs(cs) } + if co != "" { + if _, err := collate.GetCollationByName(co); err != nil { + return errors.Trace(err) + } + } return nil } @@ -1923,7 +1929,7 @@ func getCharsetAndCollateInTableOption(startIdx int, options []*ast.TableOption) coll = info.DefaultCollation } case ast.TableOptionCollate: - info, err := charset.GetCollationByName(opt.StrValue) + info, err := collate.GetCollationByName(opt.StrValue) if err != nil { return "", "", err } @@ -2527,11 +2533,18 @@ func (d *ddl) DropColumn(ctx sessionctx.Context, ti ast.Ident, spec *ast.AlterTa return errors.Trace(err) } -// modifiableCharsetAndCollation returns error when the charset or collation is not modifiable. -func modifiableCharsetAndCollation(toCharset, toCollate, origCharset, origCollate string) error { +// checkModifyCharsetAndCollation returns error when the charset or collation is not modifiable. +// needRewriteCollationData is used when trying to modify the collation of a column, it is true when the column is with +// index because index of a string column is collation-aware. +func checkModifyCharsetAndCollation(toCharset, toCollate, origCharset, origCollate string, needRewriteCollationData bool) error { if !charset.ValidCharsetAndCollation(toCharset, toCollate) { return ErrUnknownCharacterSet.GenWithStack("Unknown character set: '%s', collation: '%s'", toCharset, toCollate) } + + if needRewriteCollationData && collate.NewCollationEnabled() && !collate.CompatibleCollate(origCollate, toCollate) { + return errUnsupportedModifyCollation.GenWithStackByArgs(origCollate, toCollate) + } + if (origCharset == charset.CharsetUTF8 && toCharset == charset.CharsetUTF8MB4) || (origCharset == charset.CharsetUTF8 && toCharset == charset.CharsetUTF8) || (origCharset == charset.CharsetUTF8MB4 && toCharset == charset.CharsetUTF8MB4) { @@ -2550,11 +2563,11 @@ func modifiableCharsetAndCollation(toCharset, toCollate, origCharset, origCollat return nil } -// modifiable checks if the 'origin' type can be modified to 'to' type with out the need to +// checkModifyTypes checks if the 'origin' type can be modified to 'to' type with out the need to // change or check existing data in the table. -// It returns true if the two types has the same Charset and Collation, the same sign, both are -// integer types or string types, and new Flen and Decimal must be greater than or equal to origin. -func modifiable(origin *types.FieldType, to *types.FieldType) error { +// It returns error if the two types has incompatible Charset and Collation, different sign, different +// digital/string types, or length of new Flen and Decimal is less than origin. +func checkModifyTypes(origin *types.FieldType, to *types.FieldType, needRewriteCollationData bool) error { unsupportedMsg := fmt.Sprintf("type %v not match origin %v", to.CompactStr(), origin.CompactStr()) switch origin.Tp { case mysql.TypeVarchar, mysql.TypeString, mysql.TypeVarString, @@ -2614,7 +2627,7 @@ func modifiable(origin *types.FieldType, to *types.FieldType) error { return errUnsupportedModifyColumn.GenWithStackByArgs(msg) } - err := modifiableCharsetAndCollation(to.Charset, to.Collate, origin.Charset, origin.Collate) + err := checkModifyCharsetAndCollation(to.Charset, to.Collate, origin.Charset, origin.Collate, needRewriteCollationData) return errors.Trace(err) } @@ -2815,7 +2828,11 @@ func (d *ddl) getModifiableColumnJob(ctx sessionctx.Context, ident ast.Ident, or return nil, errors.Trace(err) } - if err = modifiable(&col.FieldType, &newCol.FieldType); err != nil { + if err = checkModifyTypes(&col.FieldType, &newCol.FieldType, isColumnWithIndex(col.Name.L, t.Meta().Indices)); err != nil { + if strings.Contains(err.Error(), "Unsupported modifying collation") { + colErrMsg := "Unsupported modifying collation of column '%s' from '%s' to '%s' when index is defined on it." + err = errUnsupportedModifyCollation.GenWithStack(colErrMsg, col.Name.L, col.Collate, newCol.Collate) + } return nil, errors.Trace(err) } @@ -3298,7 +3315,7 @@ func checkAlterTableCharset(tblInfo *model.TableInfo, dbInfo *model.DBInfo, toCh } } - if err = modifiableCharsetAndCollation(toCharset, toCollate, origCharset, origCollate); err != nil { + if err = checkModifyCharsetAndCollation(toCharset, toCollate, origCharset, origCollate, false); err != nil { return doNothing, err } @@ -3314,7 +3331,11 @@ func checkAlterTableCharset(tblInfo *model.TableInfo, dbInfo *model.DBInfo, toCh if len(col.Charset) == 0 { continue } - if err = modifiableCharsetAndCollation(toCharset, toCollate, col.Charset, col.Collate); err != nil { + if err = checkModifyCharsetAndCollation(toCharset, toCollate, col.Charset, col.Collate, isColumnWithIndex(col.Name.L, tblInfo.Indices)); err != nil { + if strings.Contains(err.Error(), "Unsupported modifying collation") { + colErrMsg := "Unsupported converting collation of column '%s' from '%s' to '%s' when index is defined on it." + err = errUnsupportedModifyCollation.GenWithStack(colErrMsg, col.Name.L, col.Collate, toCollate) + } return doNothing, err } } @@ -3712,6 +3733,9 @@ func (d *ddl) CreateIndex(ctx sessionctx.Context, ti ast.Ident, keyType ast.Inde if err != nil { return err } + if len(hiddenCols) > 0 && !config.GetGlobalConfig().Experimental.AllowsExpressionIndex { + return ErrUnsupportedExpressionIndex + } if err = checkAddColumnTooManyColumns(len(t.Cols()) + len(hiddenCols)); err != nil { return errors.Trace(err) } diff --git a/ddl/ddl_worker.go b/ddl/ddl_worker.go index 83af5c404f70a..6e9b0b1dec514 100644 --- a/ddl/ddl_worker.go +++ b/ddl/ddl_worker.go @@ -283,6 +283,7 @@ func (w *worker) handleUpdateJobError(t *meta.Meta, job *model.Job, err error) e // Reduce this txn entry size. job.BinlogInfo.Clean() job.Error = toTError(err) + job.ErrorCount++ job.SchemaState = model.StateNone job.State = model.JobStateCancelled err = w.finishDDLJob(t, job) @@ -293,6 +294,11 @@ func (w *worker) handleUpdateJobError(t *meta.Meta, job *model.Job, err error) e // updateDDLJob updates the DDL job information. // Every time we enter another state except final state, we must call this function. func (w *worker) updateDDLJob(t *meta.Meta, job *model.Job, meetErr bool) error { + failpoint.Inject("mockErrEntrySizeTooLarge", func(val failpoint.Value) { + if val.(bool) { + failpoint.Return(kv.ErrEntryTooLarge) + } + }) updateRawArgs := true // If there is an error when running job and the RawArgs hasn't been decoded by DecodeArgs, // so we shouldn't replace RawArgs with the marshaling Args. diff --git a/ddl/error.go b/ddl/error.go index a773edb8500a4..71c5ca735fe0a 100644 --- a/ddl/error.go +++ b/ddl/error.go @@ -36,27 +36,28 @@ var ( ErrRepairTableFail = terror.ClassDDL.New(mysql.ErrRepairTable, mysql.MySQLErrName[mysql.ErrRepairTable]) // We don't support dropping column with index covered now. - errCantDropColWithIndex = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "drop column with index")) - errUnsupportedAddColumn = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "add column")) - errUnsupportedModifyColumn = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "modify column: %s")) - errUnsupportedModifyCharset = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "modify %s")) - errUnsupportedPKHandle = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "drop integer primary key")) - errUnsupportedCharset = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "charset %s and collate %s")) - errUnsupportedShardRowIDBits = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "shard_row_id_bits for table with primary key as row id")) - errBlobKeyWithoutLength = terror.ClassDDL.New(mysql.ErrBlobKeyWithoutLength, mysql.MySQLErrName[mysql.ErrBlobKeyWithoutLength]) - errKeyPart0 = terror.ClassDDL.New(mysql.ErrKeyPart0, mysql.MySQLErrName[mysql.ErrKeyPart0]) - errIncorrectPrefixKey = terror.ClassDDL.New(mysql.ErrWrongSubKey, mysql.MySQLErrName[mysql.ErrWrongSubKey]) - errTooLongKey = terror.ClassDDL.New(mysql.ErrTooLongKey, mysql.MySQLErrName[mysql.ErrTooLongKey]) - errKeyColumnDoesNotExits = terror.ClassDDL.New(mysql.ErrKeyColumnDoesNotExits, mysql.MySQLErrName[mysql.ErrKeyColumnDoesNotExits]) - errUnknownTypeLength = terror.ClassDDL.New(mysql.ErrUnknownTypeLength, mysql.MySQLErrName[mysql.ErrUnknownTypeLength]) - errUnknownFractionLength = terror.ClassDDL.New(mysql.ErrUnknownFractionLength, mysql.MySQLErrName[mysql.ErrUnknownFractionLength]) - errInvalidDDLJobVersion = terror.ClassDDL.New(mysql.ErrInvalidDDLJobVersion, mysql.MySQLErrName[mysql.ErrInvalidDDLJobVersion]) - errInvalidUseOfNull = terror.ClassDDL.New(mysql.ErrInvalidUseOfNull, mysql.MySQLErrName[mysql.ErrInvalidUseOfNull]) - errTooManyFields = terror.ClassDDL.New(mysql.ErrTooManyFields, mysql.MySQLErrName[mysql.ErrTooManyFields]) - errInvalidSplitRegionRanges = terror.ClassDDL.New(mysql.ErrInvalidSplitRegionRanges, mysql.MySQLErrName[mysql.ErrInvalidSplitRegionRanges]) - errReorgPanic = terror.ClassDDL.New(mysql.ErrReorgPanic, mysql.MySQLErrName[mysql.ErrReorgPanic]) - errFkColumnCannotDrop = terror.ClassDDL.New(mysql.ErrFkColumnCannotDrop, mysql.MySQLErrName[mysql.ErrFkColumnCannotDrop]) - errFKIncompatibleColumns = terror.ClassDDL.New(mysql.ErrFKIncompatibleColumns, mysql.MySQLErrName[mysql.ErrFKIncompatibleColumns]) + errCantDropColWithIndex = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "drop column with index")) + errUnsupportedAddColumn = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "add column")) + errUnsupportedModifyColumn = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "modify column: %s")) + errUnsupportedModifyCharset = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "modify %s")) + errUnsupportedModifyCollation = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "modifying collation from %s to %s")) + errUnsupportedPKHandle = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "drop integer primary key")) + errUnsupportedCharset = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "charset %s and collate %s")) + errUnsupportedShardRowIDBits = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "shard_row_id_bits for table with primary key as row id")) + errBlobKeyWithoutLength = terror.ClassDDL.New(mysql.ErrBlobKeyWithoutLength, mysql.MySQLErrName[mysql.ErrBlobKeyWithoutLength]) + errKeyPart0 = terror.ClassDDL.New(mysql.ErrKeyPart0, mysql.MySQLErrName[mysql.ErrKeyPart0]) + errIncorrectPrefixKey = terror.ClassDDL.New(mysql.ErrWrongSubKey, mysql.MySQLErrName[mysql.ErrWrongSubKey]) + errTooLongKey = terror.ClassDDL.New(mysql.ErrTooLongKey, mysql.MySQLErrName[mysql.ErrTooLongKey]) + errKeyColumnDoesNotExits = terror.ClassDDL.New(mysql.ErrKeyColumnDoesNotExits, mysql.MySQLErrName[mysql.ErrKeyColumnDoesNotExits]) + errUnknownTypeLength = terror.ClassDDL.New(mysql.ErrUnknownTypeLength, mysql.MySQLErrName[mysql.ErrUnknownTypeLength]) + errUnknownFractionLength = terror.ClassDDL.New(mysql.ErrUnknownFractionLength, mysql.MySQLErrName[mysql.ErrUnknownFractionLength]) + errInvalidDDLJobVersion = terror.ClassDDL.New(mysql.ErrInvalidDDLJobVersion, mysql.MySQLErrName[mysql.ErrInvalidDDLJobVersion]) + errInvalidUseOfNull = terror.ClassDDL.New(mysql.ErrInvalidUseOfNull, mysql.MySQLErrName[mysql.ErrInvalidUseOfNull]) + errTooManyFields = terror.ClassDDL.New(mysql.ErrTooManyFields, mysql.MySQLErrName[mysql.ErrTooManyFields]) + errInvalidSplitRegionRanges = terror.ClassDDL.New(mysql.ErrInvalidSplitRegionRanges, mysql.MySQLErrName[mysql.ErrInvalidSplitRegionRanges]) + errReorgPanic = terror.ClassDDL.New(mysql.ErrReorgPanic, mysql.MySQLErrName[mysql.ErrReorgPanic]) + errFkColumnCannotDrop = terror.ClassDDL.New(mysql.ErrFkColumnCannotDrop, mysql.MySQLErrName[mysql.ErrFkColumnCannotDrop]) + errFKIncompatibleColumns = terror.ClassDDL.New(mysql.ErrFKIncompatibleColumns, mysql.MySQLErrName[mysql.ErrFKIncompatibleColumns]) errOnlyOnRangeListPartition = terror.ClassDDL.New(mysql.ErrOnlyOnRangeListPartition, mysql.MySQLErrName[mysql.ErrOnlyOnRangeListPartition]) // errWrongKeyColumn is for table column cannot be indexed. @@ -197,4 +198,6 @@ var ( ErrSequenceUnsupportedTableOption = terror.ClassDDL.New(mysql.ErrSequenceUnsupportedTableOption, mysql.MySQLErrName[mysql.ErrSequenceUnsupportedTableOption]) // ErrColumnTypeUnsupportedNextValue is returned when sequence next value is assigned to unsupported column type. ErrColumnTypeUnsupportedNextValue = terror.ClassDDL.New(mysql.ErrColumnTypeUnsupportedNextValue, mysql.MySQLErrName[mysql.ErrColumnTypeUnsupportedNextValue]) + // ErrUnsupportedExpressionIndex is returned when create an expression index without allow-expression-index. + ErrUnsupportedExpressionIndex = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "creating expression index without allow-expression-index in config")) ) diff --git a/ddl/sequence_test.go b/ddl/sequence_test.go index dcf803806c964..41985be876b60 100644 --- a/ddl/sequence_test.go +++ b/ddl/sequence_test.go @@ -34,6 +34,7 @@ type testSequenceSuite struct{ *testDBSuite } func (s *testSequenceSuite) TestCreateSequence(c *C) { s.tk = testkit.NewTestKit(c, s.store) s.tk.MustExec("use test") + s.tk.MustExec("drop sequence if exists seq") s.tk.MustGetErrCode("create sequence `seq `", mysql.ErrWrongTableName) // increment should not be set as 0. @@ -744,3 +745,29 @@ func (s *testSequenceSuite) TestUnflodSequence(c *C) { // `select nextval(seq), a from t1 union select nextval(seq), a from t2` // The executing order of nextval and lastval is implicit, don't make any assumptions on it. } + +// before this PR: +// single insert consume: 50.498672ms +// after this PR: +// single insert consume: 33.213615ms +// Notice: use go test -check.b Benchmarkxxx to test it. +func (s *testSequenceSuite) BenchmarkInsertCacheDefaultExpr(c *C) { + s.tk = testkit.NewTestKit(c, s.store) + s.tk.MustExec("use test") + s.tk.MustExec("drop sequence if exists seq") + s.tk.MustExec("drop table if exists t") + s.tk.MustExec("create sequence seq") + s.tk.MustExec("create table t(a int default next value for seq)") + sql := "insert into t values " + for i := 0; i < 1000; i++ { + if i == 0 { + sql += "()" + } else { + sql += ",()" + } + } + c.ResetTimer() + for i := 0; i < c.N; i++ { + s.tk.MustExec(sql) + } +} diff --git a/ddl/serial_test.go b/ddl/serial_test.go index 640a3f8a1acf4..5fb39f68d89f6 100644 --- a/ddl/serial_test.go +++ b/ddl/serial_test.go @@ -41,6 +41,7 @@ import ( "github.com/pingcap/tidb/store/mockstore" "github.com/pingcap/tidb/store/mockstore/mocktikv" "github.com/pingcap/tidb/util/admin" + "github.com/pingcap/tidb/util/collate" "github.com/pingcap/tidb/util/gcutil" "github.com/pingcap/tidb/util/mock" "github.com/pingcap/tidb/util/testkit" @@ -480,17 +481,23 @@ func (s *testSerialSuite) TestRecoverTableByJobID(c *C) { tk.MustExec("insert into t_recover values (1),(2),(3)") tk.MustExec("drop table t_recover") - rs, err := tk.Exec("admin show ddl jobs") - c.Assert(err, IsNil) - rows, err := session.GetRows4Test(context.Background(), tk.Se, rs) - c.Assert(err, IsNil) - row := rows[0] - c.Assert(row.GetString(1), Equals, "test_recover") - c.Assert(row.GetString(3), Equals, "drop table") - jobID := row.GetInt64(0) + getDDLJobID := func(table, tp string) int64 { + rs, err := tk.Exec("admin show ddl jobs") + c.Assert(err, IsNil) + rows, err := session.GetRows4Test(context.Background(), tk.Se, rs) + c.Assert(err, IsNil) + for _, row := range rows { + if row.GetString(1) == table && row.GetString(3) == tp { + return row.GetInt64(0) + } + } + c.Errorf("can't find %s table of %s", tp, table) + return -1 + } + jobID := getDDLJobID("test_recover", "drop table") // if GC safe point is not exists in mysql.tidb - _, err = tk.Exec(fmt.Sprintf("recover table by job %d", jobID)) + _, err := tk.Exec(fmt.Sprintf("recover table by job %d", jobID)) c.Assert(err, NotNil) c.Assert(err.Error(), Equals, "can not get 'tikv_gc_safe_point'") // set GC safe point @@ -539,14 +546,7 @@ func (s *testSerialSuite) TestRecoverTableByJobID(c *C) { tk.MustExec("delete from t_recover where a > 1") tk.MustExec("drop table t_recover") - rs, err = tk.Exec("admin show ddl jobs") - c.Assert(err, IsNil) - rows, err = session.GetRows4Test(context.Background(), tk.Se, rs) - c.Assert(err, IsNil) - row = rows[0] - c.Assert(row.GetString(1), Equals, "test_recover") - c.Assert(row.GetString(3), Equals, "drop table") - jobID = row.GetInt64(0) + jobID = getDDLJobID("test_recover", "drop table") tk.MustExec(fmt.Sprintf("recover table by job %d", jobID)) @@ -556,6 +556,14 @@ func (s *testSerialSuite) TestRecoverTableByJobID(c *C) { tk.MustExec("insert into t_recover values (7),(8),(9)") tk.MustQuery("select * from t_recover;").Check(testkit.Rows("1", "7", "8", "9")) + // Test for recover truncate table. + tk.MustExec("truncate table t_recover") + tk.MustExec("rename table t_recover to t_recover_new") + jobID = getDDLJobID("test_recover", "truncate table") + tk.MustExec(fmt.Sprintf("recover table by job %d", jobID)) + tk.MustExec("insert into t_recover values (10)") + tk.MustQuery("select * from t_recover;").Check(testkit.Rows("1", "7", "8", "9", "10")) + gcEnable, err := gcutil.CheckGCEnable(tk.Se) c.Assert(err, IsNil) c.Assert(gcEnable, Equals, false) @@ -903,3 +911,64 @@ func (s *testSerialSuite) TestAutoRandom(c *C) { config.GetGlobalConfig().Experimental.AllowAutoRandom = false assertExperimentDisabled("create table auto_random_table (a int primary key auto_random(3))") } + +func (s *testSerialSuite) TestModifyingColumn4NewCollations(c *C) { + collate.SetNewCollationEnabledForTest(true) + defer collate.SetNewCollationEnabledForTest(false) + + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("create database dct") + tk.MustExec("use dct") + tk.MustExec("create table t(b varchar(10) collate utf8_bin, c varchar(10) collate utf8_general_ci) collate utf8_bin") + // Column collation can be changed as long as there is no index defined. + tk.MustExec("alter table t modify b varchar(10) collate utf8_general_ci") + tk.MustExec("alter table t modify c varchar(10) collate utf8_bin") + tk.MustExec("alter table t charset utf8 collate utf8_general_ci") + tk.MustExec("alter table t convert to charset utf8 collate utf8_bin") + tk.MustExec("alter table t convert to charset utf8 collate utf8_general_ci") + tk.MustExec("alter table t modify b varchar(10) collate utf8_bin") + + tk.MustExec("alter table t add index b_idx(b)") + tk.MustExec("alter table t add index c_idx(c)") + tk.MustGetErrMsg("alter table t modify b varchar(10) collate utf8_general_ci", "[ddl:8200]Unsupported modifying collation of column 'b' from 'utf8_bin' to 'utf8_general_ci' when index is defined on it.") + tk.MustGetErrMsg("alter table t modify c varchar(10) collate utf8_bin", "[ddl:8200]Unsupported modifying collation of column 'c' from 'utf8_general_ci' to 'utf8_bin' when index is defined on it.") + tk.MustGetErrMsg("alter table t convert to charset utf8 collate utf8_general_ci", "[ddl:8200]Unsupported converting collation of column 'b' from 'utf8_bin' to 'utf8_general_ci' when index is defined on it.") + // Change to a compatible collation is allowed. + tk.MustExec("alter table t modify c varchar(10) collate utf8mb4_general_ci") +} + +func (s *testSerialSuite) TestForbidUnsupportedCollations(c *C) { + collate.SetNewCollationEnabledForTest(true) + defer collate.SetNewCollationEnabledForTest(false) + tk := testkit.NewTestKit(c, s.store) + + mustGetUnsupportedCollation := func(sql string, coll string) { + tk.MustGetErrMsg(sql, fmt.Sprintf("[ddl:1273]Unsupported collation when new collation is enabled: '%s'", coll)) + } + // Test default collation of database. + mustGetUnsupportedCollation("create database ucd charset utf8mb4 collate utf8mb4_unicode_ci", "utf8mb4_unicode_ci") + mustGetUnsupportedCollation("create database ucd charset utf8 collate utf8_unicode_ci", "utf8_unicode_ci") + tk.MustExec("create database ucd") + mustGetUnsupportedCollation("alter database ucd charset utf8mb4 collate utf8mb4_unicode_ci", "utf8mb4_unicode_ci") + mustGetUnsupportedCollation("alter database ucd collate utf8mb4_unicode_ci", "utf8mb4_unicode_ci") + + // Test default collation of table. + tk.MustExec("use ucd") + mustGetUnsupportedCollation("create table t(a varchar(20)) charset utf8mb4 collate utf8mb4_unicode_ci", "utf8mb4_unicode_ci") + mustGetUnsupportedCollation("create table t(a varchar(20)) collate utf8_unicode_ci", "utf8_unicode_ci") + tk.MustExec("create table t(a varchar(20)) collate utf8mb4_general_ci") + mustGetUnsupportedCollation("alter table t default collate utf8mb4_unicode_ci", "utf8mb4_unicode_ci") + mustGetUnsupportedCollation("alter table t convert to charset utf8mb4 collate utf8mb4_unicode_ci", "utf8mb4_unicode_ci") + + // Test collation of columns. + mustGetUnsupportedCollation("create table t1(a varchar(20)) collate utf8mb4_unicode_ci", "utf8mb4_unicode_ci") + mustGetUnsupportedCollation("create table t1(a varchar(20)) charset utf8 collate utf8_unicode_ci", "utf8_unicode_ci") + tk.MustExec("create table t1(a varchar(20))") + mustGetUnsupportedCollation("alter table t1 modify a varchar(20) collate utf8mb4_unicode_ci", "utf8mb4_unicode_ci") + mustGetUnsupportedCollation("alter table t1 modify a varchar(20) charset utf8 collate utf8_unicode_ci", "utf8_unicode_ci") + mustGetUnsupportedCollation("alter table t1 modify a varchar(20) charset utf8 collate utf8_unicode_ci", "utf8_unicode_ci") + + // TODO(bb7133): fix the following cases by setting charset from collate firstly. + // mustGetUnsupportedCollation("create database ucd collate utf8mb4_unicode_ci", errMsgUnsupportedUnicodeCI) + // mustGetUnsupportedCollation("alter table t convert to collate utf8mb4_unicode_ci", "utf8mb4_unicode_ci") +} diff --git a/distsql/select_result_test.go b/distsql/select_result_test.go index 9a77a2ab1f0f2..803d84bf4f0d9 100644 --- a/distsql/select_result_test.go +++ b/distsql/select_result_test.go @@ -46,7 +46,7 @@ func (s *testSuite) TestUpdateCopRuntimeStats(c *C) { c.Assert(ctx.GetSessionVars().StmtCtx.RuntimeStatsColl, NotNil) c.Assert(len(sr.selectResp.GetExecutionSummaries()), Equals, len(sr.copPlanIDs)) sr.updateCopRuntimeStats(&execdetails.ExecDetails{CalleeAddress: "callee"}, 0) - c.Assert(ctx.GetSessionVars().StmtCtx.RuntimeStatsColl.GetCopStats("callee").String(), Equals, "time:1ns, loops:1, rows:1") + c.Assert(ctx.GetSessionVars().StmtCtx.RuntimeStatsColl.GetCopStats("callee").String(), Equals, "time:1ns, loops:1") } type copPlan struct{} diff --git a/docs/design/2020-03-12-invisible-index.md b/docs/design/2020-03-12-invisible-index.md new file mode 100644 index 0000000000000..e44cfcd07abfd --- /dev/null +++ b/docs/design/2020-03-12-invisible-index.md @@ -0,0 +1,91 @@ +# Proposal: Invisible index + +- Author(s): [Deardrops](https://github.com/Deardrops), [wjhuang2016](https://github.com/wjhuang2016) +- Last updated: Mar. 12, 2020 +- Discussion at: https://github.com/pingcap/tidb/issues/9246 + +## Abstract + +MySQL supports [invisible indexes](https://dev.mysql.com/doc/refman/8.0/en/invisible-indexes.html); that is, indexes that are not used by the optimizer. + +This is a useful feature for dropping an index in a safe way. Invisible indexes make it possible to test the effect of removing an index on query performance, without making a destructive change that must be undone should the index turn out to be required. Dropping and re-adding an index can be expensive for a large table, whereas making it invisible and visible are fast, in-place operations. + +Support the option of `VISIBLE | INVISIBLE`. +``` +CREATE [...] INDEX index_name + [index_type] + ON tbl_name (key_part,...) + [index_option] + +index_option: + {VISIBLE | INVISIBLE} +``` + +Also, the following behaviors need to be supported as well: + +- Display information about invisible indexes in the output of `INFORMATION_SCHEMA.STATISTICS` or `SHOW INDEX`. +- Index hints need to report errors when used in invisible indexes. +- The primary key cannot be set to an invisible index. + +## Background + +Index has a great influence on the performance of the database. Whether there is an index or whether the optimizer chooses the right index determines the performance of reading and writing the database to a great extent. In some cases, we would like to know the impact of deleting an index on the read-write performance of the database. At present, our method is to tell the optimizer to ignore the index through Index Hint. Although this method can achieve the goal, it is not practical to modify all SQL statements. + +## Proposal + +Adding an option (visible or not) to the index. If it is not visible, it's called **Invisible Index**. Invisible indexes cannot be used by the optimizer (with the `use_invisible_indexes` switch on), but the index is maintained during DML operations. For a query statement, invisible indexes have the same effect as ignoring the index through Index Hint. + +The option `INVISIBLE` of an index can be changed by using the following DDL statement: + +``` +ALTER TABLE table_name ALTER INDEX index_name { INVISIBLE | VISIBLE }; +``` + +Or by setting option `INVISIBLE` when creating an index: + +``` +CREATE INDEX index_name ON table_name(key) [ INVISIBLE | VISIBLE ]; +``` + +`INVISIBLE`, `VISIBLE` is as part of the index option, they can also be set when creating a table. + +In order to know whether an index is invisible, it can be read from the `INFORMATION_SCHEMA.STATISTICS` table or through the `SHOW INDEX` command. + +In addition, add a new flag `use_invisible_indexes` in system variable `optimizer_switch`, which determine whether the option `INVISIBLE` takes effect. If `use_invite_indexes` is on, the optimizer can still use invisible index. + +A table with no explicit primary key may still have an effective implicit primary key if it has any UNIQUE indexes on NOT NULL columns. In this case, the first such index places the same constraint on table rows as an explicit primary key and that index cannot be made invisible. + +## Rationale + +Another solution for implement invisible indexes is: Indicate invisibility by DDL state `WriteOnly`. This solution has the following problems: + +- The logic of schema change needs to be changed, which is relatively complicated to implement. +- Cannot distinguish between indexes that are currently in WriteOnly and invisible indexes. +- Handling the switch is troublesome. + +## Compatibility and Migration Plan + +This the a new feature and it's absolutly compatible with old TiDB versions, also, it does not impact any data migration. +The syntax and functions are basically compatible with MySQL expect: + + When use invisible index in `SQL Hint`, and set `use_invisible_indexes = false`, MySQL allow use the invisible index. + But in TiDB, It's **not allowed** and an `Unresolved name` error will be thrown. + +## Implementation + +- Add syntax support in parser +- Add a new column `IS_VISIBLE` in `information_schema.statistics` +- Add a new column `VISIBLE` in `SHOW INDEX FROM table` statement +- Show invisiable column infomations in `SHOW CREATE TABLE` statement +- Add `use_invisible_indexes` in system variable `@@optimizer_switch` +- Add new error message `ERROR 3522 (HY000): A primary key index cannot be invisible` +- Ignore invisible index in optimizer and add unit tests + +## Testing Plan + +- Unit test +- Learn from MySQL test cases related to invisible indexes + +## Open issues + +https://github.com/pingcap/tidb/issues/9246 diff --git a/domain/global_vars_cache.go b/domain/global_vars_cache.go index 7011ff7ccf09d..c99e652dfa903 100644 --- a/domain/global_vars_cache.go +++ b/domain/global_vars_cache.go @@ -76,6 +76,8 @@ func checkEnableServerGlobalVar(rows []chunk.Row) { switch row.GetString(0) { case variable.TiDBEnableStmtSummary: stmtsummary.StmtSummaryByDigestMap.SetEnabled(sVal, false) + case variable.TiDBStmtSummaryInternalQuery: + stmtsummary.StmtSummaryByDigestMap.SetEnabledInternalQuery(sVal, false) case variable.TiDBStmtSummaryRefreshInterval: stmtsummary.StmtSummaryByDigestMap.SetRefreshInterval(sVal, false) case variable.TiDBStmtSummaryHistorySize: diff --git a/domain/infosync/info.go b/domain/infosync/info.go index 037fafab688b8..fa47afc44c940 100644 --- a/domain/infosync/info.go +++ b/domain/infosync/info.go @@ -309,9 +309,12 @@ func (is *InfoSyncer) getTopologyInfo() topologyInfo { s = "" } return topologyInfo{ - ServerVersionInfo: is.info.ServerVersionInfo, - StatusPort: is.info.StatusPort, - BinaryPath: s, + ServerVersionInfo: ServerVersionInfo{ + Version: mysql.TiDBReleaseVersion, + GitHash: is.info.ServerVersionInfo.GitHash, + }, + StatusPort: is.info.StatusPort, + BinaryPath: s, } } diff --git a/executor/adapter.go b/executor/adapter.go index 184c7f04723c4..fa1af494f2873 100644 --- a/executor/adapter.go +++ b/executor/adapter.go @@ -878,7 +878,7 @@ func getPlanDigest(sctx sessionctx.Context, p plannercore.Plan) (normalized, pla func (a *ExecStmt) SummaryStmt() { sessVars := a.Ctx.GetSessionVars() // Internal SQLs must also be recorded to keep the consistency of `PrevStmt` and `PrevStmtDigest`. - if !stmtsummary.StmtSummaryByDigestMap.Enabled() { + if !stmtsummary.StmtSummaryByDigestMap.Enabled() || (sessVars.InRestrictedSQL && !stmtsummary.StmtSummaryByDigestMap.EnabledInternal()) { sessVars.SetPrevStmtDigest("") return } @@ -942,5 +942,6 @@ func (a *ExecStmt) SummaryStmt() { ExecDetail: &execDetail, MemMax: memMax, StartTime: sessVars.StartTime, + IsInternal: sessVars.InRestrictedSQL, }) } diff --git a/executor/aggfuncs/builder.go b/executor/aggfuncs/builder.go index 6454bf6c6583c..48cdb5ca4e185 100644 --- a/executor/aggfuncs/builder.go +++ b/executor/aggfuncs/builder.go @@ -34,7 +34,7 @@ func Build(ctx sessionctx.Context, aggFuncDesc *aggregation.AggFuncDesc, ordinal case ast.AggFuncCount: return buildCount(aggFuncDesc, ordinal) case ast.AggFuncSum: - return buildSum(aggFuncDesc, ordinal) + return buildSum(ctx, aggFuncDesc, ordinal) case ast.AggFuncAvg: return buildAvg(aggFuncDesc, ordinal) case ast.AggFuncFirstRow: @@ -134,7 +134,7 @@ func buildCount(aggFuncDesc *aggregation.AggFuncDesc, ordinal int) AggFunc { } // buildSum builds the AggFunc implementation for function "SUM". -func buildSum(aggFuncDesc *aggregation.AggFuncDesc, ordinal int) AggFunc { +func buildSum(ctx sessionctx.Context, aggFuncDesc *aggregation.AggFuncDesc, ordinal int) AggFunc { base := baseSumAggFunc{ baseAggFunc: baseAggFunc{ args: aggFuncDesc.Args, @@ -155,7 +155,10 @@ func buildSum(aggFuncDesc *aggregation.AggFuncDesc, ordinal int) AggFunc { if aggFuncDesc.HasDistinct { return &sum4DistinctFloat64{base} } - return &sum4Float64{base} + if ctx.GetSessionVars().WindowingUseHighPrecision { + return &sum4Float64HighPrecision{baseSum4Float64{base}} + } + return &sum4Float64{baseSum4Float64{base}} } } } diff --git a/executor/aggfuncs/func_sum.go b/executor/aggfuncs/func_sum.go index 233ef5e178f21..26888c0cdca10 100644 --- a/executor/aggfuncs/func_sum.go +++ b/executor/aggfuncs/func_sum.go @@ -22,22 +22,24 @@ import ( ) type partialResult4SumFloat64 struct { - val float64 - isNull bool + val float64 + notNullRowCount int64 } type partialResult4SumDecimal struct { - val types.MyDecimal - isNull bool + val types.MyDecimal + notNullRowCount int64 } type partialResult4SumDistinctFloat64 struct { - partialResult4SumFloat64 + val float64 + isNull bool valSet set.Float64Set } type partialResult4SumDistinctDecimal struct { - partialResult4SumDecimal + val types.MyDecimal + isNull bool valSet set.StringSet } @@ -45,25 +47,24 @@ type baseSumAggFunc struct { baseAggFunc } -type sum4Float64 struct { +type baseSum4Float64 struct { baseSumAggFunc } -func (e *sum4Float64) AllocPartialResult() PartialResult { +func (e *baseSum4Float64) AllocPartialResult() PartialResult { p := new(partialResult4SumFloat64) - p.isNull = true return PartialResult(p) } -func (e *sum4Float64) ResetPartialResult(pr PartialResult) { +func (e *baseSum4Float64) ResetPartialResult(pr PartialResult) { p := (*partialResult4SumFloat64)(pr) p.val = 0 - p.isNull = true + p.notNullRowCount = 0 } -func (e *sum4Float64) AppendFinalResult2Chunk(sctx sessionctx.Context, pr PartialResult, chk *chunk.Chunk) error { +func (e *baseSum4Float64) AppendFinalResult2Chunk(sctx sessionctx.Context, pr PartialResult, chk *chunk.Chunk) error { p := (*partialResult4SumFloat64)(pr) - if p.isNull { + if p.notNullRowCount == 0 { chk.AppendNull(e.ordinal) return nil } @@ -71,7 +72,7 @@ func (e *sum4Float64) AppendFinalResult2Chunk(sctx sessionctx.Context, pr Partia return nil } -func (e *sum4Float64) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, pr PartialResult) error { +func (e *baseSum4Float64) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, pr PartialResult) error { p := (*partialResult4SumFloat64)(pr) for _, row := range rowsInGroup { input, isNull, err := e.args[0].EvalReal(sctx, row) @@ -81,44 +82,74 @@ func (e *sum4Float64) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup [ if isNull { continue } - if p.isNull { - p.val = input - p.isNull = false - continue - } p.val += input + p.notNullRowCount++ } return nil } -func (e *sum4Float64) MergePartialResult(sctx sessionctx.Context, src, dst PartialResult) error { +func (e *baseSum4Float64) MergePartialResult(sctx sessionctx.Context, src, dst PartialResult) error { p1, p2 := (*partialResult4SumFloat64)(src), (*partialResult4SumFloat64)(dst) - if p1.isNull { + if p1.notNullRowCount == 0 { return nil } p2.val += p1.val - p2.isNull = false + p2.notNullRowCount += p1.notNullRowCount + return nil +} + +type sum4Float64 struct { + baseSum4Float64 +} + +func (e *sum4Float64) Slide(sctx sessionctx.Context, rows []chunk.Row, lastStart, lastEnd uint64, shiftStart, shiftEnd uint64, pr PartialResult) error { + p := (*partialResult4SumFloat64)(pr) + for i := uint64(0); i < shiftEnd; i++ { + input, isNull, err := e.args[0].EvalReal(sctx, rows[lastEnd+i]) + if err != nil { + return err + } + if isNull { + continue + } + p.val += input + p.notNullRowCount++ + } + for i := uint64(0); i < shiftStart; i++ { + input, isNull, err := e.args[0].EvalReal(sctx, rows[lastStart+i]) + if err != nil { + return err + } + if isNull { + continue + } + p.val -= input + p.notNullRowCount-- + } return nil } +type sum4Float64HighPrecision struct { + baseSum4Float64 +} + type sum4Decimal struct { baseSumAggFunc } func (e *sum4Decimal) AllocPartialResult() PartialResult { p := new(partialResult4SumDecimal) - p.isNull = true return PartialResult(p) } func (e *sum4Decimal) ResetPartialResult(pr PartialResult) { p := (*partialResult4SumDecimal)(pr) - p.isNull = true + p.notNullRowCount = 0 } func (e *sum4Decimal) AppendFinalResult2Chunk(sctx sessionctx.Context, pr PartialResult, chk *chunk.Chunk) error { p := (*partialResult4SumDecimal)(pr) - if p.isNull { + if p.notNullRowCount == 0 { chk.AppendNull(e.ordinal) return nil } @@ -136,9 +167,9 @@ func (e *sum4Decimal) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup [ if isNull { continue } - if p.isNull { + if p.notNullRowCount == 0 { p.val = *input - p.isNull = false + p.notNullRowCount = 1 continue } @@ -148,13 +179,56 @@ func (e *sum4Decimal) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup [ return err } p.val = *newSum + p.notNullRowCount++ + } + return nil +} + +func (e *sum4Decimal) Slide(sctx sessionctx.Context, rows []chunk.Row, lastStart, lastEnd uint64, shiftStart, shiftEnd uint64, pr PartialResult) error { + p := (*partialResult4SumDecimal)(pr) + for i := uint64(0); i < shiftEnd; i++ { + input, isNull, err := e.args[0].EvalDecimal(sctx, rows[lastEnd+i]) + if err != nil { + return err + } + if isNull { + continue + } + if p.notNullRowCount == 0 { + p.val = *input + p.notNullRowCount = 1 + continue + } + newSum := new(types.MyDecimal) + err = types.DecimalAdd(&p.val, input, newSum) + if err != nil { + return err + } + p.val = *newSum + p.notNullRowCount++ + } + for i := uint64(0); i < shiftStart; i++ { + input, isNull, err := e.args[0].EvalDecimal(sctx, rows[lastStart+i]) + if err != nil { + return err + } + if isNull { + continue + } + newSum := new(types.MyDecimal) + err = types.DecimalSub(&p.val, input, newSum) + if err != nil { + return err + } + p.val = *newSum + p.notNullRowCount-- } return nil } func (e *sum4Decimal) MergePartialResult(sctx sessionctx.Context, src, dst PartialResult) error { p1, p2 := (*partialResult4SumDecimal)(src), (*partialResult4SumDecimal)(dst) - if p1.isNull { + if p1.notNullRowCount == 0 { return nil } newSum := new(types.MyDecimal) @@ -163,7 +237,7 @@ func (e *sum4Decimal) MergePartialResult(sctx sessionctx.Context, src, dst Parti return err } p2.val = *newSum - p2.isNull = false + p2.notNullRowCount += p1.notNullRowCount return nil } diff --git a/executor/analyze_test.go b/executor/analyze_test.go index e867344dcb448..e874dd8ef766f 100644 --- a/executor/analyze_test.go +++ b/executor/analyze_test.go @@ -334,14 +334,14 @@ func (s *testFastAnalyze) TestFastAnalyze(c *C) { tk.MustExec("insert into t1 values (1,1),(1,1),(1,2),(1,2)") tk.MustExec("analyze table t1") tk.MustQuery("explain select a from t1 where a = 1").Check(testkit.Rows( - "IndexReader_6 4.00 root index:IndexRangeScan_5", - "└─IndexRangeScan_5 4.00 cop[tikv] table:t1, index:a, b, range:[1,1], keep order:false")) + "IndexReader_6 4.00 root index:IndexRangeScan_5", + "└─IndexRangeScan_5 4.00 cop[tikv] table:t1, index:idx(a, b) range:[1,1], keep order:false")) tk.MustQuery("explain select a, b from t1 where a = 1 and b = 1").Check(testkit.Rows( - "IndexReader_6 2.00 root index:IndexRangeScan_5", - "└─IndexRangeScan_5 2.00 cop[tikv] table:t1, index:a, b, range:[1 1,1 1], keep order:false")) + "IndexReader_6 2.00 root index:IndexRangeScan_5", + "└─IndexRangeScan_5 2.00 cop[tikv] table:t1, index:idx(a, b) range:[1 1,1 1], keep order:false")) tk.MustQuery("explain select a, b from t1 where a = 1 and b = 2").Check(testkit.Rows( - "IndexReader_6 2.00 root index:IndexRangeScan_5", - "└─IndexRangeScan_5 2.00 cop[tikv] table:t1, index:a, b, range:[1 2,1 2], keep order:false")) + "IndexReader_6 2.00 root index:IndexRangeScan_5", + "└─IndexRangeScan_5 2.00 cop[tikv] table:t1, index:idx(a, b) range:[1 2,1 2], keep order:false")) tk.MustExec("create table t2 (a bigint unsigned, primary key(a))") tk.MustExec("insert into t2 values (0), (18446744073709551615)") diff --git a/executor/batch_point_get.go b/executor/batch_point_get.go index 0b9709ad39933..f4c3ad1bf0687 100644 --- a/executor/batch_point_get.go +++ b/executor/batch_point_get.go @@ -51,6 +51,25 @@ type BatchPointGetExec struct { rowDecoder *rowcodec.ChunkDecoder keepOrder bool desc bool + + columns []*model.ColumnInfo + // virtualColumnIndex records all the indices of virtual columns and sort them in definition + // to make sure we can compute the virtual column in right order. + virtualColumnIndex []int + + // virtualColumnRetFieldTypes records the RetFieldTypes of virtual columns. + virtualColumnRetFieldTypes []*types.FieldType +} + +// buildVirtualColumnInfo saves virtual column indices and sort them in definition order +func (e *BatchPointGetExec) buildVirtualColumnInfo() { + e.virtualColumnIndex = buildVirtualColumnIndex(e.Schema(), e.columns) + if len(e.virtualColumnIndex) > 0 { + e.virtualColumnRetFieldTypes = make([]*types.FieldType, len(e.virtualColumnIndex)) + for i, idx := range e.virtualColumnIndex { + e.virtualColumnRetFieldTypes[i] = e.schema.Columns[idx].RetType + } + } } // Open implements the Executor interface. @@ -83,6 +102,11 @@ func (e *BatchPointGetExec) Next(ctx context.Context, req *chunk.Chunk) error { } e.index++ } + + err := FillVirtualColumnValue(e.virtualColumnRetFieldTypes, e.virtualColumnIndex, e.schema, e.columns, e.ctx, req) + if err != nil { + return err + } return nil } diff --git a/executor/benchmark_test.go b/executor/benchmark_test.go index 8d72d23242d2c..2bf90342b0b3d 100644 --- a/executor/benchmark_test.go +++ b/executor/benchmark_test.go @@ -104,13 +104,15 @@ func (mds *mockDataSource) genColDatums(col int) (results []interface{}) { NDV = mds.p.ndvs[col] } results = make([]interface{}, 0, rows) - if mds.p.genDataFunc != nil { - for i := 0; i < rows; i++ { - results = append(results, mds.p.genDataFunc(i, typ)) - } - } else if NDV == 0 { - for i := 0; i < rows; i++ { - results = append(results, mds.randDatum(typ)) + if NDV == 0 { + if mds.p.genDataFunc == nil { + for i := 0; i < rows; i++ { + results = append(results, mds.randDatum(typ)) + } + } else { + for i := 0; i < rows; i++ { + results = append(results, mds.p.genDataFunc(i, typ)) + } } } else { datumSet := make(map[string]bool, NDV) @@ -152,8 +154,11 @@ func (mds *mockDataSource) randDatum(typ *types.FieldType) interface{} { switch typ.Tp { case mysql.TypeLong, mysql.TypeLonglong: return int64(rand.Int()) - case mysql.TypeDouble: + case mysql.TypeDouble, mysql.TypeFloat: return rand.Float64() + case mysql.TypeNewDecimal: + var d types.MyDecimal + return d.FromInt(int64(rand.Int())) case mysql.TypeVarString: buff := make([]byte, 10) rand.Read(buff) @@ -185,9 +190,9 @@ func (mds *mockDataSource) Next(ctx context.Context, req *chunk.Chunk) error { func buildMockDataSource(opt mockDataSourceParameters) *mockDataSource { baseExec := newBaseExecutor(opt.ctx, opt.schema, nil) m := &mockDataSource{baseExec, opt, nil, nil, 0} - types := retTypes(m) - colData := make([][]interface{}, len(types)) - for i := 0; i < len(types); i++ { + rTypes := retTypes(m) + colData := make([][]interface{}, len(rTypes)) + for i := 0; i < len(rTypes); i++ { colData[i] = m.genColDatums(i) } @@ -199,12 +204,14 @@ func buildMockDataSource(opt mockDataSourceParameters) *mockDataSource { for i := 0; i < m.p.rows; i++ { idx := i / m.maxChunkSize retTypes := retTypes(m) - for colIdx := 0; colIdx < len(types); colIdx++ { + for colIdx := 0; colIdx < len(rTypes); colIdx++ { switch retTypes[colIdx].Tp { case mysql.TypeLong, mysql.TypeLonglong: m.genData[idx].AppendInt64(colIdx, colData[colIdx][i].(int64)) - case mysql.TypeDouble: + case mysql.TypeDouble, mysql.TypeFloat: m.genData[idx].AppendFloat64(colIdx, colData[colIdx][i].(float64)) + case mysql.TypeNewDecimal: + m.genData[idx].AppendMyDecimal(colIdx, colData[colIdx][i].(*types.MyDecimal)) case mysql.TypeVarString: m.genData[idx].AppendString(colIdx, colData[colIdx][i].(string)) default: @@ -509,27 +516,25 @@ type windowTestCase struct { dataSourceSorted bool ctx sessionctx.Context rawDataSmall string -} - -func (a windowTestCase) columns() []*expression.Column { - return []*expression.Column{ - {Index: 0, RetType: types.NewFieldType(mysql.TypeDouble)}, - {Index: 1, RetType: types.NewFieldType(mysql.TypeLonglong)}, - {Index: 2, RetType: types.NewFieldType(mysql.TypeVarString)}, - {Index: 3, RetType: types.NewFieldType(mysql.TypeLonglong)}, - } + columns []*expression.Column // the columns of mock schema } func (a windowTestCase) String() string { - return fmt.Sprintf("(func:%v, numFunc:%v, ndv:%v, rows:%v, sorted:%v, concurrency:%v)", - a.windowFunc, a.numFunc, a.ndv, a.rows, a.dataSourceSorted, a.concurrency) + return fmt.Sprintf("(func:%v, aggColType:%s, numFunc:%v, ndv:%v, rows:%v, sorted:%v, concurrency:%v)", + a.windowFunc, a.columns[0].RetType, a.numFunc, a.ndv, a.rows, a.dataSourceSorted, a.concurrency) } func defaultWindowTestCase() *windowTestCase { ctx := mock.NewContext() ctx.GetSessionVars().InitChunkSize = variable.DefInitChunkSize ctx.GetSessionVars().MaxChunkSize = variable.DefMaxChunkSize - return &windowTestCase{ast.WindowFuncRowNumber, 1, nil, 1000, 10000000, 1, true, ctx, strings.Repeat("x", 16)} + return &windowTestCase{ast.WindowFuncRowNumber, 1, nil, 1000, 10000000, 1, true, ctx, strings.Repeat("x", 16), + []*expression.Column{ + {Index: 0, RetType: types.NewFieldType(mysql.TypeDouble)}, + {Index: 1, RetType: types.NewFieldType(mysql.TypeLonglong)}, + {Index: 2, RetType: types.NewFieldType(mysql.TypeVarString)}, + {Index: 3, RetType: types.NewFieldType(mysql.TypeLonglong)}, + }} } func benchmarkWindowExecWithCase(b *testing.B, casTest *windowTestCase) { @@ -538,29 +543,19 @@ func benchmarkWindowExecWithCase(b *testing.B, casTest *windowTestCase) { b.Fatal(err) } - cols := casTest.columns() + cols := casTest.columns dataSource := buildMockDataSource(mockDataSourceParameters{ schema: expression.NewSchema(cols...), ndvs: []int{0, casTest.ndv, 0, 0}, orders: []bool{false, casTest.dataSourceSorted, false, false}, rows: casTest.rows, ctx: casTest.ctx, - genDataFunc: func(row int, typ *types.FieldType) interface{} { - switch typ.Tp { - case mysql.TypeLong, mysql.TypeLonglong: - return int64(row) - case mysql.TypeVarString: - return casTest.rawDataSmall - default: - panic("not implement") - } - }, }) b.ResetTimer() for i := 0; i < b.N; i++ { b.StopTimer() // prepare a new window-executor - childCols := casTest.columns() + childCols := casTest.columns schema := expression.NewSchema(childCols...) windowExec := buildWindowExecutor(casTest.ctx, casTest.windowFunc, casTest.numFunc, casTest.frame, dataSource, schema, childCols[1:2], casTest.concurrency, casTest.dataSourceSorted) tmpCtx := context.Background() @@ -675,35 +670,42 @@ func BenchmarkWindowFunctionsWithFrame(b *testing.B) { } } -func BenchmarkWindowFunctionsWithSlidingWindow(b *testing.B) { +func baseBenchmarkWindowFunctionsWithSlidingWindow(b *testing.B, frameType ast.FrameType) { b.ReportAllocs() - windowFuncs := []string{ - ast.AggFuncCount, - } - rows := []int{1000, 100000} - ndvs := []int{10, 1000} - frames := []*core.WindowFrame{ - {Type: ast.Rows, Start: &core.FrameBound{Type: ast.Preceding, Num: 10}, End: &core.FrameBound{Type: ast.Following, Num: 10}}, - {Type: ast.Rows, Start: &core.FrameBound{Type: ast.Preceding, Num: 100}, End: &core.FrameBound{Type: ast.Following, Num: 100}}, + windowFuncs := []struct { + aggFunc string + aggColTypes byte + }{ + {ast.AggFuncSum, mysql.TypeFloat}, + {ast.AggFuncSum, mysql.TypeNewDecimal}, + {ast.AggFuncCount, mysql.TypeLong}, + } + row := 100000 + ndv := 100 + frame := &core.WindowFrame{ + Type: frameType, + Start: &core.FrameBound{Type: ast.Preceding, Num: 10}, + End: &core.FrameBound{Type: ast.Following, Num: 10}, } - for _, row := range rows { - for _, ndv := range ndvs { - for _, frame := range frames { - for _, windowFunc := range windowFuncs { - cas := defaultWindowTestCase() - cas.rows = row - cas.ndv = ndv - cas.windowFunc = windowFunc - cas.frame = frame - b.Run(fmt.Sprintf("%v", cas), func(b *testing.B) { - benchmarkWindowExecWithCase(b, cas) - }) - } - } - } + for _, windowFunc := range windowFuncs { + cas := defaultWindowTestCase() + cas.ctx.GetSessionVars().WindowingUseHighPrecision = false + cas.rows = row + cas.ndv = ndv + cas.windowFunc = windowFunc.aggFunc + cas.frame = frame + cas.columns[0].RetType.Tp = windowFunc.aggColTypes + b.Run(fmt.Sprintf("%v", cas), func(b *testing.B) { + benchmarkWindowExecWithCase(b, cas) + }) } } +func BenchmarkWindowFunctionsWithSlidingWindow(b *testing.B) { + baseBenchmarkWindowFunctionsWithSlidingWindow(b, ast.Rows) + baseBenchmarkWindowFunctionsWithSlidingWindow(b, ast.Ranges) +} + type hashJoinTestCase struct { rows int cols []*types.FieldType diff --git a/executor/builder.go b/executor/builder.go index dd6baef5b59ab..29fb65e3c4e48 100644 --- a/executor/builder.go +++ b/executor/builder.go @@ -1422,20 +1422,26 @@ func (b *executorBuilder) buildMemTable(v *plannercore.PhysicalMemTable) Executo strings.ToLower(infoschema.TableTiDBIndexes), strings.ToLower(infoschema.TableViews), strings.ToLower(infoschema.TableTables), + strings.ToLower(infoschema.TableColumns), + strings.ToLower(infoschema.TableSequences), strings.ToLower(infoschema.TablePartitions), strings.ToLower(infoschema.TableEngines), strings.ToLower(infoschema.TableCollations), strings.ToLower(infoschema.TableAnalyzeStatus), strings.ToLower(infoschema.TableClusterInfo), + strings.ToLower(infoschema.TableProfiling), strings.ToLower(infoschema.TableCharacterSets), strings.ToLower(infoschema.TableKeyColumn), strings.ToLower(infoschema.TableUserPrivileges), strings.ToLower(infoschema.TableMetricTables), strings.ToLower(infoschema.TableCollationCharacterSetApplicability), + strings.ToLower(infoschema.TableProcesslist), + strings.ToLower(infoschema.ClusterTableProcesslist), strings.ToLower(infoschema.TableTiKVRegionPeers), strings.ToLower(infoschema.TableTiDBHotRegions), strings.ToLower(infoschema.TableSessionVar), strings.ToLower(infoschema.TableConstraints), + strings.ToLower(infoschema.TableTiFlashReplica), strings.ToLower(infoschema.TableTiDBServersInfo): return &MemTableReaderExec{ baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ExplainID()), @@ -1455,6 +1461,11 @@ func (b *executorBuilder) buildMemTable(v *plannercore.PhysicalMemTable) Executo extractor: v.Extractor.(*plannercore.SlowQueryExtractor), }, } + case strings.ToLower(infoschema.TableDDLJobs): + return &DDLJobsReaderExec{ + baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ExplainID()), + is: b.is, + } } } tb, _ := b.is.TableByID(v.Table.ID) @@ -1677,6 +1688,9 @@ func (b *executorBuilder) updateForUpdateTSIfNeeded(selectPlan plannercore.Physi // refreshForUpdateTSForRC is used to refresh the for-update-ts for reading data at read consistency level in pessimistic transaction. // It could use the cached tso from the statement future to avoid get tso many times. func (b *executorBuilder) refreshForUpdateTSForRC() error { + defer func() { + b.snapshotTS = b.ctx.GetSessionVars().TxnCtx.GetForUpdateTS() + }() future := b.ctx.GetSessionVars().TxnCtx.GetStmtFutureForRC() if future == nil { return nil @@ -1689,11 +1703,7 @@ func (b *executorBuilder) refreshForUpdateTSForRC() error { } b.ctx.GetSessionVars().TxnCtx.SetStmtFutureForRC(nil) // If newForUpdateTS is 0, it will force to get a new for-update-ts from PD. - if err := UpdateForUpdateTS(b.ctx, newForUpdateTS); err != nil { - return err - } - b.snapshotTS = b.ctx.GetSessionVars().TxnCtx.GetForUpdateTS() - return nil + return UpdateForUpdateTS(b.ctx, newForUpdateTS) } func (b *executorBuilder) buildAnalyzeIndexPushdown(task plannercore.AnalyzeIndexTask, opts map[ast.AnalyzeOptionType]uint64, autoAnalyze string) *analyzeTask { @@ -2901,14 +2911,19 @@ func newRowDecoder(ctx sessionctx.Context, schema *expression.Schema, tbl *model if isPK { handleColID = col.ID } + isGeneratedCol := false + if col.VirtualExpr != nil { + isGeneratedCol = true + } reqCols[idx] = rowcodec.ColInfo{ - ID: col.ID, - Tp: int32(col.RetType.Tp), - Flag: int32(col.RetType.Flag), - Flen: col.RetType.Flen, - Decimal: col.RetType.Decimal, - Elems: col.RetType.Elems, - Collate: col.GetType().Collate, + ID: col.ID, + Tp: int32(col.RetType.Tp), + Flag: int32(col.RetType.Flag), + Flen: col.RetType.Flen, + Decimal: col.RetType.Decimal, + Elems: col.RetType.Elems, + Collate: col.GetType().Collate, + VirtualGenCol: isGeneratedCol, } } defVal := func(i int, chk *chunk.Chunk) error { @@ -2947,6 +2962,7 @@ func (b *executorBuilder) buildBatchPointGet(plan *plannercore.BatchPointGetPlan lock: plan.Lock, waitTime: plan.LockWaitTime, partPos: plan.PartitionColPos, + columns: plan.Columns, } if e.lock { b.hasLock = true @@ -2971,6 +2987,7 @@ func (b *executorBuilder) buildBatchPointGet(plan *plannercore.BatchPointGetPlan } e.base().initCap = capacity e.base().maxChunkSize = capacity + e.buildVirtualColumnInfo() return e } diff --git a/executor/ddl.go b/executor/ddl.go index 1b058737fb517..dfa4abc5d84c9 100644 --- a/executor/ddl.go +++ b/executor/ddl.go @@ -426,8 +426,8 @@ func (e *DDLExec) getRecoverTableByJobID(s *ast.RecoverTableStmt, t *meta.Meta, if job == nil { return nil, nil, admin.ErrDDLJobNotFound.GenWithStackByArgs(s.JobID) } - if job.Type != model.ActionDropTable { - return nil, nil, errors.Errorf("Job %v type is %v, not drop table", job.ID, job.Type) + if job.Type != model.ActionDropTable && job.Type != model.ActionTruncateTable { + return nil, nil, errors.Errorf("Job %v type is %v, not dropped/truncated table", job.ID, job.Type) } // Check GC safe point for getting snapshot infoSchema. diff --git a/executor/executor.go b/executor/executor.go index 91f4ef7f9c79d..44ad0dab44178 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -18,6 +18,7 @@ import ( "fmt" "runtime" "strconv" + "strings" "sync" "sync/atomic" "time" @@ -26,6 +27,7 @@ import ( "github.com/opentracing/opentracing-go" "github.com/pingcap/errors" "github.com/pingcap/parser/ast" + "github.com/pingcap/parser/auth" "github.com/pingcap/parser/model" "github.com/pingcap/parser/mysql" "github.com/pingcap/parser/terror" @@ -38,6 +40,7 @@ import ( "github.com/pingcap/tidb/meta" "github.com/pingcap/tidb/meta/autoid" plannercore "github.com/pingcap/tidb/planner/core" + "github.com/pingcap/tidb/privilege" "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/stmtctx" "github.com/pingcap/tidb/sessionctx/variable" @@ -329,14 +332,79 @@ func (e *ShowDDLExec) Next(ctx context.Context, req *chunk.Chunk) error { // ShowDDLJobsExec represent a show DDL jobs executor. type ShowDDLJobsExec struct { baseExecutor + DDLJobRetriever - cursor int + jobNumber int + is infoschema.InfoSchema + done bool +} + +// DDLJobRetriever retrieve the DDLJobs. +type DDLJobRetriever struct { runningJobs []*model.Job historyJobIter *meta.LastJobIterator - cacheJobs []*model.Job - jobNumber int + cursor int is infoschema.InfoSchema - done bool + activeRoles []*auth.RoleIdentity + cacheJobs []*model.Job +} + +func (e *DDLJobRetriever) initial(txn kv.Transaction) error { + jobs, err := admin.GetDDLJobs(txn) + if err != nil { + return err + } + m := meta.NewMeta(txn) + e.historyJobIter, err = m.GetLastHistoryDDLJobsIterator() + if err != nil { + return err + } + e.runningJobs = jobs + e.cursor = 0 + return nil +} + +func (e *DDLJobRetriever) appendJobToChunk(req *chunk.Chunk, job *model.Job, checker privilege.Manager) { + schemaName := job.SchemaName + tableName := "" + finishTS := uint64(0) + if job.BinlogInfo != nil { + finishTS = job.BinlogInfo.FinishedTS + if job.BinlogInfo.TableInfo != nil { + tableName = job.BinlogInfo.TableInfo.Name.L + } + if len(schemaName) == 0 && job.BinlogInfo.DBInfo != nil { + schemaName = job.BinlogInfo.DBInfo.Name.L + } + } + // For compatibility, the old version of DDL Job wasn't store the schema name and table name. + if len(schemaName) == 0 { + schemaName = getSchemaName(e.is, job.SchemaID) + } + if len(tableName) == 0 { + tableName = getTableName(e.is, job.TableID) + } + + // Check the privilege. + if checker != nil && !checker.RequestVerification(e.activeRoles, strings.ToLower(schemaName), strings.ToLower(tableName), "", mysql.AllPrivMask) { + return + } + + req.AppendInt64(0, job.ID) + req.AppendString(1, schemaName) + req.AppendString(2, tableName) + req.AppendString(3, job.Type.String()) + req.AppendString(4, job.SchemaState.String()) + req.AppendInt64(5, job.SchemaID) + req.AppendInt64(6, job.TableID) + req.AppendInt64(7, job.RowCount) + req.AppendString(8, model.TSConvert2Time(job.StartTS).String()) + if finishTS > 0 { + req.AppendString(9, model.TSConvert2Time(finishTS).String()) + } else { + req.AppendString(9, "") + } + req.AppendString(10, job.State.String()) } // ShowDDLJobQueriesExec represents a show DDL job queries executor. @@ -404,21 +472,14 @@ func (e *ShowDDLJobsExec) Open(ctx context.Context) error { if err != nil { return err } - jobs, err := admin.GetDDLJobs(txn) - if err != nil { - return err - } + e.DDLJobRetriever.is = e.is if e.jobNumber == 0 { e.jobNumber = admin.DefNumHistoryJobs } - - m := meta.NewMeta(txn) - e.historyJobIter, err = m.GetLastHistoryDDLJobsIterator() + err = e.DDLJobRetriever.initial(txn) if err != nil { return err } - e.runningJobs = append(e.runningJobs, jobs...) - e.cursor = 0 return nil } @@ -429,17 +490,19 @@ func (e *ShowDDLJobsExec) Next(ctx context.Context, req *chunk.Chunk) error { return nil } count := 0 + // Append running ddl jobs. if e.cursor < len(e.runningJobs) { numCurBatch := mathutil.Min(req.Capacity(), len(e.runningJobs)-e.cursor) for i := e.cursor; i < e.cursor+numCurBatch; i++ { - e.appendJobToChunk(req, e.runningJobs[i]) + e.appendJobToChunk(req, e.runningJobs[i], nil) } e.cursor += numCurBatch count += numCurBatch } - var err error + // Append history ddl jobs. + var err error if count < req.Capacity() { num := req.Capacity() - count remainNum := e.jobNumber - (e.cursor - len(e.runningJobs)) @@ -449,50 +512,13 @@ func (e *ShowDDLJobsExec) Next(ctx context.Context, req *chunk.Chunk) error { return err } for _, job := range e.cacheJobs { - e.appendJobToChunk(req, job) + e.appendJobToChunk(req, job, nil) } e.cursor += len(e.cacheJobs) } return nil } -func (e *ShowDDLJobsExec) appendJobToChunk(req *chunk.Chunk, job *model.Job) { - req.AppendInt64(0, job.ID) - schemaName := job.SchemaName - tableName := "" - finishTS := uint64(0) - if job.BinlogInfo != nil { - finishTS = job.BinlogInfo.FinishedTS - if job.BinlogInfo.TableInfo != nil { - tableName = job.BinlogInfo.TableInfo.Name.L - } - if len(schemaName) == 0 && job.BinlogInfo.DBInfo != nil { - schemaName = job.BinlogInfo.DBInfo.Name.L - } - } - // For compatibility, the old version of DDL Job wasn't store the schema name and table name. - if len(schemaName) == 0 { - schemaName = getSchemaName(e.is, job.SchemaID) - } - if len(tableName) == 0 { - tableName = getTableName(e.is, job.TableID) - } - req.AppendString(1, schemaName) - req.AppendString(2, tableName) - req.AppendString(3, job.Type.String()) - req.AppendString(4, job.SchemaState.String()) - req.AppendInt64(5, job.SchemaID) - req.AppendInt64(6, job.TableID) - req.AppendInt64(7, job.RowCount) - req.AppendString(8, model.TSConvert2Time(job.StartTS).String()) - if finishTS > 0 { - req.AppendString(9, model.TSConvert2Time(finishTS).String()) - } else { - req.AppendString(9, "") - } - req.AppendString(10, job.State.String()) -} - func getSchemaName(is infoschema.InfoSchema, id int64) string { var schemaName string DBInfo, ok := is.SchemaByID(id) @@ -1608,3 +1634,28 @@ func ResetContextOfStmt(ctx sessionctx.Context, s ast.StmtNode) (err error) { vars.StmtCtx = sc return } + +// FillVirtualColumnValue will calculate the virtual column value by evaluating generated +// expression using rows from a chunk, and then fill this value into the chunk +func FillVirtualColumnValue(virtualRetTypes []*types.FieldType, virtualColumnIndex []int, + schema *expression.Schema, columns []*model.ColumnInfo, sctx sessionctx.Context, req *chunk.Chunk) error { + virCols := chunk.NewChunkWithCapacity(virtualRetTypes, req.Capacity()) + iter := chunk.NewIterator4Chunk(req) + for i, idx := range virtualColumnIndex { + for row := iter.Begin(); row != iter.End(); row = iter.Next() { + datum, err := schema.Columns[idx].EvalVirtualColumn(row) + if err != nil { + return err + } + // Because the expression might return different type from + // the generated column, we should wrap a CAST on the result. + castDatum, err := table.CastValue(sctx, datum, columns[idx]) + if err != nil { + return err + } + virCols.AppendDatum(i, &castDatum) + } + req.SetCol(idx, virCols.Column(i)) + } + return nil +} diff --git a/executor/executor_test.go b/executor/executor_test.go index cb1ae583ca8c1..9841c6edcedd4 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -88,6 +88,7 @@ func TestT(t *testing.T) { old := config.GetGlobalConfig() new := *old new.Log.SlowThreshold = 30000 // 30s + new.Experimental.AllowsExpressionIndex = true config.StoreGlobalConfig(&new) testleak.BeforeTest() @@ -1911,6 +1912,35 @@ func (s *testSuiteP1) TestGeneratedColumnRead(c *C) { } } +// TestGeneratedColumnRead tests generated columns using point get and batch point get +func (s *testSuiteP1) TestGeneratedColumnPointGet(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists tu") + tk.MustExec("CREATE TABLE tu(a int, b int, c int GENERATED ALWAYS AS (a + b) VIRTUAL, d int as (a * b) stored, " + + "e int GENERATED ALWAYS as (b * 2) VIRTUAL, PRIMARY KEY (a), UNIQUE KEY ukc (c), unique key ukd(d), key ke(e))") + tk.MustExec("insert into tu(a, b) values(1, 2)") + tk.MustExec("insert into tu(a, b) values(5, 6)") + tk.MustQuery("select * from tu for update").Check(testkit.Rows("1 2 3 2 4", "5 6 11 30 12")) + tk.MustQuery("select * from tu where a = 1").Check(testkit.Rows("1 2 3 2 4")) + tk.MustQuery("select * from tu where a in (1, 2)").Check(testkit.Rows("1 2 3 2 4")) + tk.MustQuery("select * from tu where c in (1, 2, 3)").Check(testkit.Rows("1 2 3 2 4")) + tk.MustQuery("select * from tu where c = 3").Check(testkit.Rows("1 2 3 2 4")) + tk.MustQuery("select d, e from tu where c = 3").Check(testkit.Rows("2 4")) + tk.MustQuery("select * from tu where d in (1, 2, 3)").Check(testkit.Rows("1 2 3 2 4")) + tk.MustQuery("select * from tu where d = 2").Check(testkit.Rows("1 2 3 2 4")) + tk.MustQuery("select c, d from tu where d = 2").Check(testkit.Rows("3 2")) + tk.MustQuery("select d, e from tu where e = 4").Check(testkit.Rows("2 4")) + tk.MustQuery("select * from tu where e = 4").Check(testkit.Rows("1 2 3 2 4")) + tk.MustExec("update tu set a = a + 1, b = b + 1 where c = 11") + tk.MustQuery("select * from tu for update").Check(testkit.Rows("1 2 3 2 4", "6 7 13 42 14")) + tk.MustQuery("select * from tu where a = 6").Check(testkit.Rows("6 7 13 42 14")) + tk.MustQuery("select * from tu where c in (5, 6, 13)").Check(testkit.Rows("6 7 13 42 14")) + tk.MustQuery("select b, c, e, d from tu where c = 13").Check(testkit.Rows("7 13 14 42")) + tk.MustQuery("select a, e, d from tu where c in (5, 6, 13)").Check(testkit.Rows("6 14 42")) + tk.MustExec("drop table if exists tu") +} + func (s *testSuiteP2) TestToPBExpr(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") @@ -4439,7 +4469,8 @@ func (s *testSuiteP2) TestUnsignedFeedback(c *C) { tk.MustExec("analyze table t") tk.MustQuery("select count(distinct b) from t").Check(testkit.Rows("2")) result := tk.MustQuery("explain analyze select count(distinct b) from t") - c.Assert(result.Rows()[2][4], Equals, "table:t, range:[0,+inf], keep order:false") + c.Assert(result.Rows()[2][4], Equals, "table:t") + c.Assert(result.Rows()[2][6], Equals, "range:[0,+inf], keep order:false") } func (s *testSuite) TestOOMPanicAction(c *C) { @@ -4638,6 +4669,13 @@ func (s *testRecoverTable) TestRecoverTable(c *C) { tk.MustExec("insert into t_recover values (7),(8),(9)") tk.MustQuery("select * from t_recover;").Check(testkit.Rows("1", "7", "8", "9")) + // Recover truncate table. + tk.MustExec("truncate table t_recover") + tk.MustExec("rename table t_recover to t_recover_new") + tk.MustExec("recover table t_recover") + tk.MustExec("insert into t_recover values (10)") + tk.MustQuery("select * from t_recover;").Check(testkit.Rows("1", "7", "8", "9", "10")) + gcEnable, err := gcutil.CheckGCEnable(tk.Se) c.Assert(err, IsNil) c.Assert(gcEnable, Equals, false) diff --git a/executor/explainfor_test.go b/executor/explainfor_test.go index 91eebd87163f5..306ddc65f4593 100644 --- a/executor/explainfor_test.go +++ b/executor/explainfor_test.go @@ -70,8 +70,8 @@ func (s *testSuite) TestExplainFor(c *C) { tkRoot.Se.SetSessionManager(&mockSessionManager1{PS: ps}) tkUser.Se.SetSessionManager(&mockSessionManager1{PS: ps}) tkRoot.MustQuery(fmt.Sprintf("explain for connection %d", tkRootProcess.ID)).Check(testkit.Rows( - "TableReader_5 10000.00 root data:TableFullScan_4", - "└─TableFullScan_4 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", + "TableReader_5 10000.00 root data:TableFullScan_4", + "└─TableFullScan_4 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", )) err := tkUser.ExecToErr(fmt.Sprintf("explain for connection %d", tkRootProcess.ID)) c.Check(core.ErrAccessDenied.Equal(err), IsTrue) @@ -109,7 +109,13 @@ func (s *testSuite) TestIssue11124(c *C) { func (s *testSuite) TestExplainMetricTable(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk.MustQuery(fmt.Sprintf("desc select * from METRICS_SCHEMA.tidb_query_duration where time >= '2019-12-23 16:10:13' and time <= '2019-12-23 16:30:13' ")).Check(testkit.Rows( - "MemTableScan_5 10000.00 root table:tidb_query_duration, PromQL:histogram_quantile(0.9, sum(rate(tidb_server_handle_query_duration_seconds_bucket{}[60s])) by (le,sql_type,instance)), start_time:2019-12-23 16:10:13, end_time:2019-12-23 16:30:13, step:1m0s")) + "MemTableScan_5 10000.00 root table:tidb_query_duration PromQL:histogram_quantile(0.9, sum(rate(tidb_server_handle_query_duration_seconds_bucket{}[60s])) by (le,sql_type,instance)), start_time:2019-12-23 16:10:13, end_time:2019-12-23 16:30:13, step:1m0s")) tk.MustQuery(fmt.Sprintf("desc select * from METRICS_SCHEMA.up where time >= '2019-12-23 16:10:13' and time <= '2019-12-23 16:30:13' ")).Check(testkit.Rows( - "MemTableScan_5 10000.00 root table:up, PromQL:up{}, start_time:2019-12-23 16:10:13, end_time:2019-12-23 16:30:13, step:1m0s")) + "MemTableScan_5 10000.00 root table:up PromQL:up{}, start_time:2019-12-23 16:10:13, end_time:2019-12-23 16:30:13, step:1m0s")) + tk.MustQuery("desc select * from information_schema.cluster_log where time >= '2019-12-23 16:10:13' and time <= '2019-12-23 16:30:13'").Check(testkit.Rows( + "MemTableScan_5 10000.00 root table:CLUSTER_LOG start_time:2019-12-23 16:10:13, end_time:2019-12-23 16:30:13")) + tk.MustQuery("desc select * from information_schema.cluster_log where level in ('warn','error') and time >= '2019-12-23 16:10:13' and time <= '2019-12-23 16:30:13'").Check(testkit.Rows( + `MemTableScan_5 10000.00 root table:CLUSTER_LOG start_time:2019-12-23 16:10:13, end_time:2019-12-23 16:30:13, log_levels:["error","warn"]`)) + tk.MustQuery("desc select * from information_schema.cluster_log where type in ('high_cpu_1','high_memory_1') and time >= '2019-12-23 16:10:13' and time <= '2019-12-23 16:30:13'").Check(testkit.Rows( + `MemTableScan_5 10000.00 root table:CLUSTER_LOG start_time:2019-12-23 16:10:13, end_time:2019-12-23 16:30:13, node_types:["high_cpu_1","high_memory_1"]`)) } diff --git a/executor/infoschema_reader.go b/executor/infoschema_reader.go index 2dd588e4386b1..a688b4f2ac1de 100644 --- a/executor/infoschema_reader.go +++ b/executor/infoschema_reader.go @@ -21,6 +21,7 @@ import ( "sync" "time" + "github.com/cznic/mathutil" "github.com/pingcap/errors" "github.com/pingcap/parser/charset" "github.com/pingcap/parser/model" @@ -34,8 +35,11 @@ import ( "github.com/pingcap/tidb/statistics" "github.com/pingcap/tidb/store/helper" "github.com/pingcap/tidb/store/tikv" + "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util" + "github.com/pingcap/tidb/util/chunk" + "github.com/pingcap/tidb/util/collate" "github.com/pingcap/tidb/util/pdapi" "github.com/pingcap/tidb/util/set" "github.com/pingcap/tidb/util/sqlexec" @@ -70,6 +74,10 @@ func (e *memtableRetriever) retrieve(ctx context.Context, sctx sessionctx.Contex e.setDataForStatistics(sctx, dbs) case infoschema.TableTables: err = e.setDataFromTables(sctx, dbs) + case infoschema.TableColumns: + e.setDataForColumns(sctx, dbs) + case infoschema.TableSequences: + e.setDataFromSequences(sctx, dbs) case infoschema.TablePartitions: err = e.setDataFromPartitions(sctx, dbs) case infoschema.TableClusterInfo: @@ -90,8 +98,14 @@ func (e *memtableRetriever) retrieve(ctx context.Context, sctx sessionctx.Contex e.setDataFromKeyColumnUsage(sctx, dbs) case infoschema.TableMetricTables: e.setDataForMetricTables(sctx) + case infoschema.TableProfiling: + e.setDataForPseudoProfiling(sctx) case infoschema.TableCollationCharacterSetApplicability: e.dataForCollationCharacterSetApplicability() + case infoschema.TableProcesslist: + e.setDataForProcessList(sctx) + case infoschema.ClusterTableProcesslist: + err = e.setDataForClusterProcessList(sctx) case infoschema.TableUserPrivileges: e.setDataFromUserPrivileges(sctx) case infoschema.TableTiKVRegionPeers: @@ -104,6 +118,8 @@ func (e *memtableRetriever) retrieve(ctx context.Context, sctx sessionctx.Contex err = e.setDataFromSessionVar(sctx) case infoschema.TableTiDBServersInfo: err = e.setDataForServersInfo() + case infoschema.TableTiFlashReplica: + e.dataForTableTiFlashReplica(sctx, dbs) } if err != nil { return nil, err @@ -405,6 +421,10 @@ func (e *memtableRetriever) setDataFromTables(ctx sessionctx.Context, schemas [] createOptions := "" + if table.IsSequence() { + continue + } + if checker != nil && !checker.RequestVerification(ctx.GetSessionVars().ActiveRoles, schema.Name.L, table.Name.L, "", mysql.AllPrivMask) { continue } @@ -507,6 +527,109 @@ func (e *memtableRetriever) setDataFromTables(ctx sessionctx.Context, schemas [] return nil } +func (e *memtableRetriever) setDataForColumns(ctx sessionctx.Context, schemas []*model.DBInfo) { + checker := privilege.GetPrivilegeManager(ctx) + var rows [][]types.Datum + for _, schema := range schemas { + for _, table := range schema.Tables { + if checker != nil && !checker.RequestVerification(ctx.GetSessionVars().ActiveRoles, schema.Name.L, table.Name.L, "", mysql.AllPrivMask) { + continue + } + + rs := e.dataForColumnsInTable(schema, table) + rows = append(rows, rs...) + } + } + e.rows = rows +} + +func (e *memtableRetriever) dataForColumnsInTable(schema *model.DBInfo, tbl *model.TableInfo) [][]types.Datum { + rows := make([][]types.Datum, 0, len(tbl.Columns)) + for i, col := range tbl.Columns { + if col.Hidden { + continue + } + var charMaxLen, charOctLen, numericPrecision, numericScale, datetimePrecision interface{} + colLen, decimal := col.Flen, col.Decimal + defaultFlen, defaultDecimal := mysql.GetDefaultFieldLengthAndDecimal(col.Tp) + if decimal == types.UnspecifiedLength { + decimal = defaultDecimal + } + if colLen == types.UnspecifiedLength { + colLen = defaultFlen + } + if col.Tp == mysql.TypeSet { + // Example: In MySQL set('a','bc','def','ghij') has length 13, because + // len('a')+len('bc')+len('def')+len('ghij')+len(ThreeComma)=13 + // Reference link: https://bugs.mysql.com/bug.php?id=22613 + colLen = 0 + for _, ele := range col.Elems { + colLen += len(ele) + } + if len(col.Elems) != 0 { + colLen += (len(col.Elems) - 1) + } + charMaxLen = colLen + charOctLen = colLen + } else if col.Tp == mysql.TypeEnum { + // Example: In MySQL enum('a', 'ab', 'cdef') has length 4, because + // the longest string in the enum is 'cdef' + // Reference link: https://bugs.mysql.com/bug.php?id=22613 + colLen = 0 + for _, ele := range col.Elems { + if len(ele) > colLen { + colLen = len(ele) + } + } + charMaxLen = colLen + charOctLen = colLen + } else if types.IsString(col.Tp) { + charMaxLen = colLen + charOctLen = colLen + } else if types.IsTypeFractionable(col.Tp) { + datetimePrecision = decimal + } else if types.IsTypeNumeric(col.Tp) { + numericPrecision = colLen + if col.Tp != mysql.TypeFloat && col.Tp != mysql.TypeDouble { + numericScale = decimal + } else if decimal != -1 { + numericScale = decimal + } + } + columnType := col.FieldType.InfoSchemaStr() + columnDesc := table.NewColDesc(table.ToColumn(col)) + var columnDefault interface{} + if columnDesc.DefaultValue != nil { + columnDefault = fmt.Sprintf("%v", columnDesc.DefaultValue) + } + record := types.MakeDatums( + infoschema.CatalogVal, // TABLE_CATALOG + schema.Name.O, // TABLE_SCHEMA + tbl.Name.O, // TABLE_NAME + col.Name.O, // COLUMN_NAME + i+1, // ORIGINAL_POSITION + columnDefault, // COLUMN_DEFAULT + columnDesc.Null, // IS_NULLABLE + types.TypeToStr(col.Tp, col.Charset), // DATA_TYPE + charMaxLen, // CHARACTER_MAXIMUM_LENGTH + charOctLen, // CHARACTER_OCTET_LENGTH + numericPrecision, // NUMERIC_PRECISION + numericScale, // NUMERIC_SCALE + datetimePrecision, // DATETIME_PRECISION + columnDesc.Charset, // CHARACTER_SET_NAME + columnDesc.Collation, // COLLATION_NAME + columnType, // COLUMN_TYPE + columnDesc.Key, // COLUMN_KEY + columnDesc.Extra, // EXTRA + "select,insert,update,references", // PRIVILEGES + columnDesc.Comment, // COLUMN_COMMENT + col.GeneratedExprString, // GENERATION_EXPRESSION + ) + rows = append(rows, record) + } + return rows +} + func (e *memtableRetriever) setDataFromPartitions(ctx sessionctx.Context, schemas []*model.DBInfo) error { tableRowsMap, colLengthMap, err := tableStatsCache.get(ctx) if err != nil { @@ -717,6 +840,66 @@ func (e *memtableRetriever) setDataFromViews(ctx sessionctx.Context, schemas []* e.rows = rows } +// DDLJobsReaderExec executes DDLJobs information retrieving. +type DDLJobsReaderExec struct { + baseExecutor + DDLJobRetriever + + cacheJobs []*model.Job + is infoschema.InfoSchema +} + +// Open implements the Executor Next interface. +func (e *DDLJobsReaderExec) Open(ctx context.Context) error { + if err := e.baseExecutor.Open(ctx); err != nil { + return err + } + txn, err := e.ctx.Txn(true) + if err != nil { + return err + } + e.DDLJobRetriever.is = e.is + e.activeRoles = e.ctx.GetSessionVars().ActiveRoles + err = e.DDLJobRetriever.initial(txn) + if err != nil { + return err + } + return nil +} + +// Next implements the Executor Next interface. +func (e *DDLJobsReaderExec) Next(ctx context.Context, req *chunk.Chunk) error { + req.GrowAndReset(e.maxChunkSize) + checker := privilege.GetPrivilegeManager(e.ctx) + count := 0 + + // Append running DDL jobs. + if e.cursor < len(e.runningJobs) { + num := mathutil.Min(req.Capacity(), len(e.runningJobs)-e.cursor) + for i := e.cursor; i < e.cursor+num; i++ { + e.appendJobToChunk(req, e.runningJobs[i], checker) + req.AppendString(11, e.runningJobs[i].Query) + } + e.cursor += num + count += num + } + var err error + + // Append history DDL jobs. + if count < req.Capacity() { + e.cacheJobs, err = e.historyJobIter.GetLastJobs(req.Capacity()-count, e.cacheJobs) + if err != nil { + return err + } + for _, job := range e.cacheJobs { + e.appendJobToChunk(req, job, checker) + req.AppendString(11, job.Query) + } + e.cursor += len(e.cacheJobs) + } + return nil +} + func (e *memtableRetriever) setDataFromEngines() { var rows [][]types.Datum rows = append(rows, @@ -745,7 +928,7 @@ func (e *memtableRetriever) setDataFromCharacterSets() { func (e *memtableRetriever) setDataFromCollations() { var rows [][]types.Datum - collations := charset.GetSupportedCollations() + collations := collate.GetSupportedCollations() for _, collation := range collations { isDefault := "" if collation.IsDefault { @@ -760,7 +943,7 @@ func (e *memtableRetriever) setDataFromCollations() { func (e *memtableRetriever) dataForCollationCharacterSetApplicability() { var rows [][]types.Datum - collations := charset.GetSupportedCollations() + collations := collate.GetSupportedCollations() for _, collation := range collations { rows = append(rows, types.MakeDatums(collation.Name, collation.CharsetName), @@ -808,6 +991,47 @@ func (e *memtableRetriever) setDataFromKeyColumnUsage(ctx sessionctx.Context, sc e.rows = rows } +func (e *memtableRetriever) setDataForClusterProcessList(ctx sessionctx.Context) error { + e.setDataForProcessList(ctx) + rows, err := infoschema.AppendHostInfoToRows(e.rows) + if err != nil { + return err + } + e.rows = rows + return nil +} + +func (e *memtableRetriever) setDataForProcessList(ctx sessionctx.Context) { + sm := ctx.GetSessionManager() + if sm == nil { + return + } + + loginUser := ctx.GetSessionVars().User + var hasProcessPriv bool + if pm := privilege.GetPrivilegeManager(ctx); pm != nil { + if pm.RequestVerification(ctx.GetSessionVars().ActiveRoles, "", "", "", mysql.ProcessPriv) { + hasProcessPriv = true + } + } + + pl := sm.ShowProcessList() + + records := make([][]types.Datum, 0, len(pl)) + for _, pi := range pl { + // If you have the PROCESS privilege, you can see all threads. + // Otherwise, you can see only your own threads. + if !hasProcessPriv && loginUser != nil && pi.User != loginUser.Username { + continue + } + + rows := pi.ToRow(ctx.GetSessionVars().StmtCtx.TimeZone) + record := types.MakeDatums(rows...) + records = append(records, record) + } + e.rows = records +} + func (e *memtableRetriever) setDataFromUserPrivileges(ctx sessionctx.Context) { pm := privilege.GetPrivilegeManager(ctx) e.rows = pm.UserPrivilegesTable() @@ -1131,6 +1355,33 @@ func (e *memtableRetriever) setDataForAnalyzeStatus(sctx sessionctx.Context) { e.rows = dataForAnalyzeStatusHelper(sctx) } +// setDataForPseudoProfiling returns pseudo data for table profiling when system variable `profiling` is set to `ON`. +func (e *memtableRetriever) setDataForPseudoProfiling(sctx sessionctx.Context) { + if v, ok := sctx.GetSessionVars().GetSystemVar("profiling"); ok && variable.TiDBOptOn(v) { + row := types.MakeDatums( + 0, // QUERY_ID + 0, // SEQ + "", // STATE + types.NewDecFromInt(0), // DURATION + types.NewDecFromInt(0), // CPU_USER + types.NewDecFromInt(0), // CPU_SYSTEM + 0, // CONTEXT_VOLUNTARY + 0, // CONTEXT_INVOLUNTARY + 0, // BLOCK_OPS_IN + 0, // BLOCK_OPS_OUT + 0, // MESSAGES_SENT + 0, // MESSAGES_RECEIVED + 0, // PAGE_FAULTS_MAJOR + 0, // PAGE_FAULTS_MINOR + 0, // SWAPS + "", // SOURCE_FUNCTION + "", // SOURCE_FILE + 0, // SOURCE_LINE + ) + e.rows = append(e.rows, row) + } +} + func (e *memtableRetriever) setDataForServersInfo() error { serversInfo, err := infosync.GetAllServerInfo(context.Background()) if err != nil { @@ -1153,3 +1404,78 @@ func (e *memtableRetriever) setDataForServersInfo() error { e.rows = rows return nil } + +func (e *memtableRetriever) setDataFromSequences(ctx sessionctx.Context, schemas []*model.DBInfo) { + checker := privilege.GetPrivilegeManager(ctx) + var rows [][]types.Datum + for _, schema := range schemas { + for _, table := range schema.Tables { + if !table.IsSequence() { + continue + } + if checker != nil && !checker.RequestVerification(ctx.GetSessionVars().ActiveRoles, schema.Name.L, table.Name.L, "", mysql.AllPrivMask) { + continue + } + record := types.MakeDatums( + infoschema.CatalogVal, // TABLE_CATALOG + schema.Name.O, // TABLE_SCHEMA + table.Name.O, // TABLE_NAME + table.Sequence.Cache, // Cache + table.Sequence.CacheValue, // CACHE_VALUE + table.Sequence.Cycle, // CYCLE + table.Sequence.Increment, // INCREMENT + table.Sequence.MaxValue, // MAXVALUE + table.Sequence.MinValue, // MINVALUE + table.Sequence.Order, // ORDER + table.Sequence.Start, // START + table.Sequence.Comment, // COMMENT + ) + rows = append(rows, record) + } + } + e.rows = rows +} + +// dataForTableTiFlashReplica constructs data for table tiflash replica info. +func (e *memtableRetriever) dataForTableTiFlashReplica(ctx sessionctx.Context, schemas []*model.DBInfo) { + var rows [][]types.Datum + progressMap, err := infosync.GetTiFlashTableSyncProgress(context.Background()) + if err != nil { + ctx.GetSessionVars().StmtCtx.AppendWarning(err) + } + for _, schema := range schemas { + for _, tbl := range schema.Tables { + if tbl.TiFlashReplica == nil { + continue + } + progress := 1.0 + if !tbl.TiFlashReplica.Available { + if pi := tbl.GetPartitionInfo(); pi != nil && len(pi.Definitions) > 0 { + progress = 0 + for _, p := range pi.Definitions { + if tbl.TiFlashReplica.IsPartitionAvailable(p.ID) { + progress += 1 + } else { + progress += progressMap[p.ID] + } + } + progress = progress / float64(len(pi.Definitions)) + } else { + progress = progressMap[tbl.ID] + } + } + record := types.MakeDatums( + schema.Name.O, // TABLE_SCHEMA + tbl.Name.O, // TABLE_NAME + tbl.ID, // TABLE_ID + int64(tbl.TiFlashReplica.Count), // REPLICA_COUNT + strings.Join(tbl.TiFlashReplica.LocationLabels, ","), // LOCATION_LABELS + tbl.TiFlashReplica.Available, // AVAILABLE + progress, // PROGRESS + ) + rows = append(rows, record) + } + } + e.rows = rows + return +} diff --git a/executor/infoschema_reader_test.go b/executor/infoschema_reader_test.go index 292baa1fab1d4..e1784de614615 100644 --- a/executor/infoschema_reader_test.go +++ b/executor/infoschema_reader_test.go @@ -28,6 +28,7 @@ import ( "github.com/pingcap/failpoint" "github.com/pingcap/fn" "github.com/pingcap/parser/auth" + "github.com/pingcap/parser/model" "github.com/pingcap/parser/mysql" "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/domain" @@ -58,14 +59,17 @@ var _ = SerialSuites(&testInfoschemaTableSerialSuite{}) var _ = SerialSuites(&inspectionSuite{}) -type testInfoschemaTableSuite struct { +type testInfoschemaTableSuiteBase struct { store kv.Storage dom *domain.Domain } +type testInfoschemaTableSuite struct { + testInfoschemaTableSuiteBase +} + type testInfoschemaTableSerialSuite struct { - store kv.Storage - dom *domain.Domain + testInfoschemaTableSuiteBase } type inspectionSuite struct { @@ -73,23 +77,7 @@ type inspectionSuite struct { dom *domain.Domain } -func (s *testInfoschemaTableSerialSuite) SetUpSuite(c *C) { - store, dom, err := newStoreWithBootstrap() - c.Assert(err, IsNil) - s.store = store - s.dom = dom - originCfg := config.GetGlobalConfig() - newConf := *originCfg - newConf.OOMAction = config.OOMActionLog - config.StoreGlobalConfig(&newConf) -} - -func (s *testInfoschemaTableSerialSuite) TearDownSuite(c *C) { - s.dom.Close() - s.store.Close() -} - -func (s *testInfoschemaTableSuite) SetUpSuite(c *C) { +func (s *testInfoschemaTableSuiteBase) SetUpSuite(c *C) { store, dom, err := newStoreWithBootstrap() c.Assert(err, IsNil) s.store = store @@ -100,7 +88,7 @@ func (s *testInfoschemaTableSuite) SetUpSuite(c *C) { config.StoreGlobalConfig(&newConf) } -func (s *testInfoschemaTableSuite) TearDownSuite(c *C) { +func (s *testInfoschemaTableSuiteBase) TearDownSuite(c *C) { s.dom.Close() s.store.Close() } @@ -161,13 +149,20 @@ func (s *inspectionSuite) TestInspectionTables(c *C) { tk.Se.GetSessionVars().InspectionTableCache = nil } +func (s *testInfoschemaTableSuite) TestProfiling(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustQuery("select * from information_schema.profiling").Check(testkit.Rows()) + tk.MustExec("set @@profiling=1") + tk.MustQuery("select * from information_schema.profiling").Check(testkit.Rows("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0")) +} + func (s *testInfoschemaTableSuite) TestSchemataTables(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustQuery("select * from information_schema.SCHEMATA where schema_name='mysql';").Check( testkit.Rows("def mysql utf8mb4 utf8mb4_bin ")) - //test the privilege of new user for information_schema.schemata + // Test the privilege of new user for information_schema.schemata. tk.MustExec("create user schemata_tester") schemataTester := testkit.NewTestKit(c, s.store) schemataTester.MustExec("use information_schema") @@ -181,7 +176,7 @@ func (s *testInfoschemaTableSuite) TestSchemataTables(c *C) { schemataTester.MustQuery("select * from information_schema.SCHEMATA where schema_name='INFORMATION_SCHEMA';").Check( testkit.Rows("def INFORMATION_SCHEMA utf8mb4 utf8mb4_bin ")) - //test the privilege of user with privilege of mysql for information_schema.schemata + // Test the privilege of user with privilege of mysql for information_schema.schemata. tk.MustExec("CREATE ROLE r_mysql_priv;") tk.MustExec("GRANT ALL PRIVILEGES ON mysql.* TO r_mysql_priv;") tk.MustExec("GRANT r_mysql_priv TO schemata_tester;") @@ -237,6 +232,40 @@ func (s *testInfoschemaTableSuite) TestCharacterSetCollations(c *C) { testkit.Rows("utf8mb4_bin utf8mb4")) } +func (s *testInfoschemaTableSuite) TestDDLJobs(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("create database if not exists test_ddl_jobs") + tk.MustQuery("select db_name, job_type from information_schema.DDL_JOBS limit 1").Check( + testkit.Rows("test_ddl_jobs create schema")) + + tk.MustExec("use test_ddl_jobs") + tk.MustExec("create table t (a int);") + tk.MustQuery("select db_name, table_name, job_type from information_schema.DDL_JOBS where table_name = 't'").Check( + testkit.Rows("test_ddl_jobs t create table")) + + tk.MustQuery("select job_type from information_schema.DDL_JOBS group by job_type having job_type = 'create table'").Check( + testkit.Rows("create table")) + + // Test the privilege of new user for information_schema.DDL_JOBS. + tk.MustExec("create user DDL_JOBS_tester") + DDLJobsTester := testkit.NewTestKit(c, s.store) + DDLJobsTester.MustExec("use information_schema") + c.Assert(DDLJobsTester.Se.Auth(&auth.UserIdentity{ + Username: "DDL_JOBS_tester", + Hostname: "127.0.0.1", + }, nil, nil), IsTrue) + + // Test the privilege of user for information_schema.ddl_jobs. + DDLJobsTester.MustQuery("select DB_NAME, TABLE_NAME from information_schema.DDL_JOBS where DB_NAME = 'test_ddl_jobs' and TABLE_NAME = 't';").Check( + [][]interface{}{}) + tk.MustExec("CREATE ROLE r_priv;") + tk.MustExec("GRANT ALL PRIVILEGES ON test_ddl_jobs.* TO r_priv;") + tk.MustExec("GRANT r_priv TO DDL_JOBS_tester;") + DDLJobsTester.MustExec("set role r_priv") + DDLJobsTester.MustQuery("select DB_NAME, TABLE_NAME from information_schema.DDL_JOBS where DB_NAME = 'test_ddl_jobs' and TABLE_NAME = 't';").Check( + testkit.Rows("test_ddl_jobs t")) +} + func (s *testInfoschemaTableSuite) TestKeyColumnUsage(c *C) { tk := testkit.NewTestKit(c, s.store) @@ -450,30 +479,13 @@ func (s *testInfoschemaTableSuite) TestForAnalyzeStatus(c *C) { tk := testkit.NewTestKit(c, s.store) statistics.ClearHistoryJobs() tk.MustExec("use test") - tk.MustExec("drop table if exists t") - tk.MustExec("create table t (a int, b int, index idx(a))") - tk.MustExec("insert into t values (1,2),(3,4)") - tk.MustExec("analyze table t") - - result := tk.MustQuery("select * from information_schema.analyze_status").Sort() - - c.Assert(len(result.Rows()), Equals, 2) - c.Assert(result.Rows()[0][0], Equals, "test") - c.Assert(result.Rows()[0][1], Equals, "t") - c.Assert(result.Rows()[0][2], Equals, "") - c.Assert(result.Rows()[0][3], Equals, "analyze columns") - c.Assert(result.Rows()[0][4], Equals, "2") - c.Assert(result.Rows()[0][5], NotNil) - c.Assert(result.Rows()[0][6], Equals, "finished") - - c.Assert(len(result.Rows()), Equals, 2) - c.Assert(result.Rows()[1][0], Equals, "test") - c.Assert(result.Rows()[1][1], Equals, "t") - c.Assert(result.Rows()[1][2], Equals, "") - c.Assert(result.Rows()[1][3], Equals, "analyze index idx") - c.Assert(result.Rows()[1][4], Equals, "2") - c.Assert(result.Rows()[1][5], NotNil) - c.Assert(result.Rows()[1][6], Equals, "finished") + tk.MustExec("drop table if exists analyze_test") + tk.MustExec("create table analyze_test (a int, b int, index idx(a))") + tk.MustExec("insert into analyze_test values (1,2),(3,4)") + + tk.MustQuery("select distinct TABLE_NAME from information_schema.analyze_status where TABLE_NAME='analyze_test'").Check([][]interface{}{}) + tk.MustExec("analyze table analyze_test") + tk.MustQuery("select distinct TABLE_NAME from information_schema.analyze_status where TABLE_NAME='analyze_test'").Check(testkit.Rows("analyze_test")) //test the privilege of new user for information_schema.analyze_status tk.MustExec("create user analyze_tester") @@ -488,7 +500,7 @@ func (s *testInfoschemaTableSuite) TestForAnalyzeStatus(c *C) { //test the privilege of user with privilege of test.t1 for information_schema.analyze_status tk.MustExec("create table t1 (a int, b int, index idx(a))") - tk.MustExec("insert into t values (1,2),(3,4)") + tk.MustExec("insert into t1 values (1,2),(3,4)") tk.MustExec("analyze table t1") tk.MustExec("CREATE ROLE r_t1 ;") tk.MustExec("GRANT ALL PRIVILEGES ON test.t1 TO r_t1;") @@ -518,10 +530,24 @@ func (s *testInfoschemaTableSuite) TestForServersInfo(c *C) { } } -var _ = SerialSuites(&testInfoschemaClusterTableSuite{testInfoschemaTableSuite: &testInfoschemaTableSuite{}}) +func (s *testInfoschemaTableSuite) TestForTableTiFlashReplica(c *C) { + tk := testkit.NewTestKit(c, s.store) + statistics.ClearHistoryJobs() + tk.MustExec("use test") + tk.MustExec("drop table if exists t") + tk.MustExec("create table t (a int, b int, index idx(a))") + tk.MustExec("alter table t set tiflash replica 2 location labels 'a','b';") + tk.MustQuery("select TABLE_SCHEMA,TABLE_NAME,REPLICA_COUNT,LOCATION_LABELS,AVAILABLE, PROGRESS from information_schema.tiflash_replica").Check(testkit.Rows("test t 2 a,b 0 0")) + tbl, err := domain.GetDomain(tk.Se).InfoSchema().TableByName(model.NewCIStr("test"), model.NewCIStr("t")) + c.Assert(err, IsNil) + tbl.Meta().TiFlashReplica.Available = true + tk.MustQuery("select TABLE_SCHEMA,TABLE_NAME,REPLICA_COUNT,LOCATION_LABELS,AVAILABLE, PROGRESS from information_schema.tiflash_replica").Check(testkit.Rows("test t 2 a,b 1 1")) +} + +var _ = SerialSuites(&testInfoschemaClusterTableSuite{testInfoschemaTableSuiteBase: &testInfoschemaTableSuiteBase{}}) type testInfoschemaClusterTableSuite struct { - *testInfoschemaTableSuite + *testInfoschemaTableSuiteBase rpcserver *grpc.Server httpServer *httptest.Server mockAddr string @@ -530,7 +556,7 @@ type testInfoschemaClusterTableSuite struct { } func (s *testInfoschemaClusterTableSuite) SetUpSuite(c *C) { - s.testInfoschemaTableSuite.SetUpSuite(c) + s.testInfoschemaTableSuiteBase.SetUpSuite(c) s.rpcserver, s.listenAddr = s.setUpRPCService(c, ":0") s.httpServer, s.mockAddr = s.setUpMockPDHTTPServer() s.startTime = time.Now() @@ -629,7 +655,7 @@ func (s *testInfoschemaClusterTableSuite) TearDownSuite(c *C) { if s.httpServer != nil { s.httpServer.Close() } - s.testInfoschemaTableSuite.TearDownSuite(c) + s.testInfoschemaTableSuiteBase.TearDownSuite(c) } type mockSessionManager struct { @@ -721,3 +747,9 @@ func (s *testInfoschemaClusterTableSuite) TestTiDBClusterInfo(c *C) { "tikv key3.key4.nest4 n-value5", )) } + +func (s *testInfoschemaTableSuite) TestSequences(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("CREATE SEQUENCE test.seq maxvalue 10000000") + tk.MustQuery("SELECT * FROM information_schema.sequences WHERE sequence_schema='test' AND sequence_name='seq'").Check(testkit.Rows("def test seq 1 1000 0 1 10000000 1 0 1 ")) +} diff --git a/executor/insert_common.go b/executor/insert_common.go index 929ebf662bbe4..a4ea2a566b5f6 100644 --- a/executor/insert_common.go +++ b/executor/insert_common.go @@ -281,7 +281,7 @@ func (e *InsertValues) handleErr(col *table.Column, val *types.Datum, rowIdx int err = resetErrDataTooLong(colName, rowIdx+1, err) } else if types.ErrOverflow.Equal(err) { err = types.ErrWarnDataOutOfRange.GenWithStackByArgs(colName, rowIdx+1) - } else if types.ErrTruncated.Equal(err) || types.ErrTruncatedWrongVal.Equal(err) { + } else if types.ErrTruncated.Equal(err) || types.ErrTruncatedWrongVal.Equal(err) || types.ErrWrongValue.Equal(err) { valStr, err1 := val.ToString() if err1 != nil { logutil.BgLogger().Warn("truncate value failed", zap.Error(err1)) @@ -497,7 +497,13 @@ func (e *InsertValues) getColDefaultValue(idx int, col *table.Column) (d types.D if !col.DefaultIsExpr && e.colDefaultVals != nil && e.colDefaultVals[idx].valid { return e.colDefaultVals[idx].val, nil } - defaultVal, err := table.GetColDefaultValue(e.ctx, col.ToInfo()) + + var defaultVal types.Datum + if col.DefaultIsExpr && col.DefaultExpr != nil { + defaultVal, err = table.EvalColDefaultExpr(e.ctx, col.ToInfo(), col.DefaultExpr) + } else { + defaultVal, err = table.GetColDefaultValue(e.ctx, col.ToInfo()) + } if err != nil { return types.Datum{}, err } diff --git a/executor/insert_test.go b/executor/insert_test.go index ea188580883eb..ee0ca94c28f81 100644 --- a/executor/insert_test.go +++ b/executor/insert_test.go @@ -1130,5 +1130,5 @@ func (s *testSuite9) TestInsertErrorMsg(c *C) { tk.MustExec(`create table t (a int primary key, b datetime, d date)`) _, err := tk.Exec(`insert into t values (1, '2019-02-11 30:00:00', '2019-01-31')`) c.Assert(err, NotNil) - c.Assert(strings.Contains(err.Error(), "Incorrect time value: '30'"), IsTrue) + c.Assert(strings.Contains(err.Error(), "Incorrect datetime value: '2019-02-11 30:00:00' for column 'b' at row 1"), IsTrue, Commentf("%v", err)) } diff --git a/executor/inspection_result.go b/executor/inspection_result.go index 763c678fddfc6..6e3cfa364caf5 100644 --- a/executor/inspection_result.go +++ b/executor/inspection_result.go @@ -247,6 +247,12 @@ func (configInspection) inspectCheckConfig(_ context.Context, sctx sessionctx.Co value: "0", detail: "slow-threshold = 0 will record every query to slow log, it may affect performance", }, + { + tp: "tikv", + key: "raftstore.sync-log", + value: "false", + detail: "sync-log should be true to avoid recover region when the machine breaks down", + }, } var results []inspectionResult @@ -532,6 +538,7 @@ func (c thresholdCheckInspection) inspect(ctx context.Context, sctx sessionctx.C c.inspectThreshold1, c.inspectThreshold2, c.inspectThreshold3, + c.inspectForLeaderDrop, } var results []inspectionResult for _, inspect := range inspects { @@ -623,10 +630,11 @@ func (thresholdCheckInspection) inspectThreshold1(ctx context.Context, sctx sess var sql string if len(rule.configKey) > 0 { - sql = fmt.Sprintf("select t1.instance, t1.cpu, t2.threshold, t2.value from "+ - "(select instance, max(value) as cpu from metrics_schema.tikv_thread_cpu %[4]s and name like '%[1]s' group by instance) as t1,"+ - "(select value * %[2]f as threshold, value from information_schema.cluster_config where type='tikv' and `key` = '%[3]s' limit 1) as t2 "+ - "where t1.cpu > t2.threshold;", rule.component, rule.threshold, rule.configKey, condition) + sql = fmt.Sprintf("select t2.instance, t1.cpu, (t2.value * %[2]f) as threshold, t2.value from "+ + "(select instance as status_address, max(value) as cpu from metrics_schema.tikv_thread_cpu %[4]s and name like '%[1]s' group by instance) as t1 join "+ + "(select instance, value from information_schema.cluster_config where type='tikv' and `key` = '%[3]s') as t2 join "+ + "(select instance,status_address from information_schema.cluster_info where type='tikv') as t3 "+ + "on t1.status_address=t3.status_address and t2.instance=t3.instance where t1.cpu > (t2.value * %[2]f)", rule.component, rule.threshold, rule.configKey, condition) } else { sql = fmt.Sprintf("select t1.instance, t1.cpu, %[2]f from "+ "(select instance, max(value) as cpu from metrics_schema.tikv_thread_cpu %[3]s and name like '%[1]s' group by instance) as t1 "+ @@ -855,13 +863,22 @@ func (c compareStoreStatus) genSQL(timeRange plannercore.QueryTimeRange) string condition := fmt.Sprintf(`where t1.time>='%[1]s' and t1.time<='%[2]s' and t2.time>='%[1]s' and t2.time<='%[2]s'`, timeRange.From.Format(plannercore.MetricTableTimeFormat), timeRange.To.Format(plannercore.MetricTableTimeFormat)) - return fmt.Sprintf(`select t1.address,t1.value,t2.address,t2.value, - (t1.value-t2.value)/t1.value as ratio - from metrics_schema.pd_scheduler_store_status t1 join metrics_schema.pd_scheduler_store_status t2 - %s and t1.type='%s' and t1.time = t2.time and - t1.type=t2.type and t1.address != t2.address and - (t1.value-t2.value)/t1.value>%v and t1.value > 0 group by t1.address,t1.value,t2.address,t2.value order by ratio desc`, - condition, c.tp, c.threshold) + return fmt.Sprintf(` + SELECT t1.address, + max(t1.value), + t2.address, + min(t2.value), + max((t1.value-t2.value)/t1.value) AS ratio + FROM metrics_schema.pd_scheduler_store_status t1 + JOIN metrics_schema.pd_scheduler_store_status t2 %s + AND t1.type='%s' + AND t1.time = t2.time + AND t1.type=t2.type + AND t1.address != t2.address + AND (t1.value-t2.value)/t1.value>%v + AND t1.value > 0 + GROUP BY t1.address,t2.address + ORDER BY ratio desc`, condition, c.tp, c.threshold) } func (c compareStoreStatus) genResult(_ string, row chunk.Row) inspectionResult { @@ -870,7 +887,7 @@ func (c compareStoreStatus) genResult(_ string, row chunk.Row) inspectionResult addr2 := row.GetString(2) value2 := row.GetFloat64(3) ratio := row.GetFloat64(4) - detail := fmt.Sprintf("%v %s is %.2f, much more than %v %s %.2f", addr1, c.tp, value1, addr2, c.tp, value2) + detail := fmt.Sprintf("%v max %s is %.2f, much more than %v min %s %.2f", addr1, c.tp, value1, addr2, c.tp, value2) return inspectionResult{ tp: "tikv", instance: addr2, @@ -919,7 +936,7 @@ type checkStoreRegionTooMuch struct{} func (c checkStoreRegionTooMuch) genSQL(timeRange plannercore.QueryTimeRange) string { condition := timeRange.Condition() - return fmt.Sprintf(`select address,value from metrics_schema.pd_scheduler_store_status %s and type='region_count' and value > 20000;`, condition) + return fmt.Sprintf(`select address, max(value) from metrics_schema.pd_scheduler_store_status %s and type='region_count' and value > 20000 group by address`, condition) } func (c checkStoreRegionTooMuch) genResult(sql string, row chunk.Row) inspectionResult { @@ -979,3 +996,51 @@ func (thresholdCheckInspection) inspectThreshold3(ctx context.Context, sctx sess } return results } + +func (c thresholdCheckInspection) inspectForLeaderDrop(ctx context.Context, sctx sessionctx.Context, filter inspectionFilter) []inspectionResult { + condition := filter.timeRange.Condition() + threshold := 50.0 + sql := fmt.Sprintf(`select address,min(value) as mi,max(value) as mx from metrics_schema.pd_scheduler_store_status %s and type='leader_count' group by address having mx-mi>%v`, condition, threshold) + rows, _, err := sctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQLWithContext(ctx, sql) + if err != nil { + sctx.GetSessionVars().StmtCtx.AppendWarning(fmt.Errorf("execute '%s' failed: %v", sql, err)) + return nil + } + var results []inspectionResult + for _, row := range rows { + address := row.GetString(0) + sql := fmt.Sprintf(`select time, value from metrics_schema.pd_scheduler_store_status %s and type='leader_count' and address = '%s' order by time`, condition, address) + subRows, _, err := sctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQLWithContext(ctx, sql) + if err != nil { + sctx.GetSessionVars().StmtCtx.AppendWarning(fmt.Errorf("execute '%s' failed: %v", sql, err)) + continue + } + lastValue := float64(0) + for i, subRows := range subRows { + v := subRows.GetFloat64(1) + if i == 0 { + lastValue = v + continue + } + if lastValue-v > threshold { + level := "warning" + if v == 0 { + level = "critical" + } + results = append(results, inspectionResult{ + tp: "tikv", + instance: address, + item: "leader-drop", + actual: fmt.Sprintf("%.0f", lastValue-v), + expected: fmt.Sprintf("<= %.0f", threshold), + severity: level, + detail: fmt.Sprintf("%s tikv has too many leader-drop around time %s, leader count from %.0f drop to %.0f", address, subRows.GetTime(0), lastValue, v), + degree: lastValue - v, + }) + break + } + lastValue = v + } + } + return results +} diff --git a/executor/inspection_result_test.go b/executor/inspection_result_test.go index 9a29202c9d6bb..02dde211ff736 100644 --- a/executor/inspection_result_test.go +++ b/executor/inspection_result_test.go @@ -49,6 +49,7 @@ func (s *inspectionResultSuite) TestInspectionResult(c *C) { types.MakeDatums("tikv", "192.168.3.33:26600", "coprocessor.high", "8"), types.MakeDatums("tikv", "192.168.3.34:26600", "coprocessor.high", "7"), types.MakeDatums("tikv", "192.168.3.35:26600", "coprocessor.high", "7"), + types.MakeDatums("tikv", "192.168.3.35:26600", "raftstore.sync-log", "false"), types.MakeDatums("pd", "192.168.3.32:2379", "scheduler.limit", "3"), types.MakeDatums("pd", "192.168.3.33:2379", "scheduler.limit", "3"), types.MakeDatums("pd", "192.168.3.34:2379", "scheduler.limit", "3"), @@ -111,6 +112,7 @@ func (s *inspectionResultSuite) TestInspectionResult(c *C) { "config ddl.lease tidb inconsistent consistent warning the cluster has different config value of ddl.lease, execute the sql to see more detail: select * from information_schema.cluster_config where type='tidb' and `key`='ddl.lease'", "config log.slow-threshold tidb 0 not 0 warning slow-threshold = 0 will record every query to slow log, it may affect performance", "config log.slow-threshold tidb inconsistent consistent warning the cluster has different config value of log.slow-threshold, execute the sql to see more detail: select * from information_schema.cluster_config where type='tidb' and `key`='log.slow-threshold'", + "config raftstore.sync-log tikv false not false warning sync-log should be true to avoid recover region when the machine breaks down", "version git_hash pd inconsistent consistent critical the cluster has 3 different pd versions, execute the sql to see more detail: select * from information_schema.cluster_info where type='pd'", "version git_hash tidb inconsistent consistent critical the cluster has 3 different tidb versions, execute the sql to see more detail: select * from information_schema.cluster_info where type='tidb'", "version git_hash tikv inconsistent consistent critical the cluster has 2 different tikv versions, execute the sql to see more detail: select * from information_schema.cluster_info where type='tikv'", @@ -130,6 +132,7 @@ func (s *inspectionResultSuite) TestInspectionResult(c *C) { "config ddl.lease tidb inconsistent consistent warning the cluster has different config value of ddl.lease, execute the sql to see more detail: select * from information_schema.cluster_config where type='tidb' and `key`='ddl.lease'", "config log.slow-threshold tidb 0 not 0 warning slow-threshold = 0 will record every query to slow log, it may affect performance", "config log.slow-threshold tidb inconsistent consistent warning the cluster has different config value of log.slow-threshold, execute the sql to see more detail: select * from information_schema.cluster_config where type='tidb' and `key`='log.slow-threshold'", + "config raftstore.sync-log tikv false not false warning sync-log should be true to avoid recover region when the machine breaks down", }, }, { @@ -167,8 +170,15 @@ func (s *inspectionResultSuite) parseTime(c *C, se session.Session, str string) return t } -func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func (s *inspectionResultSuite) tearDownForThresholdCheck(c *C) { + fpName := "github.com/pingcap/tidb/executor/mockMergeMockInspectionTables" + c.Assert(failpoint.Disable(fpName), IsNil) + + fpName2 := "github.com/pingcap/tidb/executor/mockMetricsTableData" + c.Assert(failpoint.Disable(fpName2), IsNil) +} + +func (s *inspectionResultSuite) setupForThresholdCheck(c *C, mockData map[string][][]types.Datum) context.Context { // mock tikv configuration. configurations := map[string]variable.TableSnapshot{} configurations[infoschema.TableClusterConfig] = variable.TableSnapshot{ @@ -178,6 +188,7 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) { types.MakeDatums("tikv", "tikv-0", "readpool.coprocessor.high-concurrency", "4"), types.MakeDatums("tikv", "tikv-0", "readpool.coprocessor.low-concurrency", "4"), types.MakeDatums("tikv", "tikv-0", "readpool.coprocessor.normal-concurrency", "4"), + types.MakeDatums("tikv", "tikv-1", "readpool.coprocessor.normal-concurrency", "8"), types.MakeDatums("tikv", "tikv-0", "readpool.storage.high-concurrency", "4"), types.MakeDatums("tikv", "tikv-0", "readpool.storage.low-concurrency", "4"), types.MakeDatums("tikv", "tikv-0", "readpool.storage.normal-concurrency", "4"), @@ -185,6 +196,30 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) { types.MakeDatums("tikv", "tikv-0", "storage.scheduler-worker-pool-size", "6"), }, } + // mock cluster information + configurations[infoschema.TableClusterInfo] = variable.TableSnapshot{ + Rows: [][]types.Datum{ + types.MakeDatums("tikv", "tikv-0", "tikv-0", "4.0", "a234c", "", ""), + types.MakeDatums("tikv", "tikv-1", "tikv-1", "4.0", "a234c", "", ""), + }, + } + fpName := "github.com/pingcap/tidb/executor/mockMergeMockInspectionTables" + c.Assert(failpoint.Enable(fpName, "return"), IsNil) + + // Mock for metric table data. + fpName2 := "github.com/pingcap/tidb/executor/mockMetricsTableData" + c.Assert(failpoint.Enable(fpName2, "return"), IsNil) + + ctx := context.WithValue(context.Background(), "__mockInspectionTables", configurations) + ctx = context.WithValue(ctx, "__mockMetricsTableData", mockData) + ctx = failpoint.WithHook(ctx, func(_ context.Context, currName string) bool { + return fpName2 == currName || currName == fpName + }) + return ctx +} + +func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) datetime := func(str string) types.Time { return s.parseTime(c, tk.Se, str) } @@ -193,6 +228,7 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) { // columns: time, instance, name, value "tikv_thread_cpu": { types.MakeDatums(datetime("2020-02-14 05:20:00"), "tikv-0", "cop_normal0", 10.0), + types.MakeDatums(datetime("2020-02-14 05:20:00"), "tikv-1", "cop_normal0", 10.0), types.MakeDatums(datetime("2020-02-14 05:20:00"), "tikv-0", "cop_normal1", 10.0), types.MakeDatums(datetime("2020-02-14 05:20:00"), "tikv-0", "cop_high1", 10.0), types.MakeDatums(datetime("2020-02-14 05:20:00"), "tikv-0", "cop_low1", 10.0), @@ -222,20 +258,8 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) { "pd_region_health": {}, } - fpName := "github.com/pingcap/tidb/executor/mockMergeMockInspectionTables" - c.Assert(failpoint.Enable(fpName, "return"), IsNil) - defer func() { c.Assert(failpoint.Disable(fpName), IsNil) }() - - // Mock for metric table data. - fpName2 := "github.com/pingcap/tidb/executor/mockMetricsTableData" - c.Assert(failpoint.Enable(fpName2, "return"), IsNil) - defer func() { c.Assert(failpoint.Disable(fpName2), IsNil) }() - - ctx := context.WithValue(context.Background(), "__mockInspectionTables", configurations) - ctx = context.WithValue(ctx, "__mockMetricsTableData", mockData) - ctx = failpoint.WithHook(ctx, func(_ context.Context, fpname2 string) bool { - return fpName2 == fpname2 || fpname2 == fpName - }) + ctx := s.setupForThresholdCheck(c, mockData) + defer s.tearDownForThresholdCheck(c) rs, err := tk.Se.Execute(ctx, "select /*+ time_range('2020-02-12 10:35:00','2020-02-12 10:37:00') */ item, type, instance, value, reference, details from information_schema.inspection_result where rule='threshold-check' order by item") c.Assert(err, IsNil) @@ -246,6 +270,7 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) { "coprocessor-high-cpu tikv tikv-0 10.00 < 3.60, config: readpool.coprocessor.high-concurrency=4 the 'coprocessor-high-cpu' max cpu-usage of tikv-0 tikv is too high", "coprocessor-low-cpu tikv tikv-0 10.00 < 3.60, config: readpool.coprocessor.low-concurrency=4 the 'coprocessor-low-cpu' max cpu-usage of tikv-0 tikv is too high", "coprocessor-normal-cpu tikv tikv-0 10.00 < 3.60, config: readpool.coprocessor.normal-concurrency=4 the 'coprocessor-normal-cpu' max cpu-usage of tikv-0 tikv is too high", + "coprocessor-normal-cpu tikv tikv-1 10.00 < 7.20, config: readpool.coprocessor.normal-concurrency=8 the 'coprocessor-normal-cpu' max cpu-usage of tikv-1 tikv is too high", "grpc-cpu tikv tikv-0 10.00 < 7.20, config: server.grpc-concurrency=8 the 'grpc-cpu' max cpu-usage of tikv-0 tikv is too high", "raftstore-cpu tikv tikv-0 10.00 < 1.60, config: raftstore.store-pool-size=2 the 'raftstore-cpu' max cpu-usage of tikv-0 tikv is too high", "scheduler-worker-cpu tikv tikv-0 10.00 < 5.10, config: storage.scheduler-worker-pool-size=6 the 'scheduler-worker-cpu' max cpu-usage of tikv-0 tikv is too high", @@ -272,11 +297,7 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) { types.MakeDatums(datetime("2020-02-14 05:20:00"), "tikv-0", "split_check", 0.5), } - ctx = context.WithValue(context.Background(), "__mockInspectionTables", configurations) ctx = context.WithValue(ctx, "__mockMetricsTableData", mockData) - ctx = failpoint.WithHook(ctx, func(_ context.Context, fpname2 string) bool { - return fpName2 == fpname2 || fpname2 == fpName - }) rs, err = tk.Se.Execute(ctx, "select item, type, instance, value, reference from information_schema.inspection_result where rule='threshold-check' order by item") c.Assert(err, IsNil) result = tk.ResultSetToResultWithCtx(ctx, rs[0], Commentf("execute inspect SQL failed")) @@ -286,11 +307,6 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) { func (s *inspectionResultSuite) TestThresholdCheckInspection2(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) - // Mock for metric table data. - fpName := "github.com/pingcap/tidb/executor/mockMetricsTableData" - c.Assert(failpoint.Enable(fpName, "return"), IsNil) - defer func() { c.Assert(failpoint.Disable(fpName), IsNil) }() - datetime := func(s string) types.Time { t, err := types.ParseTime(tk.Se.GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp) c.Assert(err, IsNil) @@ -346,10 +362,8 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection2(c *C) { "pd_region_health": {}, } - ctx := context.WithValue(context.Background(), "__mockMetricsTableData", mockData) - ctx = failpoint.WithHook(ctx, func(_ context.Context, fpname string) bool { - return fpname == fpName - }) + ctx := s.setupForThresholdCheck(c, mockData) + defer s.tearDownForThresholdCheck(c) rs, err := tk.Se.Execute(ctx, "select /*+ time_range('2020-02-12 10:35:00','2020-02-12 10:37:00') */ item, type, instance, value, reference, details from information_schema.inspection_result where rule='threshold-check' order by item") c.Assert(err, IsNil) @@ -375,11 +389,6 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection2(c *C) { func (s *inspectionResultSuite) TestThresholdCheckInspection3(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) - // Mock for metric table data. - fpName := "github.com/pingcap/tidb/executor/mockMetricsTableData" - c.Assert(failpoint.Enable(fpName, "return"), IsNil) - defer func() { c.Assert(failpoint.Disable(fpName), IsNil) }() - datetime := func(s string) types.Time { t, err := types.ParseTime(tk.Se.GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp) c.Assert(err, IsNil) @@ -391,11 +400,20 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection3(c *C) { "pd_scheduler_store_status": { types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-0", "0", "leader_score", 100.0), types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-1", "1", "leader_score", 50.0), + types.MakeDatums(datetime("2020-02-14 05:21:00"), "pd-0", "tikv-0", "0", "leader_score", 99.0), + types.MakeDatums(datetime("2020-02-14 05:21:00"), "pd-0", "tikv-1", "1", "leader_score", 51.0), types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-0", "0", "region_score", 100.0), types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-1", "1", "region_score", 90.0), types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-0", "0", "store_available", 100.0), types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-1", "1", "store_available", 70.0), types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-0", "0", "region_count", 20001.0), + types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-0", "0", "leader_count", 10000.0), + types.MakeDatums(datetime("2020-02-14 05:21:00"), "pd-0", "tikv-0", "0", "leader_count", 5000.0), + types.MakeDatums(datetime("2020-02-14 05:22:00"), "pd-0", "tikv-0", "0", "leader_count", 5000.0), + types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-1", "0", "leader_count", 5000.0), + types.MakeDatums(datetime("2020-02-14 05:21:00"), "pd-0", "tikv-1", "0", "leader_count", 10000.0), + types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "tikv-2", "0", "leader_count", 10000.0), + types.MakeDatums(datetime("2020-02-14 05:21:00"), "pd-0", "tikv-2", "0", "leader_count", 0.0), }, "pd_region_health": { types.MakeDatums(datetime("2020-02-14 05:20:00"), "pd-0", "extra-peer-region-count", 40.0), @@ -404,24 +422,24 @@ func (s *inspectionResultSuite) TestThresholdCheckInspection3(c *C) { }, } - ctx := context.WithValue(context.Background(), "__mockMetricsTableData", mockData) - ctx = failpoint.WithHook(ctx, func(_ context.Context, fpname string) bool { - return fpname == fpName - }) + ctx := s.setupForThresholdCheck(c, mockData) + defer s.tearDownForThresholdCheck(c) - rs, err := tk.Se.Execute(ctx, `select /*+ time_range('2020-02-14 04:20:00','2020-02-14 05:20:00') */ + rs, err := tk.Se.Execute(ctx, `select /*+ time_range('2020-02-14 04:20:00','2020-02-14 05:23:00') */ item, type, instance, value, reference, details from information_schema.inspection_result - where rule='threshold-check' and item in ('leader-score-balance','region-score-balance','region-count','region-health','store-available-balance') + where rule='threshold-check' and item in ('leader-score-balance','region-score-balance','region-count','region-health','store-available-balance','leader-drop') order by item`) c.Assert(err, IsNil) result := tk.ResultSetToResultWithCtx(ctx, rs[0], Commentf("execute inspect SQL failed")) c.Assert(tk.Se.GetSessionVars().StmtCtx.WarningCount(), Equals, uint16(0), Commentf("unexpected warnings: %+v", tk.Se.GetSessionVars().StmtCtx.GetWarnings())) result.Check(testkit.Rows( - "leader-score-balance tikv tikv-1 50.00% < 5.00% tikv-0 leader_score is 100.00, much more than tikv-1 leader_score 50.00", + "leader-drop tikv tikv-2 10000 <= 50 tikv-2 tikv has too many leader-drop around time 2020-02-14 05:21:00.000000, leader count from 10000 drop to 0", + "leader-drop tikv tikv-0 5000 <= 50 tikv-0 tikv has too many leader-drop around time 2020-02-14 05:21:00.000000, leader count from 10000 drop to 5000", + "leader-score-balance tikv tikv-1 50.00% < 5.00% tikv-0 max leader_score is 100.00, much more than tikv-1 min leader_score 50.00", "region-count tikv tikv-0 20001.00 <= 20000 tikv-0 tikv has too many regions", "region-health pd pd-0 110.00 < 100 the count of extra-perr and learner-peer and pending-peer are 110, it means the scheduling is too frequent or too slow", - "region-score-balance tikv tikv-1 10.00% < 5.00% tikv-0 region_score is 100.00, much more than tikv-1 region_score 90.00", - "store-available-balance tikv tikv-1 30.00% < 20.00% tikv-0 store_available is 100.00, much more than tikv-1 store_available 70.00")) + "region-score-balance tikv tikv-1 10.00% < 5.00% tikv-0 max region_score is 100.00, much more than tikv-1 min region_score 90.00", + "store-available-balance tikv tikv-1 30.00% < 20.00% tikv-0 max store_available is 100.00, much more than tikv-1 min store_available 70.00")) } func (s *inspectionResultSuite) TestCriticalErrorInspection(c *C) { diff --git a/executor/join_test.go b/executor/join_test.go index 73d22cb66c6c7..224bc394ce560 100644 --- a/executor/join_test.go +++ b/executor/join_test.go @@ -17,7 +17,6 @@ import ( "context" "fmt" "math/rand" - "strings" "time" . "github.com/pingcap/check" @@ -1148,41 +1147,41 @@ func (s *testSuiteJoin1) TestIndexLookupJoin(c *C) { tk.MustExec("analyze table s;") tk.MustQuery("desc select /*+ TIDB_INLJ(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows( - "HashAgg_9 1.00 root funcs:count(1)->Column#6", - "└─IndexJoin_16 64.00 root inner join, inner:IndexReader_15, outer key:test.t.a, inner key:test.s.a, other cond:lt(test.s.b, test.t.b)", - " ├─TableReader_26(Build) 64.00 root data:Selection_25", - " │ └─Selection_25 64.00 cop[tikv] not(isnull(test.t.b))", - " │ └─TableFullScan_24 64.00 cop[tikv] table:t, keep order:false", - " └─IndexReader_15(Probe) 1.00 root index:Selection_14", - " └─Selection_14 1.00 cop[tikv] not(isnull(test.s.a)), not(isnull(test.s.b))", - " └─IndexRangeScan_13 1.00 cop[tikv] table:s, index:a, b, range: decided by [eq(test.s.a, test.t.a) lt(test.s.b, test.t.b)], keep order:false")) + "HashAgg_9 1.00 root funcs:count(1)->Column#6", + "└─IndexJoin_16 64.00 root inner join, inner:IndexReader_15, outer key:test.t.a, inner key:test.s.a, other cond:lt(test.s.b, test.t.b)", + " ├─TableReader_26(Build) 64.00 root data:Selection_25", + " │ └─Selection_25 64.00 cop[tikv] not(isnull(test.t.b))", + " │ └─TableFullScan_24 64.00 cop[tikv] table:t keep order:false", + " └─IndexReader_15(Probe) 1.00 root index:Selection_14", + " └─Selection_14 1.00 cop[tikv] not(isnull(test.s.a)), not(isnull(test.s.b))", + " └─IndexRangeScan_13 1.00 cop[tikv] table:s, index:idx(a, b) range: decided by [eq(test.s.a, test.t.a) lt(test.s.b, test.t.b)], keep order:false")) tk.MustQuery("select /*+ TIDB_INLJ(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows("64")) tk.MustExec("set @@tidb_index_lookup_join_concurrency=1;") tk.MustQuery("select /*+ TIDB_INLJ(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows("64")) tk.MustQuery("desc select /*+ INL_MERGE_JOIN(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows( - "HashAgg_9 1.00 root funcs:count(1)->Column#6", - "└─IndexMergeJoin_21 64.00 root inner join, inner:IndexReader_19, outer key:test.t.a, inner key:test.s.a, other cond:lt(test.s.b, test.t.b)", - " ├─TableReader_26(Build) 64.00 root data:Selection_25", - " │ └─Selection_25 64.00 cop[tikv] not(isnull(test.t.b))", - " │ └─TableFullScan_24 64.00 cop[tikv] table:t, keep order:false", - " └─IndexReader_19(Probe) 1.00 root index:Selection_18", - " └─Selection_18 1.00 cop[tikv] not(isnull(test.s.a)), not(isnull(test.s.b))", - " └─IndexRangeScan_17 1.00 cop[tikv] table:s, index:a, b, range: decided by [eq(test.s.a, test.t.a) lt(test.s.b, test.t.b)], keep order:true", + "HashAgg_9 1.00 root funcs:count(1)->Column#6", + "└─IndexMergeJoin_21 64.00 root inner join, inner:IndexReader_19, outer key:test.t.a, inner key:test.s.a, other cond:lt(test.s.b, test.t.b)", + " ├─TableReader_26(Build) 64.00 root data:Selection_25", + " │ └─Selection_25 64.00 cop[tikv] not(isnull(test.t.b))", + " │ └─TableFullScan_24 64.00 cop[tikv] table:t keep order:false", + " └─IndexReader_19(Probe) 1.00 root index:Selection_18", + " └─Selection_18 1.00 cop[tikv] not(isnull(test.s.a)), not(isnull(test.s.b))", + " └─IndexRangeScan_17 1.00 cop[tikv] table:s, index:idx(a, b) range: decided by [eq(test.s.a, test.t.a) lt(test.s.b, test.t.b)], keep order:true", )) tk.MustQuery("select /*+ INL_MERGE_JOIN(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows("64")) tk.MustExec("set @@tidb_index_lookup_join_concurrency=1;") tk.MustQuery("select /*+ INL_MERGE_JOIN(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows("64")) tk.MustQuery("desc select /*+ INL_HASH_JOIN(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows( - "HashAgg_9 1.00 root funcs:count(1)->Column#6", - "└─IndexHashJoin_23 64.00 root inner join, inner:IndexReader_15, outer key:test.t.a, inner key:test.s.a, other cond:lt(test.s.b, test.t.b)", - " ├─TableReader_26(Build) 64.00 root data:Selection_25", - " │ └─Selection_25 64.00 cop[tikv] not(isnull(test.t.b))", - " │ └─TableFullScan_24 64.00 cop[tikv] table:t, keep order:false", - " └─IndexReader_15(Probe) 1.00 root index:Selection_14", - " └─Selection_14 1.00 cop[tikv] not(isnull(test.s.a)), not(isnull(test.s.b))", - " └─IndexRangeScan_13 1.00 cop[tikv] table:s, index:a, b, range: decided by [eq(test.s.a, test.t.a) lt(test.s.b, test.t.b)], keep order:false", + "HashAgg_9 1.00 root funcs:count(1)->Column#6", + "└─IndexHashJoin_23 64.00 root inner join, inner:IndexReader_15, outer key:test.t.a, inner key:test.s.a, other cond:lt(test.s.b, test.t.b)", + " ├─TableReader_26(Build) 64.00 root data:Selection_25", + " │ └─Selection_25 64.00 cop[tikv] not(isnull(test.t.b))", + " │ └─TableFullScan_24 64.00 cop[tikv] table:t keep order:false", + " └─IndexReader_15(Probe) 1.00 root index:Selection_14", + " └─Selection_14 1.00 cop[tikv] not(isnull(test.s.a)), not(isnull(test.s.b))", + " └─IndexRangeScan_13 1.00 cop[tikv] table:s, index:idx(a, b) range: decided by [eq(test.s.a, test.t.a) lt(test.s.b, test.t.b)], keep order:false", )) tk.MustQuery("select /*+ INL_HASH_JOIN(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows("64")) tk.MustExec("set @@tidb_index_lookup_join_concurrency=1;") @@ -1211,11 +1210,11 @@ func (s *testSuiteJoin1) TestIndexNestedLoopHashJoin(c *C) { tk.MustExec("analyze table s") // Test IndexNestedLoopHashJoin keepOrder. tk.MustQuery("explain select /*+ INL_HASH_JOIN(s) */ * from t left join s on t.a=s.a order by t.pk").Check(testkit.Rows( - "IndexHashJoin_28 100.00 root left outer join, inner:TableReader_22, outer key:test.t.a, inner key:test.s.a", - "├─TableReader_30(Build) 100.00 root data:TableFullScan_29", - "│ └─TableFullScan_29 100.00 cop[tikv] table:t, keep order:true", - "└─TableReader_22(Probe) 1.00 root data:TableRangeScan_21", - " └─TableRangeScan_21 1.00 cop[tikv] table:s, range: decided by [test.t.a], keep order:false", + "IndexHashJoin_28 100.00 root left outer join, inner:TableReader_22, outer key:test.t.a, inner key:test.s.a", + "├─TableReader_30(Build) 100.00 root data:TableFullScan_29", + "│ └─TableFullScan_29 100.00 cop[tikv] table:t keep order:true", + "└─TableReader_22(Probe) 1.00 root data:TableRangeScan_21", + " └─TableRangeScan_21 1.00 cop[tikv] table:s range: decided by [test.t.a], keep order:false", )) rs := tk.MustQuery("select /*+ INL_HASH_JOIN(s) */ * from t left join s on t.a=s.a order by t.pk") for i, row := range rs.Rows() { @@ -1238,12 +1237,12 @@ func (s *testSuiteJoin3) TestIssue13449(c *C) { tk.MustExec("set @@tidb_index_join_batch_size=32;") tk.MustQuery("desc select /*+ INL_HASH_JOIN(s) */ * from t join s on t.a=s.a order by t.a;").Check(testkit.Rows( - "IndexHashJoin_35 12487.50 root inner join, inner:IndexReader_27, outer key:test.t.a, inner key:test.s.a", - "├─IndexReader_37(Build) 9990.00 root index:IndexFullScan_36", - "│ └─IndexFullScan_36 9990.00 cop[tikv] table:t, index:a, keep order:true, stats:pseudo", - "└─IndexReader_27(Probe) 1.25 root index:Selection_26", - " └─Selection_26 1.25 cop[tikv] not(isnull(test.s.a))", - " └─IndexRangeScan_25 1.25 cop[tikv] table:s, index:a, range: decided by [eq(test.s.a, test.t.a)], keep order:false, stats:pseudo")) + "IndexHashJoin_35 12487.50 root inner join, inner:IndexReader_27, outer key:test.t.a, inner key:test.s.a", + "├─IndexReader_37(Build) 9990.00 root index:IndexFullScan_36", + "│ └─IndexFullScan_36 9990.00 cop[tikv] table:t, index:a(a) keep order:true, stats:pseudo", + "└─IndexReader_27(Probe) 1.25 root index:Selection_26", + " └─Selection_26 1.25 cop[tikv] not(isnull(test.s.a))", + " └─IndexRangeScan_25 1.25 cop[tikv] table:s, index:a(a) range: decided by [eq(test.s.a, test.t.a)], keep order:false, stats:pseudo")) tk.MustQuery("select /*+ INL_HASH_JOIN(s) */ * from t join s on t.a=s.a order by t.a;").Check(testkit.Rows("1 1", "128 128")) } @@ -1257,11 +1256,11 @@ func (s *testSuiteJoin3) TestMergejoinOrder(c *C) { tk.MustExec("insert into t2 select a*100, b*100 from t1;") tk.MustQuery("explain select /*+ TIDB_SMJ(t2) */ * from t1 left outer join t2 on t1.a=t2.a and t1.a!=3 order by t1.a;").Check(testkit.Rows( - "MergeJoin_20 10000.00 root left outer join, left key:test.t1.a, right key:test.t2.a, left cond:[ne(test.t1.a, 3)]", - "├─TableReader_14(Build) 6666.67 root data:TableRangeScan_13", - "│ └─TableRangeScan_13 6666.67 cop[tikv] table:t2, range:[-inf,3), (3,+inf], keep order:true, stats:pseudo", - "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", - " └─TableFullScan_11 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo", + "MergeJoin_20 10000.00 root left outer join, left key:test.t1.a, right key:test.t2.a, left cond:[ne(test.t1.a, 3)]", + "├─TableReader_14(Build) 6666.67 root data:TableRangeScan_13", + "│ └─TableRangeScan_13 6666.67 cop[tikv] table:t2 range:[-inf,3), (3,+inf], keep order:true, stats:pseudo", + "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", + " └─TableFullScan_11 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo", )) tk.MustExec("set @@tidb_init_chunk_size=1") @@ -1314,20 +1313,21 @@ func (s *testSuiteJoin1) TestHashJoin(c *C) { tk.MustQuery("select count(*) from t2").Check(testkit.Rows("0")) tk.MustExec("set @@tidb_init_chunk_size=1;") result := tk.MustQuery("explain analyze select /*+ TIDB_HJ(t1, t2) */ * from t1 where exists (select a from t2 where t1.a = t2.a);") - // HashLeftJoin_9 7992.00 root semi join, inner:TableReader_15, equal:[eq(test.t1.a, test.t2.a)] time:219.863µs, loops:1, rows:0 - // ├─TableReader_15(Build) 9990.00 root data:Selection_14 time:12.983µs, loops:1, rows:0 - // │ └─Selection_14 9990.00 cop[tikv] not(isnull(test.t2.a)) - // │ └─TableFullScan_13 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo time:0s, loops:0, rows:0 - // └─TableReader_12(Probe) 9990.00 root data:Selection_11 time:9.129µs, loops:1, rows:1 - // └─Selection_11 9990.00 cop[tikv] not(isnull(test.t1.a)) - // └─TableFullScan_10 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo time:0s, loops:0, rows:5 + // 0 1 2 3 4 5 6 7 8 + // 0 HashJoin_9 7992.00 0 root time:959.436µs, loops:1, Concurrency:5, probe collision:0, build:0s semi join, equal:[eq(test.t1.a, test.t2.a)] 0 Bytes 0 Bytes + // 1 ├─TableReader_15(Build) 9990.00 0 root time:583.499µs, loops:1, rpc num: 1, rpc time:563.325µs, proc keys:0 data:Selection_14 141 Bytes N/A + // 2 │ └─Selection_14 9990.00 0 cop[tikv] time:53.674µs, loops:1 not(isnull(test.t2.a)) N/A N/A + // 3 │ └─TableFullScan_13 10000.00 0 cop[tikv] table:t2 time:52.14µs, loops:1 keep order:false, stats:pseudo N/A N/A + // 4 └─TableReader_12(Probe) 9990.00 5 root time:779.503µs, loops:1, rpc num: 1, rpc time:794.929µs, proc keys:0 data:Selection_11 241 Bytes N/A + // 5 └─Selection_11 9990.00 5 cop[tikv] time:243.395µs, loops:6 not(isnull(test.t1.a)) N/A N/A + // 6 └─TableFullScan_10 10000.00 5 cop[tikv] table:t1 time:206.273µs, loops:6 keep order:false, stats:pseudo N/A N/A row := result.Rows() c.Assert(len(row), Equals, 7) - outerExecInfo := row[4][5].(string) + innerActRows := row[1][2].(string) + c.Assert(innerActRows, Equals, "0") + outerActRows := row[4][2].(string) // FIXME: revert this result to 1 after TableReaderExecutor can handle initChunkSize. - c.Assert(outerExecInfo[strings.Index(outerExecInfo, "rows")+5:strings.Index(outerExecInfo, "rows")+6], Equals, "5") - innerExecInfo := row[1][5].(string) - c.Assert(innerExecInfo[strings.Index(innerExecInfo, "rows")+5:strings.Index(innerExecInfo, "rows")+6], Equals, "0") + c.Assert(outerActRows, Equals, "5") } func (s *testSuiteJoin1) TestJoinDifferentDecimals(c *C) { @@ -1795,12 +1795,12 @@ func (s *testSuiteJoinSerial) TestOuterTableBuildHashTableIsuse13933(c *C) { tk.MustExec("insert into s values (1,2),(2,1),(11,11)") tk.MustQuery("select * from t left join s on s.a > t.a").Sort().Check(testkit.Rows("1 2 11 11", "1 2 2 1", "11 11 ")) tk.MustQuery("explain select * from t left join s on s.a > t.a").Check(testkit.Rows( - "HashLeftJoin_6 99900000.00 root CARTESIAN left outer join, other cond:gt(test.s.a, test.t.a)", - "├─TableReader_8(Build) 10000.00 root data:TableFullScan_7", - "│ └─TableFullScan_7 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo", - "└─TableReader_11(Probe) 9990.00 root data:Selection_10", - " └─Selection_10 9990.00 cop[tikv] not(isnull(test.s.a))", - " └─TableFullScan_9 10000.00 cop[tikv] table:s, keep order:false, stats:pseudo")) + "HashJoin_6 99900000.00 root CARTESIAN left outer join, other cond:gt(test.s.a, test.t.a)", + "├─TableReader_8(Build) 10000.00 root data:TableFullScan_7", + "│ └─TableFullScan_7 10000.00 cop[tikv] table:t keep order:false, stats:pseudo", + "└─TableReader_11(Probe) 9990.00 root data:Selection_10", + " └─Selection_10 9990.00 cop[tikv] not(isnull(test.s.a))", + " └─TableFullScan_9 10000.00 cop[tikv] table:s keep order:false, stats:pseudo")) tk.MustExec("drop table if exists t, s") tk.MustExec("Create table s (a int, b int, key(b))") tk.MustExec("Create table t (a int, b int, key(b))") @@ -1808,14 +1808,14 @@ func (s *testSuiteJoinSerial) TestOuterTableBuildHashTableIsuse13933(c *C) { tk.MustExec("Insert into t values (11,2),(1,2),(5,2)") tk.MustQuery("select /*+ INL_HASH_JOIN(s)*/ * from t left join s on s.b=t.b and s.a < t.a;").Sort().Check(testkit.Rows("1 2 ", "11 2 1 2", "5 2 1 2")) tk.MustQuery("explain select /*+ INL_HASH_JOIN(s)*/ * from t left join s on s.b=t.b and s.a < t.a;").Check(testkit.Rows( - "IndexHashJoin_22 12475.01 root left outer join, inner:IndexLookUp_11, outer key:test.t.b, inner key:test.s.b, other cond:lt(test.s.a, test.t.a)", - "├─TableReader_24(Build) 10000.00 root data:TableFullScan_23", - "│ └─TableFullScan_23 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo", - "└─IndexLookUp_11(Probe) 1.25 root ", - " ├─Selection_9(Build) 1.25 cop[tikv] not(isnull(test.s.b))", - " │ └─IndexRangeScan_7 1.25 cop[tikv] table:s, index:b, range: decided by [eq(test.s.b, test.t.b)], keep order:false, stats:pseudo", - " └─Selection_10(Probe) 1.25 cop[tikv] not(isnull(test.s.a))", - " └─TableRowIDScan_8 1.25 cop[tikv] table:s, keep order:false, stats:pseudo")) + "IndexHashJoin_22 12475.01 root left outer join, inner:IndexLookUp_11, outer key:test.t.b, inner key:test.s.b, other cond:lt(test.s.a, test.t.a)", + "├─TableReader_24(Build) 10000.00 root data:TableFullScan_23", + "│ └─TableFullScan_23 10000.00 cop[tikv] table:t keep order:false, stats:pseudo", + "└─IndexLookUp_11(Probe) 1.25 root ", + " ├─Selection_9(Build) 1.25 cop[tikv] not(isnull(test.s.b))", + " │ └─IndexRangeScan_7 1.25 cop[tikv] table:s, index:b(b) range: decided by [eq(test.s.b, test.t.b)], keep order:false, stats:pseudo", + " └─Selection_10(Probe) 1.25 cop[tikv] not(isnull(test.s.a))", + " └─TableRowIDScan_8 1.25 cop[tikv] table:s keep order:false, stats:pseudo")) } func (s *testSuiteJoin1) TestIssue13177(c *C) { @@ -1888,3 +1888,36 @@ func (s *testSuiteJoinSerial) TestOuterMatchStatusIssue14742(c *C) { "2 1", )) } + +func (s *testSuiteJoinSerial) TestInlineProjection4HashJoinIssue15316(c *C) { + // Two necessary factors to reproduce this issue: + // (1) taking HashLeftJoin, i.e., letting the probing tuple lay at the left side of joined tuples + // (2) the projection only contains a part of columns from the build side, i.e., pruning the same probe side + plannercore.ForcedHashLeftJoin4Test = true + defer func() { plannercore.ForcedHashLeftJoin4Test = false }() + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("create table S (a int not null, b int, c int);") + tk.MustExec("create table T (a int not null, b int, c int);") + tk.MustExec("insert into S values (0,1,2),(0,1,null),(0,1,2);") + tk.MustExec("insert into T values (0,10,2),(0,10,null),(1,10,2);") + tk.MustQuery("select T.a,T.a,T.c from S join T on T.a = S.a where S.b", + "0 0 ", + "0 0 ", + "0 0 2", + "0 0 2", + "0 0 2", + )) + // NOTE: the HashLeftJoin should be kept + tk.MustQuery("explain select T.a,T.a,T.c from S join T on T.a = S.a where S.b= t.b) from t").Check(testkit.Rows( - "Projection_7 10000.00 root Column#7", - "└─MergeJoin_8 10000.00 root left outer semi join, other cond:eq(test.t.a, test.s.a), ge(test.s.b, test.t.b)", - " ├─TableReader_12(Build) 10000.00 root data:TableFullScan_11", - " │ └─TableFullScan_11 10000.00 cop[tikv] table:s, keep order:false, stats:pseudo", - " └─TableReader_10(Probe) 10000.00 root data:TableFullScan_9", - " └─TableFullScan_9 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo", + "Projection_7 10000.00 root Column#7", + "└─MergeJoin_8 10000.00 root left outer semi join, other cond:eq(test.t.a, test.s.a), ge(test.s.b, test.t.b)", + " ├─TableReader_12(Build) 10000.00 root data:TableFullScan_11", + " │ └─TableFullScan_11 10000.00 cop[tikv] table:s keep order:false, stats:pseudo", + " └─TableReader_10(Probe) 10000.00 root data:TableFullScan_9", + " └─TableFullScan_9 10000.00 cop[tikv] table:t keep order:false, stats:pseudo", )) tk.MustQuery("select /*+ TIDB_SMJ(t, s) */ a in (select a from s where s.b >= t.b) from t").Check(testkit.Rows( "1", @@ -420,16 +420,16 @@ func (s *testSuite2) TestMergeJoin(c *C) { tk.MustExec("create table s (a int)") tk.MustExec("insert into s values (4), (1), (3), (2)") tk.MustQuery("explain select s1.a1 from (select a as a1 from s order by s.a desc) as s1 join (select a as a2 from s order by s.a desc) as s2 on s1.a1 = s2.a2 order by s1.a1 desc").Check(testkit.Rows( - "Projection_27 12487.50 root test.s.a", - "└─MergeJoin_28 12487.50 root inner join, left key:test.s.a, right key:test.s.a", - " ├─Sort_31(Build) 9990.00 root test.s.a:desc", - " │ └─TableReader_26 9990.00 root data:Selection_25", - " │ └─Selection_25 9990.00 cop[tikv] not(isnull(test.s.a))", - " │ └─TableFullScan_24 10000.00 cop[tikv] table:s, keep order:false, stats:pseudo", - " └─Sort_29(Probe) 9990.00 root test.s.a:desc", - " └─TableReader_21 9990.00 root data:Selection_20", - " └─Selection_20 9990.00 cop[tikv] not(isnull(test.s.a))", - " └─TableFullScan_19 10000.00 cop[tikv] table:s, keep order:false, stats:pseudo", + "Projection_27 12487.50 root test.s.a", + "└─MergeJoin_28 12487.50 root inner join, left key:test.s.a, right key:test.s.a", + " ├─Sort_31(Build) 9990.00 root test.s.a:desc", + " │ └─TableReader_26 9990.00 root data:Selection_25", + " │ └─Selection_25 9990.00 cop[tikv] not(isnull(test.s.a))", + " │ └─TableFullScan_24 10000.00 cop[tikv] table:s keep order:false, stats:pseudo", + " └─Sort_29(Probe) 9990.00 root test.s.a:desc", + " └─TableReader_21 9990.00 root data:Selection_20", + " └─Selection_20 9990.00 cop[tikv] not(isnull(test.s.a))", + " └─TableFullScan_19 10000.00 cop[tikv] table:s keep order:false, stats:pseudo", )) tk.MustQuery("select s1.a1 from (select a as a1 from s order by s.a desc) as s1 join (select a as a2 from s order by s.a desc) as s2 on s1.a1 = s2.a2 order by s1.a1 desc").Check(testkit.Rows( "4", "3", "2", "1")) @@ -524,24 +524,24 @@ func (s *testSuiteJoin3) TestVectorizedMergeJoin(c *C) { insert("t2", t2) tk.MustQuery("explain select /*+ TIDB_SMJ(t1, t2) */ * from t1, t2 where t1.a=t2.a and t1.b>5 and t2.b<5").Check(testkit.Rows( - `MergeJoin_7 4150.01 root inner join, left key:test.t1.a, right key:test.t2.a`, - `├─Sort_15(Build) 3320.01 root test.t2.a:asc`, - `│ └─TableReader_14 3320.01 root data:Selection_13`, - `│ └─Selection_13 3320.01 cop[tikv] lt(test.t2.b, 5), not(isnull(test.t2.a))`, - `│ └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo`, - `└─Sort_11(Probe) 3330.00 root test.t1.a:asc`, - ` └─TableReader_10 3330.00 root data:Selection_9`, - ` └─Selection_9 3330.00 cop[tikv] gt(test.t1.b, 5), not(isnull(test.t1.a))`, - ` └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo`, + `MergeJoin_7 4150.01 root inner join, left key:test.t1.a, right key:test.t2.a`, + `├─Sort_15(Build) 3320.01 root test.t2.a:asc`, + `│ └─TableReader_14 3320.01 root data:Selection_13`, + `│ └─Selection_13 3320.01 cop[tikv] lt(test.t2.b, 5), not(isnull(test.t2.a))`, + `│ └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo`, + `└─Sort_11(Probe) 3330.00 root test.t1.a:asc`, + ` └─TableReader_10 3330.00 root data:Selection_9`, + ` └─Selection_9 3330.00 cop[tikv] gt(test.t1.b, 5), not(isnull(test.t1.a))`, + ` └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo`, )) tk.MustQuery("explain select /*+ TIDB_HJ(t1, t2) */ * from t1, t2 where t1.a=t2.a and t1.b>5 and t2.b<5").Check(testkit.Rows( - `HashLeftJoin_7 4150.01 root inner join, equal:[eq(test.t1.a, test.t2.a)]`, - `├─TableReader_14(Build) 3320.01 root data:Selection_13`, - `│ └─Selection_13 3320.01 cop[tikv] lt(test.t2.b, 5), not(isnull(test.t2.a))`, - `│ └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo`, - `└─TableReader_11(Probe) 3330.00 root data:Selection_10`, - ` └─Selection_10 3330.00 cop[tikv] gt(test.t1.b, 5), not(isnull(test.t1.a))`, - ` └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo`, + `HashJoin_7 4150.01 root inner join, equal:[eq(test.t1.a, test.t2.a)]`, + `├─TableReader_14(Build) 3320.01 root data:Selection_13`, + `│ └─Selection_13 3320.01 cop[tikv] lt(test.t2.b, 5), not(isnull(test.t2.a))`, + `│ └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo`, + `└─TableReader_11(Probe) 3330.00 root data:Selection_10`, + ` └─Selection_10 3330.00 cop[tikv] gt(test.t1.b, 5), not(isnull(test.t1.a))`, + ` └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo`, )) r1 := tk.MustQuery("select /*+ TIDB_SMJ(t1, t2) */ * from t1, t2 where t1.a=t2.a and t1.b>5 and t2.b<5").Sort() diff --git a/executor/point_get.go b/executor/point_get.go index 387e6a9cfaccb..71043fe25b131 100644 --- a/executor/point_get.go +++ b/executor/point_get.go @@ -72,6 +72,14 @@ type PointGetExecutor struct { lock bool lockWaitTime int64 rowDecoder *rowcodec.ChunkDecoder + + columns []*model.ColumnInfo + // virtualColumnIndex records all the indices of virtual columns and sort them in definition + // to make sure we can compute the virtual column in right order. + virtualColumnIndex []int + + // virtualColumnRetFieldTypes records the RetFieldTypes of virtual columns. + virtualColumnRetFieldTypes []*types.FieldType } // Init set fields needed for PointGetExecutor reuse, this does NOT change baseExecutor field @@ -87,6 +95,19 @@ func (e *PointGetExecutor) Init(p *plannercore.PointGetPlan, startTs uint64) { e.lockWaitTime = p.LockWaitTime e.rowDecoder = decoder e.partInfo = p.PartitionInfo + e.columns = p.Columns + e.buildVirtualColumnInfo() +} + +// buildVirtualColumnInfo saves virtual column indices and sort them in definition order +func (e *PointGetExecutor) buildVirtualColumnInfo() { + e.virtualColumnIndex = buildVirtualColumnIndex(e.Schema(), e.columns) + if len(e.virtualColumnIndex) > 0 { + e.virtualColumnRetFieldTypes = make([]*types.FieldType, len(e.virtualColumnIndex)) + for i, idx := range e.virtualColumnIndex { + e.virtualColumnRetFieldTypes[i] = e.schema.Columns[idx].RetType + } + } } // Open implements the Executor interface. @@ -183,7 +204,17 @@ func (e *PointGetExecutor) Next(ctx context.Context, req *chunk.Chunk) error { } return nil } - return decodeRowValToChunk(e.base(), e.tblInfo, e.handle, val, req, e.rowDecoder) + err = decodeRowValToChunk(e.base(), e.tblInfo, e.handle, val, req, e.rowDecoder) + if err != nil { + return err + } + + err = FillVirtualColumnValue(e.virtualColumnRetFieldTypes, e.virtualColumnIndex, + e.schema, e.columns, e.ctx, req) + if err != nil { + return err + } + return nil } func (e *PointGetExecutor) lockKeyIfNeeded(ctx context.Context, key []byte) error { @@ -280,6 +311,11 @@ func decodeOldRowValToChunk(e *baseExecutor, tblInfo *model.TableInfo, handle in } decoder := codec.NewDecoder(chk, e.ctx.GetSessionVars().Location()) for i, col := range e.schema.Columns { + // fill the virtual column value after row calculation + if col.VirtualExpr != nil { + chk.AppendNull(i) + continue + } if tblInfo.PKIsHandle && mysql.HasPriKeyFlag(col.RetType.Flag) { chk.AppendInt64(i, handle) continue diff --git a/executor/point_get_test.go b/executor/point_get_test.go index f9cb2bdb3aef0..73bca25ea6f98 100644 --- a/executor/point_get_test.go +++ b/executor/point_get_test.go @@ -374,39 +374,39 @@ func (s *testPointGetSuite) TestIssue10448(c *C) { tk.MustExec("drop table if exists t") tk.MustExec("create table t(pk int1 primary key)") tk.MustExec("insert into t values(125)") - tk.MustQuery("desc select * from t where pk = 9223372036854775807").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 18446744073709551616").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 9223372036854775808").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 18446744073709551615").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 128").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 9223372036854775807").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 18446744073709551616").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 9223372036854775808").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 18446744073709551615").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 128").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) tk.MustExec("drop table if exists t") tk.MustExec("create table t(pk int8 primary key)") tk.MustExec("insert into t values(9223372036854775807)") tk.MustQuery("select * from t where pk = 9223372036854775807").Check(testkit.Rows("9223372036854775807")) - tk.MustQuery("desc select * from t where pk = 9223372036854775807").Check(testkit.Rows("Point_Get_1 1.00 root table:t, handle:9223372036854775807")) - tk.MustQuery("desc select * from t where pk = 18446744073709551616").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 9223372036854775808").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 18446744073709551615").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 9223372036854775807").Check(testkit.Rows("Point_Get_1 1.00 root table:t handle:9223372036854775807")) + tk.MustQuery("desc select * from t where pk = 18446744073709551616").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 9223372036854775808").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 18446744073709551615").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) tk.MustExec("drop table if exists t") tk.MustExec("create table t(pk int1 unsigned primary key)") tk.MustExec("insert into t values(255)") tk.MustQuery("select * from t where pk = 255").Check(testkit.Rows("255")) - tk.MustQuery("desc select * from t where pk = 256").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 9223372036854775807").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 18446744073709551616").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 9223372036854775808").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 18446744073709551615").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 256").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 9223372036854775807").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 18446744073709551616").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 9223372036854775808").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 18446744073709551615").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) tk.MustExec("drop table if exists t") tk.MustExec("create table t(pk int8 unsigned primary key)") tk.MustExec("insert into t value(18446744073709551615)") - tk.MustQuery("desc select * from t where pk = 18446744073709551615").Check(testkit.Rows("Point_Get_1 1.00 root table:t, handle:18446744073709551615")) + tk.MustQuery("desc select * from t where pk = 18446744073709551615").Check(testkit.Rows("Point_Get_1 1.00 root table:t handle:18446744073709551615")) tk.MustQuery("select * from t where pk = 18446744073709551615").Check(testkit.Rows("18446744073709551615")) - tk.MustQuery("desc select * from t where pk = 9223372036854775807").Check(testkit.Rows("Point_Get_1 1.00 root table:t, handle:9223372036854775807")) - tk.MustQuery("desc select * from t where pk = 18446744073709551616").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) - tk.MustQuery("desc select * from t where pk = 9223372036854775808").Check(testkit.Rows("Point_Get_1 1.00 root table:t, handle:9223372036854775808")) + tk.MustQuery("desc select * from t where pk = 9223372036854775807").Check(testkit.Rows("Point_Get_1 1.00 root table:t handle:9223372036854775807")) + tk.MustQuery("desc select * from t where pk = 18446744073709551616").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 9223372036854775808").Check(testkit.Rows("Point_Get_1 1.00 root table:t handle:9223372036854775808")) } func (s *testPointGetSuite) TestIssue10677(c *C) { @@ -415,15 +415,15 @@ func (s *testPointGetSuite) TestIssue10677(c *C) { tk.MustExec("drop table if exists t") tk.MustExec("create table t(pk int1 primary key)") tk.MustExec("insert into t values(1)") - tk.MustQuery("desc select * from t where pk = 1.1").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = 1.1").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) tk.MustQuery("select * from t where pk = 1.1").Check(testkit.Rows()) - tk.MustQuery("desc select * from t where pk = '1.1'").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) + tk.MustQuery("desc select * from t where pk = '1.1'").Check(testkit.Rows("TableDual_2 0.00 root rows:0")) tk.MustQuery("select * from t where pk = '1.1'").Check(testkit.Rows()) - tk.MustQuery("desc select * from t where pk = 1").Check(testkit.Rows("Point_Get_1 1.00 root table:t, handle:1")) + tk.MustQuery("desc select * from t where pk = 1").Check(testkit.Rows("Point_Get_1 1.00 root table:t handle:1")) tk.MustQuery("select * from t where pk = 1").Check(testkit.Rows("1")) - tk.MustQuery("desc select * from t where pk = '1'").Check(testkit.Rows("Point_Get_1 1.00 root table:t, handle:1")) + tk.MustQuery("desc select * from t where pk = '1'").Check(testkit.Rows("Point_Get_1 1.00 root table:t handle:1")) tk.MustQuery("select * from t where pk = '1'").Check(testkit.Rows("1")) - tk.MustQuery("desc select * from t where pk = '1.0'").Check(testkit.Rows("Point_Get_1 1.00 root table:t, handle:1")) + tk.MustQuery("desc select * from t where pk = '1.0'").Check(testkit.Rows("Point_Get_1 1.00 root table:t handle:1")) tk.MustQuery("select * from t where pk = '1.0'").Check(testkit.Rows("1")) } @@ -449,7 +449,7 @@ func (s *testPointGetSuite) TestPointGetByRowID(c *C) { tk.MustExec("create table t (a varchar(20), b int)") tk.MustExec("insert into t values(\"aaa\", 12)") tk.MustQuery("explain select * from t where t._tidb_rowid = 1").Check(testkit.Rows( - "Point_Get_1 1.00 root table:t, handle:1")) + "Point_Get_1 1.00 root table:t handle:1")) tk.MustQuery("select * from t where t._tidb_rowid = 1").Check(testkit.Rows("aaa 12")) } diff --git a/executor/prepared.go b/executor/prepared.go index 8c84b82e88333..ef23df97cd5fb 100644 --- a/executor/prepared.go +++ b/executor/prepared.go @@ -200,9 +200,12 @@ func (e *PrepareExec) Next(ctx context.Context, req *chunk.Chunk) error { vars.PreparedStmtNameToID[e.name] = e.ID } + normalized, digest := parser.NormalizeDigest(prepared.Stmt.Text()) preparedObj := &plannercore.CachedPrepareStmt{ - PreparedAst: prepared, - VisitInfos: destBuilder.GetVisitInfo(), + PreparedAst: prepared, + VisitInfos: destBuilder.GetVisitInfo(), + NormalizedSQL: normalized, + SQLDigest: digest, } return vars.AddPreparedStmt(e.ID, preparedObj) } @@ -315,8 +318,10 @@ func CompileExecutePreparedStmt(ctx context.Context, sctx sessionctx.Context, if !ok { return nil, errors.Errorf("invalid CachedPrepareStmt type") } + stmtCtx := sctx.GetSessionVars().StmtCtx stmt.Text = preparedObj.PreparedAst.Stmt.Text() - sctx.GetSessionVars().StmtCtx.OriginalSQL = stmt.Text + stmtCtx.OriginalSQL = stmt.Text + stmtCtx.InitSQLDigest(preparedObj.NormalizedSQL, preparedObj.SQLDigest) } return stmt, nil } diff --git a/executor/seqtest/seq_executor_test.go b/executor/seqtest/seq_executor_test.go index b30646fe4c56c..86cf58c503bf1 100644 --- a/executor/seqtest/seq_executor_test.go +++ b/executor/seqtest/seq_executor_test.go @@ -55,6 +55,7 @@ import ( "github.com/pingcap/tidb/store/mockstore/mocktikv" "github.com/pingcap/tidb/store/tikv" "github.com/pingcap/tidb/store/tikv/tikvrpc" + "github.com/pingcap/tidb/util/collate" "github.com/pingcap/tidb/util/gcutil" "github.com/pingcap/tidb/util/logutil" "github.com/pingcap/tidb/util/mock" @@ -179,6 +180,7 @@ func (s stats) Stats(vars *variable.SessionVars) (map[string]interface{}, error) } func (s *seqTestSuite) TestShow(c *C) { + config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") @@ -1193,6 +1195,44 @@ func (s *seqTestSuite1) TestCoprocessorPriority(c *C) { cli.mu.Unlock() } +func (s *seqTestSuite) TestShowForNewCollations(c *C) { + collate.SetNewCollationEnabledForTest(true) + defer collate.SetNewCollationEnabledForTest(false) + + tk := testkit.NewTestKit(c, s.store) + expectRows := testkit.Rows( + "ascii_bin ascii 65 Yes Yes 1", + "binary binary 63 Yes Yes 1", + "latin1_bin latin1 47 Yes Yes 1", + "utf8_bin utf8 83 Yes Yes 1", + "utf8_general_ci utf8 33 Yes 1", + "utf8mb4_bin utf8mb4 46 Yes Yes 1", + "utf8mb4_general_ci utf8mb4 45 Yes 1", + ) + tk.MustQuery("show collation").Check(expectRows) + tk.MustQuery("select * from information_schema.COLLATIONS").Check(expectRows) +} + +func (s *seqTestSuite) TestForbidUnsupportedCollations(c *C) { + collate.SetNewCollationEnabledForTest(true) + defer collate.SetNewCollationEnabledForTest(false) + + tk := testkit.NewTestKit(c, s.store) + mustGetUnsupportedCollation := func(sql string, coll string) { + tk.MustGetErrMsg(sql, fmt.Sprintf("[ddl:1273]Unsupported collation when new collation is enabled: '%s'", coll)) + } + + mustGetUnsupportedCollation("select 'a' collate utf8_unicode_ci", "utf8_unicode_ci") + mustGetUnsupportedCollation("select cast('a' as char) collate utf8_unicode_ci", "utf8_unicode_ci") + mustGetUnsupportedCollation("set names utf8 collate utf8_unicode_ci", "utf8_unicode_ci") + mustGetUnsupportedCollation("set session collation_server = 'utf8_unicode_ci'", "utf8_unicode_ci") + mustGetUnsupportedCollation("set session collation_database = 'utf8_unicode_ci'", "utf8_unicode_ci") + mustGetUnsupportedCollation("set session collation_connection = 'utf8_unicode_ci'", "utf8_unicode_ci") + mustGetUnsupportedCollation("set global collation_server = 'utf8_unicode_ci'", "utf8_unicode_ci") + mustGetUnsupportedCollation("set global collation_database = 'utf8_unicode_ci'", "utf8_unicode_ci") + mustGetUnsupportedCollation("set global collation_connection = 'utf8_unicode_ci'", "utf8_unicode_ci") +} + func (s *seqTestSuite) TestAutoIncIDInRetry(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("drop table if exists t;") diff --git a/executor/set.go b/executor/set.go index 2dc64669b6314..0ab7f9fbd5650 100644 --- a/executor/set.go +++ b/executor/set.go @@ -208,6 +208,8 @@ func (e *SetExecutor) setSysVariable(name string, v *expression.VarAssignment) e switch name { case variable.TiDBEnableStmtSummary: stmtsummary.StmtSummaryByDigestMap.SetEnabled(valStr, !v.IsGlobal) + case variable.TiDBStmtSummaryInternalQuery: + stmtsummary.StmtSummaryByDigestMap.SetEnabledInternalQuery(valStr, !v.IsGlobal) case variable.TiDBStmtSummaryRefreshInterval: stmtsummary.StmtSummaryByDigestMap.SetRefreshInterval(valStr, !v.IsGlobal) case variable.TiDBStmtSummaryHistorySize: @@ -222,17 +224,25 @@ func (e *SetExecutor) setSysVariable(name string, v *expression.VarAssignment) e func (e *SetExecutor) setCharset(cs, co string) error { var err error if len(co) == 0 { - co, err = charset.GetDefaultCollation(cs) - if err != nil { + if co, err = charset.GetDefaultCollation(cs); err != nil { + return err + } + } else { + var coll *charset.Collation + if coll, err = charset.GetCollationByName(co); err != nil { return err } + if coll.CharsetName != cs { + return charset.ErrCollationCharsetMismatch.GenWithStackByArgs(coll.Name, cs) + } } sessionVars := e.ctx.GetSessionVars() for _, v := range variable.SetNamesVariables { - terror.Log(sessionVars.SetSystemVar(v, cs)) + if err = sessionVars.SetSystemVar(v, cs); err != nil { + return errors.Trace(err) + } } - terror.Log(sessionVars.SetSystemVar(variable.CollationConnection, co)) - return nil + return errors.Trace(sessionVars.SetSystemVar(variable.CollationConnection, co)) } func (e *SetExecutor) getVarValue(v *expression.VarAssignment, sysVar *variable.SysVar) (value types.Datum, err error) { diff --git a/executor/set_test.go b/executor/set_test.go index 31230257bc9ee..53ac6305513b9 100644 --- a/executor/set_test.go +++ b/executor/set_test.go @@ -137,6 +137,15 @@ func (s *testSuite5) TestSetVar(c *C) { c.Assert(charset, Equals, "utf8") c.Assert(collation, Equals, "utf8_bin") + expectErrMsg := "[ddl:1273]Unknown collation: 'non_exist_collation'" + tk.MustGetErrMsg("set names utf8 collate non_exist_collation", expectErrMsg) + tk.MustGetErrMsg("set @@session.collation_server='non_exist_collation'", expectErrMsg) + tk.MustGetErrMsg("set @@session.collation_database='non_exist_collation'", expectErrMsg) + tk.MustGetErrMsg("set @@session.collation_connection='non_exist_collation'", expectErrMsg) + tk.MustGetErrMsg("set @@global.collation_server='non_exist_collation'", expectErrMsg) + tk.MustGetErrMsg("set @@global.collation_database='non_exist_collation'", expectErrMsg) + tk.MustGetErrMsg("set @@global.collation_connection='non_exist_collation'", expectErrMsg) + tk.MustExec("set character_set_results = NULL") tk.MustQuery("select @@character_set_results").Check(testkit.Rows("")) diff --git a/executor/show.go b/executor/show.go index 8950dfe15cdc3..aa03fccb9461e 100644 --- a/executor/show.go +++ b/executor/show.go @@ -54,6 +54,7 @@ import ( "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/types/json" "github.com/pingcap/tidb/util/chunk" + "github.com/pingcap/tidb/util/collate" "github.com/pingcap/tidb/util/format" "github.com/pingcap/tidb/util/hack" "github.com/pingcap/tidb/util/sqlexec" @@ -1086,7 +1087,7 @@ func (e *ShowExec) fetchShowCreateDatabase() error { } func (e *ShowExec) fetchShowCollation() error { - collations := charset.GetSupportedCollations() + collations := collate.GetSupportedCollations() for _, v := range collations { isDefault := "" if v.IsDefault { diff --git a/executor/simple_test.go b/executor/simple_test.go index 548b36d94042f..2e365de48053d 100644 --- a/executor/simple_test.go +++ b/executor/simple_test.go @@ -59,6 +59,22 @@ func (s *testSuite3) TestDo(c *C) { tk.MustQuery("select @a").Check(testkit.Rows("1")) } +func (s *testSuite3) TestSetRoleAllCorner(c *C) { + // For user with no role, `SET ROLE ALL` should active + // a empty slice, rather than nil. + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("create user set_role_all") + se, err := session.CreateSession4Test(s.store) + c.Check(err, IsNil) + defer se.Close() + c.Assert(se.Auth(&auth.UserIdentity{Username: "set_role_all", Hostname: "localhost"}, nil, nil), IsTrue) + ctx := context.Background() + _, err = se.Execute(ctx, `set role all`) + c.Assert(err, IsNil) + _, err = se.Execute(ctx, `select current_role`) + c.Assert(err, IsNil) +} + func (s *testSuite3) TestCreateRole(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("create user testCreateRole;") diff --git a/executor/table_reader.go b/executor/table_reader.go index 8cea2e21b8bf2..8af87b7c40ae5 100644 --- a/executor/table_reader.go +++ b/executor/table_reader.go @@ -166,24 +166,9 @@ func (e *TableReaderExecutor) Next(ctx context.Context, req *chunk.Chunk) error return err } - virCols := chunk.NewChunkWithCapacity(e.virtualColumnRetFieldTypes, req.Capacity()) - iter := chunk.NewIterator4Chunk(req) - - for i, idx := range e.virtualColumnIndex { - for row := iter.Begin(); row != iter.End(); row = iter.Next() { - datum, err := e.schema.Columns[idx].EvalVirtualColumn(row) - if err != nil { - return err - } - // Because the expression might return different type from - // the generated column, we should wrap a CAST on the result. - castDatum, err := table.CastValue(e.ctx, datum, e.columns[idx]) - if err != nil { - return err - } - virCols.AppendDatum(i, &castDatum) - } - req.SetCol(idx, virCols.Column(i)) + err := FillVirtualColumnValue(e.virtualColumnRetFieldTypes, e.virtualColumnIndex, e.schema, e.columns, e.ctx, req) + if err != nil { + return nil } return nil diff --git a/executor/testdata/agg_suite_out.json b/executor/testdata/agg_suite_out.json index 67c17674e0e67..ab65db16fb991 100644 --- a/executor/testdata/agg_suite_out.json +++ b/executor/testdata/agg_suite_out.json @@ -3,11 +3,11 @@ "Name": "TestInjectProjBelowTopN", "Cases": [ [ - "Projection_10 10000.00 root test.t.i", - "└─Sort_4 10000.00 root Column#3:asc", - " └─Projection_11 10000.00 root test.t.i, plus(test.t.i, 1)->Column#3", - " └─TableReader_8 10000.00 root data:TableFullScan_7", - " └─TableFullScan_7 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_10 10000.00 root test.t.i", + "└─Sort_4 10000.00 root Column#3:asc", + " └─Projection_11 10000.00 root test.t.i, plus(test.t.i, 1)->Column#3", + " └─TableReader_8 10000.00 root data:TableFullScan_7", + " └─TableFullScan_7 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], [ "1", @@ -21,12 +21,12 @@ "3" ], [ - "Projection_15 2.00 root test.t.i", - "└─TopN_7 2.00 root Column#3:asc, offset:0, count:2", - " └─Projection_16 2.00 root test.t.i, plus(test.t.i, 1)->Column#3", - " └─TableReader_12 2.00 root data:TopN_11", - " └─TopN_11 2.00 cop[tikv] plus(test.t.i, 1):asc, offset:0, count:2", - " └─TableFullScan_10 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_15 2.00 root test.t.i", + "└─TopN_7 2.00 root Column#3:asc, offset:0, count:2", + " └─Projection_16 2.00 root test.t.i, plus(test.t.i, 1)->Column#3", + " └─TableReader_12 2.00 root data:TopN_11", + " └─TopN_11 2.00 cop[tikv] plus(test.t.i, 1):asc, offset:0, count:2", + " └─TableFullScan_10 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], [ "1", @@ -49,32 +49,32 @@ "Name": "TestIssue12759HashAggCalledByApply", "Cases": [ [ - "Projection_28 1.00 root Column#3, Column#6, Column#9, Column#12", - "└─Apply_30 1.00 root CARTESIAN left outer join", - " ├─Apply_32(Build) 1.00 root CARTESIAN left outer join", - " │ ├─Apply_34(Build) 1.00 root CARTESIAN left outer join", - " │ │ ├─HashAgg_39(Build) 1.00 root funcs:sum(Column#22)->Column#3, funcs:firstrow(Column#23)->test.test.a", - " │ │ │ └─TableReader_40 1.00 root data:HashAgg_35", - " │ │ │ └─HashAgg_35 1.00 cop[tikv] funcs:sum(test.test.a)->Column#22, funcs:firstrow(test.test.a)->Column#23", - " │ │ │ └─TableFullScan_38 10000.00 cop[tikv] table:tt, keep order:false, stats:pseudo", - " │ │ └─Projection_43(Probe) 1.00 root ->Column#6", - " │ │ └─Limit_44 1.00 root offset:0, count:1", - " │ │ └─TableReader_50 1.00 root data:Limit_49", - " │ │ └─Limit_49 1.00 cop[tikv] offset:0, count:1", - " │ │ └─Selection_48 1.00 cop[tikv] eq(test.test.a, test.test.a)", - " │ │ └─TableFullScan_47 1000.00 cop[tikv] table:test, keep order:false, stats:pseudo", - " │ └─Projection_54(Probe) 1.00 root ->Column#9", - " │ └─Limit_55 1.00 root offset:0, count:1", - " │ └─TableReader_61 1.00 root data:Limit_60", - " │ └─Limit_60 1.00 cop[tikv] offset:0, count:1", - " │ └─Selection_59 1.00 cop[tikv] eq(test.test.a, test.test.a)", - " │ └─TableFullScan_58 1000.00 cop[tikv] table:test, keep order:false, stats:pseudo", - " └─Projection_65(Probe) 1.00 root ->Column#12", - " └─Limit_66 1.00 root offset:0, count:1", - " └─TableReader_72 1.00 root data:Limit_71", - " └─Limit_71 1.00 cop[tikv] offset:0, count:1", - " └─Selection_70 1.00 cop[tikv] eq(test.test.a, test.test.a)", - " └─TableFullScan_69 1000.00 cop[tikv] table:test, keep order:false, stats:pseudo" + "Projection_28 1.00 root Column#3, Column#6, Column#9, Column#12", + "└─Apply_30 1.00 root CARTESIAN left outer join", + " ├─Apply_32(Build) 1.00 root CARTESIAN left outer join", + " │ ├─Apply_34(Build) 1.00 root CARTESIAN left outer join", + " │ │ ├─HashAgg_39(Build) 1.00 root funcs:sum(Column#22)->Column#3, funcs:firstrow(Column#23)->test.test.a", + " │ │ │ └─TableReader_40 1.00 root data:HashAgg_35", + " │ │ │ └─HashAgg_35 1.00 cop[tikv] funcs:sum(test.test.a)->Column#22, funcs:firstrow(test.test.a)->Column#23", + " │ │ │ └─TableFullScan_38 10000.00 cop[tikv] table:tt keep order:false, stats:pseudo", + " │ │ └─Projection_43(Probe) 1.00 root ->Column#6", + " │ │ └─Limit_44 1.00 root offset:0, count:1", + " │ │ └─TableReader_50 1.00 root data:Limit_49", + " │ │ └─Limit_49 1.00 cop[tikv] offset:0, count:1", + " │ │ └─Selection_48 1.00 cop[tikv] eq(test.test.a, test.test.a)", + " │ │ └─TableFullScan_47 1000.00 cop[tikv] table:test keep order:false, stats:pseudo", + " │ └─Projection_54(Probe) 1.00 root ->Column#9", + " │ └─Limit_55 1.00 root offset:0, count:1", + " │ └─TableReader_61 1.00 root data:Limit_60", + " │ └─Limit_60 1.00 cop[tikv] offset:0, count:1", + " │ └─Selection_59 1.00 cop[tikv] eq(test.test.a, test.test.a)", + " │ └─TableFullScan_58 1000.00 cop[tikv] table:test keep order:false, stats:pseudo", + " └─Projection_65(Probe) 1.00 root ->Column#12", + " └─Limit_66 1.00 root offset:0, count:1", + " └─TableReader_72 1.00 root data:Limit_71", + " └─Limit_71 1.00 cop[tikv] offset:0, count:1", + " └─Selection_70 1.00 cop[tikv] eq(test.test.a, test.test.a)", + " └─TableFullScan_69 1000.00 cop[tikv] table:test keep order:false, stats:pseudo" ] ] } diff --git a/executor/update.go b/executor/update.go index 7ff80e7228c96..58ee206219089 100644 --- a/executor/update.go +++ b/executor/update.go @@ -17,13 +17,11 @@ import ( "context" "fmt" - "github.com/pingcap/errors" "github.com/pingcap/parser/model" "github.com/pingcap/parser/mysql" "github.com/pingcap/tidb/expression" "github.com/pingcap/tidb/kv" plannercore "github.com/pingcap/tidb/planner/core" - "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util/chunk" @@ -52,7 +50,7 @@ type UpdateExec struct { } func (e *UpdateExec) exec(ctx context.Context, schema *expression.Schema, row, newData []types.Datum) error { - assignFlag, err := e.getUpdateColumns(e.ctx, schema.Len()) + assignFlag, err := plannercore.GetUpdateColumns(e.ctx, e.OrderedList, schema.Len()) if err != nil { return err } @@ -269,18 +267,6 @@ func (e *UpdateExec) Open(ctx context.Context) error { return e.children[0].Open(ctx) } -func (e *UpdateExec) getUpdateColumns(ctx sessionctx.Context, schemaLen int) ([]bool, error) { - assignFlag := make([]bool, schemaLen) - for _, v := range e.OrderedList { - if !ctx.GetSessionVars().AllowWriteRowID && v.Col.ID == model.ExtraHandleID { - return nil, errors.Errorf("insert, update and replace statements for _tidb_rowid are not supported.") - } - idx := v.Col.Index - assignFlag[idx] = true - } - return assignFlag, nil -} - // setMessage sets info message(ERR_UPDATE_INFO) generated by UPDATE statement func (e *UpdateExec) setMessage() { stmtCtx := e.ctx.GetSessionVars().StmtCtx diff --git a/executor/window.go b/executor/window.go index 2257b8fb3867c..dcc2776bec92f 100644 --- a/executor/window.go +++ b/executor/window.go @@ -429,28 +429,59 @@ func (p *rangeFrameWindowProcessor) getEndOffset(ctx sessionctx.Context, rows [] } func (p *rangeFrameWindowProcessor) appendResult2Chunk(ctx sessionctx.Context, rows []chunk.Row, chk *chunk.Chunk, remained int) ([]chunk.Row, error) { - for remained > 0 { - start, err := p.getStartOffset(ctx, rows) + var ( + err error + initializedSlidingWindow bool + start uint64 + end uint64 + lastStart uint64 + lastEnd uint64 + shiftStart uint64 + shiftEnd uint64 + ) + slidingWindowAggFuncs := make([]aggfuncs.SlidingWindowAggFunc, len(p.windowFuncs)) + for i, windowFunc := range p.windowFuncs { + if slidingWindowAggFunc, ok := windowFunc.(aggfuncs.SlidingWindowAggFunc); ok { + slidingWindowAggFuncs[i] = slidingWindowAggFunc + } + } + for ; remained > 0; lastStart, lastEnd = start, end { + start, err = p.getStartOffset(ctx, rows) if err != nil { return nil, err } - end, err := p.getEndOffset(ctx, rows) + end, err = p.getEndOffset(ctx, rows) if err != nil { return nil, err } p.curRowIdx++ remained-- + shiftStart = start - lastStart + shiftEnd = end - lastEnd if start >= end { for i, windowFunc := range p.windowFuncs { - err := windowFunc.AppendFinalResult2Chunk(ctx, p.partialResults[i], chk) + slidingWindowAggFunc := slidingWindowAggFuncs[i] + if slidingWindowAggFunc != nil && initializedSlidingWindow { + err = slidingWindowAggFunc.Slide(ctx, rows, lastStart, lastEnd, shiftStart, shiftEnd, p.partialResults[i]) + if err != nil { + return nil, err + } + } + err = windowFunc.AppendFinalResult2Chunk(ctx, p.partialResults[i], chk) if err != nil { return nil, err } } continue } + for i, windowFunc := range p.windowFuncs { - err := windowFunc.UpdatePartialResult(ctx, rows[start:end], p.partialResults[i]) + slidingWindowAggFunc := slidingWindowAggFuncs[i] + if slidingWindowAggFunc != nil && initializedSlidingWindow { + err = slidingWindowAggFunc.Slide(ctx, rows, lastStart, lastEnd, shiftStart, shiftEnd, p.partialResults[i]) + } else { + err = windowFunc.UpdatePartialResult(ctx, rows[start:end], p.partialResults[i]) + } if err != nil { return nil, err } @@ -458,8 +489,16 @@ func (p *rangeFrameWindowProcessor) appendResult2Chunk(ctx sessionctx.Context, r if err != nil { return nil, err } - windowFunc.ResetPartialResult(p.partialResults[i]) + if slidingWindowAggFunc == nil { + windowFunc.ResetPartialResult(p.partialResults[i]) + } } + if !initializedSlidingWindow { + initializedSlidingWindow = true + } + } + for i, windowFunc := range p.windowFuncs { + windowFunc.ResetPartialResult(p.partialResults[i]) } return rows, nil } diff --git a/executor/window_test.go b/executor/window_test.go index babec8e2956db..f6f3f692024f9 100644 --- a/executor/window_test.go +++ b/executor/window_test.go @@ -14,6 +14,7 @@ package executor_test import ( + "fmt" . "github.com/pingcap/check" "github.com/pingcap/tidb/util/testkit" ) @@ -222,8 +223,20 @@ func (s *testSuite7) TestWindowFunctionsDataReference(c *C) { func (s *testSuite7) TestSlidingWindowFunctions(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test;") - tk.MustExec("drop table if exists t;") - tk.MustExec("CREATE TABLE t (id INTEGER, sex CHAR(1));") + idTypes := []string{"INTEGER", "FLOAT", "DOUBLE"} + useHighPrecisions := []string{"ON", "OFF"} + for _, idType := range idTypes { + for _, useHighPrecision := range useHighPrecisions { + tk.MustExec("drop table if exists t;") + tk.MustExec(fmt.Sprintf("CREATE TABLE t (id %s, sex CHAR(1));", idType)) + tk.MustExec(fmt.Sprintf("SET SESSION windowing_use_high_precision = %s;", useHighPrecision)) + baseTestSlidingWindowFunctions(tk) + } + } +} + +func baseTestSlidingWindowFunctions(tk *testkit.TestKit) { + var result *testkit.Result tk.MustExec("insert into t values (1,'M')") tk.MustExec("insert into t values (2,'F')") tk.MustExec("insert into t values (3,'F')") @@ -231,11 +244,10 @@ func (s *testSuite7) TestSlidingWindowFunctions(c *C) { tk.MustExec("insert into t values (5,'M')") tk.MustExec("insert into t values (10,null)") tk.MustExec("insert into t values (11,null)") - tk.MustExec("PREPARE p FROM 'SELECT sex, COUNT(id) OVER (ORDER BY id ROWS BETWEEN ? PRECEDING and ? PRECEDING) FROM t';") tk.MustExec("SET @p1= 1;") tk.MustExec("SET @p2= 2;") - result := tk.MustQuery("EXECUTE p USING @p1, @p2;") + result = tk.MustQuery("EXECUTE p USING @p1, @p2;") result.Check(testkit.Rows("M 0", "F 0", "F 0", "F 0", "M 0", " 0", " 0")) result = tk.MustQuery("EXECUTE p USING @p2, @p1;") result.Check(testkit.Rows("M 0", "F 1", "F 2", "F 2", "M 2", " 2", " 2")) @@ -249,15 +261,47 @@ func (s *testSuite7) TestSlidingWindowFunctions(c *C) { result.Check(testkit.Rows("M 2", "F 2", "F 2", "F 2", "M 2", " 1", " 0")) tk.MustExec("DROP PREPARE p;") + // COUNT ROWS result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id ROWS BETWEEN 1 FOLLOWING and 2 FOLLOWING) FROM t;") result.Check(testkit.Rows("M 2", "F 2", "F 2", "F 2", "M 2", " 1", " 0")) - result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id ROWS BETWEEN 3 FOLLOWING and 1 FOLLOWING) FROM t;") result.Check(testkit.Rows("M 0", "F 0", "F 0", "F 0", "M 0", " 0", " 0")) - - result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id ROWS BETWEEN 2 preceding and 1 preceding) FROM t;") + result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id ROWS BETWEEN 2 PRECEDING and 1 PRECEDING) FROM t;") result.Check(testkit.Rows("M 0", "F 1", "F 2", "F 2", "M 2", " 2", " 2")) + result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id ROWS BETWEEN 1 PRECEDING and 3 PRECEDING) FROM t;") + result.Check(testkit.Rows("M 0", "F 0", "F 0", "F 0", "M 0", " 0", " 0")) - result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id ROWS BETWEEN 1 preceding and 3 preceding) FROM t;") + // COUNT RANGE + result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id RANGE BETWEEN 1 FOLLOWING and 2 FOLLOWING) FROM t;") + result.Check(testkit.Rows("M 2", "F 2", "F 2", "F 1", "M 0", " 1", " 0")) + result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id RANGE BETWEEN 3 FOLLOWING and 1 FOLLOWING) FROM t;") result.Check(testkit.Rows("M 0", "F 0", "F 0", "F 0", "M 0", " 0", " 0")) + result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id RANGE BETWEEN 2 PRECEDING and 1 PRECEDING) FROM t;") + result.Check(testkit.Rows("M 0", "F 1", "F 2", "F 2", "M 2", " 0", " 1")) + result = tk.MustQuery("SELECT sex, COUNT(id) OVER (ORDER BY id RANGE BETWEEN 1 PRECEDING and 3 PRECEDING) FROM t;") + result.Check(testkit.Rows("M 0", "F 0", "F 0", "F 0", "M 0", " 0", " 0")) + + // SUM ROWS + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id ROWS BETWEEN 1 FOLLOWING and 2 FOLLOWING) FROM t;") + result.Check(testkit.Rows("M 5", "F 7", "F 9", "F 15", "M 21", " 11", " ")) + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id ROWS BETWEEN 3 FOLLOWING and 1 FOLLOWING) FROM t;") + result.Check(testkit.Rows("M ", "F ", "F ", "F ", "M ", " ", " ")) + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id ROWS BETWEEN 2 PRECEDING and 1 PRECEDING) FROM t;") + result.Check(testkit.Rows("M ", "F 1", "F 3", "F 5", "M 7", " 9", " 15")) + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id ROWS BETWEEN 1 PRECEDING and 3 PRECEDING) FROM t;") + result.Check(testkit.Rows("M ", "F ", "F ", "F ", "M ", " ", " ")) + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING and 1 FOLLOWING) FROM t;") + result.Check(testkit.Rows("M 3", "F 6", "F 10", "F 15", "M 25", " 36", " 36")) + + // SUM RANGE + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id RANGE BETWEEN 1 FOLLOWING and 2 FOLLOWING) FROM t;") + result.Check(testkit.Rows("M 5", "F 7", "F 9", "F 5", "M ", " 11", " ")) + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id RANGE BETWEEN 3 FOLLOWING and 1 FOLLOWING) FROM t;") + result.Check(testkit.Rows("M ", "F ", "F ", "F ", "M ", " ", " ")) + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id RANGE BETWEEN 2 PRECEDING and 1 PRECEDING) FROM t;") + result.Check(testkit.Rows("M ", "F 1", "F 3", "F 5", "M 7", " ", " 10")) + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id RANGE BETWEEN 1 PRECEDING and 2 FOLLOWING) FROM t;") + result.Check(testkit.Rows("M 6", "F 10", "F 14", "F 12", "M 9", " 21", " 21")) + result = tk.MustQuery("SELECT sex, SUM(id) OVER (ORDER BY id DESC RANGE BETWEEN 1 PRECEDING and 2 FOLLOWING) FROM t;") + result.Check(testkit.Rows(" 21", " 21", "M 12", "F 14", "F 10", "F 6", "M 3")) } diff --git a/executor/write_test.go b/executor/write_test.go index e98f24ae5dfcf..429efd0839e3c 100644 --- a/executor/write_test.go +++ b/executor/write_test.go @@ -268,7 +268,7 @@ func (s *testSuite) TestInsert(c *C) { tk.MustExec("insert into t value(20070219173709.055870), (20070219173709.055), (20070219173709.055870123)") tk.MustQuery("select * from t").Check(testkit.Rows("17:37:09.055870", "17:37:09.055000", "17:37:09.055870")) _, err = tk.Exec("insert into t value(-20070219173709.055870)") - c.Assert(err.Error(), Equals, "[types:1525]Incorrect time value: '-20070219173709.055870'") + c.Assert(err.Error(), Equals, "[table:1366]Incorrect time value: '-20070219173709.055870' for column 'a' at row 1") tk.MustExec("drop table if exists t") tk.MustExec("set @@sql_mode=''") diff --git a/expression/builtin_miscellaneous_vec.go b/expression/builtin_miscellaneous_vec.go index 3a0695cca6ba5..681837862cf39 100644 --- a/expression/builtin_miscellaneous_vec.go +++ b/expression/builtin_miscellaneous_vec.go @@ -334,20 +334,22 @@ func (b *builtinSleepSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) e } func doSleep(secs float64, sessVars *variable.SessionVars) (isKilled bool) { + if secs <= 0.0 { + return false + } dur := time.Duration(secs * float64(time.Second.Nanoseconds())) ticker := time.NewTicker(10 * time.Millisecond) defer ticker.Stop() - start := time.Now() + timer := time.NewTimer(dur) for { select { - case now := <-ticker.C: + case <-ticker.C: if atomic.CompareAndSwapUint32(&sessVars.Killed, 1, 0) { + timer.Stop() return true } - - if now.Sub(start) > dur { - return false - } + case <-timer.C: + return false } } } diff --git a/expression/builtin_other.go b/expression/builtin_other.go index e67e6037c6abb..e90c5d31e6016 100644 --- a/expression/builtin_other.go +++ b/expression/builtin_other.go @@ -797,6 +797,19 @@ func (b *builtinValuesIntSig) evalInt(_ chunk.Row) (int64, bool, error) { if row.IsNull(b.offset) { return 0, true, nil } + // For BinaryLiteral, see issue #15310 + val := row.GetRaw(b.offset) + if len(val) > 8 { + return 0, true, errors.New("Session current insert values is too long") + } + if len(val) < 8 { + var binary types.BinaryLiteral = val + v, err := binary.ToInt(b.ctx.GetSessionVars().StmtCtx) + if err != nil { + return 0, true, errors.Trace(err) + } + return int64(v), false, nil + } return row.GetInt64(b.offset), false, nil } return 0, true, errors.Errorf("Session current insert values len %d and column's offset %v don't match", row.Len(), b.offset) diff --git a/expression/builtin_string.go b/expression/builtin_string.go index b7e8306456b08..1d4c7636f3a31 100644 --- a/expression/builtin_string.go +++ b/expression/builtin_string.go @@ -2394,7 +2394,7 @@ func (b *builtinFindInSetSig) evalInt(row chunk.Row) (int64, bool, error) { } for i, strInSet := range strings.Split(strlist, ",") { - if b.ctor.Compare(str, strInSet, collate.NewCollatorOption(0)) == 0 { + if b.ctor.Compare(str, strInSet) == 0 { return int64(i + 1), false, nil } } @@ -2523,7 +2523,7 @@ func (b *builtinFieldStringSig) evalInt(row chunk.Row) (int64, bool, error) { if err != nil { return 0, true, err } - if !isNull && b.ctor.Compare(str, stri, collate.NewCollatorOption(0)) == 0 { + if !isNull && b.ctor.Compare(str, stri) == 0 { return int64(i), false, nil } } @@ -3816,5 +3816,5 @@ func (b *builtinWeightStringSig) evalString(row chunk.Row) (string, bool, error) default: return "", false, ErrIncorrectType.GenWithStackByArgs(ast.WeightString, string(b.padding)) } - return string(ctor.Key(str, collate.CollatorOption{PadLen: b.length})), false, nil + return string(ctor.Key(str)), false, nil } diff --git a/expression/builtin_string_vec.go b/expression/builtin_string_vec.go index dd64027aa5e7c..a45268ddb1d1c 100644 --- a/expression/builtin_string_vec.go +++ b/expression/builtin_string_vec.go @@ -29,7 +29,6 @@ import ( "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util/chunk" - "github.com/pingcap/tidb/util/collate" "github.com/pingcap/tidb/util/logutil" "go.uber.org/zap" "golang.org/x/text/transform" @@ -1058,7 +1057,7 @@ func (b *builtinFindInSetSig) vecEvalInt(input *chunk.Chunk, result *chunk.Colum continue } for j, strInSet := range strings.Split(strlistI, ",") { - if b.ctor.Compare(str.GetString(i), strInSet, collate.NewCollatorOption(0)) == 0 { + if b.ctor.Compare(str.GetString(i), strInSet) == 0 { res[i] = int64(j + 1) } } diff --git a/expression/constant_fold_test.go b/expression/constant_fold_test.go index 6d69b5186f0e0..7270595295920 100644 --- a/expression/constant_fold_test.go +++ b/expression/constant_fold_test.go @@ -25,9 +25,9 @@ func (s *testIntegrationSuite) TestFoldIfNull(c *C) { tk.MustExec(`create table t(a bigint, b bigint);`) tk.MustExec(`insert into t values(1, 1);`) tk.MustQuery(`desc select ifnull("aaaa", a) from t;`).Check(testkit.Rows( - `Projection_3 10000.00 root aaaa->Column#4`, - `└─TableReader_5 10000.00 root data:TableFullScan_4`, - ` └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo`, + `Projection_3 10000.00 root aaaa->Column#4`, + `└─TableReader_5 10000.00 root data:TableFullScan_4`, + ` └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo`, )) tk.MustQuery(`show warnings;`).Check(testkit.Rows()) tk.MustQuery(`select ifnull("aaaa", a) from t;`).Check(testkit.Rows("aaaa")) diff --git a/expression/expression.go b/expression/expression.go index 5e26cd8d8f6eb..cddaf493c9a30 100644 --- a/expression/expression.go +++ b/expression/expression.go @@ -34,6 +34,7 @@ import ( "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/types/json" "github.com/pingcap/tidb/util/chunk" + "github.com/pingcap/tidb/util/collate" "github.com/pingcap/tidb/util/logutil" "github.com/pingcap/tipb/go-tipb" "go.uber.org/zap" @@ -933,7 +934,7 @@ func canScalarFuncPushDown(scalarFunc *ScalarFunction, pc PbConverter, storeType } func canExprPushDown(expr Expression, pc PbConverter, storeType kv.StoreType) bool { - if storeType == kv.TiFlash && (expr.GetType().Tp == mysql.TypeDuration || expr.GetType().Tp == mysql.TypeJSON) { + if storeType == kv.TiFlash && (expr.GetType().Tp == mysql.TypeDuration || expr.GetType().Tp == mysql.TypeJSON || collate.NewCollationEnabled()) { return false } switch x := expr.(type) { diff --git a/expression/integration_test.go b/expression/integration_test.go index 42079d4e60e0d..b189b784128ff 100755 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -1212,7 +1212,7 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { tk.MustExec(`insert into t select year("0000-00-00 00:00:00")`) tk.MustExec(`set sql_mode="NO_ZERO_DATE";`) // with zero date tk.MustExec(`insert into t select year("0000-00-00 00:00:00")`) - tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) + tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) tk.MustExec(`set sql_mode="NO_ZERO_DATE,STRICT_TRANS_TABLES";`) _, err = tk.Exec(`insert into t select year("0000-00-00 00:00:00");`) c.Assert(err, NotNil) @@ -1243,7 +1243,7 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { tk.MustExec(`insert into t select month("0000-00-00 00:00:00")`) tk.MustExec(`set sql_mode="NO_ZERO_DATE";`) tk.MustExec(`insert into t select month("0000-00-00 00:00:00")`) - tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) + tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) tk.MustExec(`set sql_mode="NO_ZERO_DATE,STRICT_TRANS_TABLES";`) _, err = tk.Exec(`insert into t select month("0000-00-00 00:00:00");`) c.Assert(err, NotNil) @@ -1306,8 +1306,8 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { result = tk.MustQuery(`select quarter("0000-00-00"), quarter("0000-00-00 00:00:00");`) result.Check(testkit.Rows(" ")) tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", - "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00.000000'", - "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) + "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00.000000'", + "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) result = tk.MustQuery(`select quarter(0), quarter(0.0), quarter(0e1), quarter(0.00);`) result.Check(testkit.Rows("0 0 0 0")) tk.MustQuery("show warnings").Check(testkit.Rows()) @@ -1662,12 +1662,12 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { result = tk.MustQuery(`SELECT DATE_FORMAT('0000-00-00', '%W %M %e %Y %r %y');`) result.Check(testkit.Rows("")) tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", - "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) + "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) result = tk.MustQuery(`SELECT DATE_FORMAT('0', '%W %M %e %Y %r %y'), DATE_FORMAT('0.0', '%W %M %e %Y %r %y'), DATE_FORMAT(0, 0);`) result.Check(testkit.Rows(" 0")) tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", - "Warning|1525|Incorrect time value: '0'", - "Warning|1525|Incorrect time value: '0.0'")) + "Warning|1292|Incorrect time value: '0'", + "Warning|1292|Incorrect time value: '0.0'")) result = tk.MustQuery(`SELECT DATE_FORMAT(0, '%W %M %e %Y %r %y'), DATE_FORMAT(0.0, '%W %M %e %Y %r %y');`) result.Check(testkit.Rows(" ")) tk.MustQuery("show warnings").Check(testkit.Rows()) @@ -1702,23 +1702,23 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { tk.MustExec("set sql_mode = 'STRICT_TRANS_TABLES'") _, err = tk.Exec("insert into t value(dayOfWeek('0000-00-00'))") - c.Assert(types.ErrWrongValue.Equal(err), IsTrue) + c.Assert(table.ErrTruncatedWrongValueForField.Equal(err), IsTrue, Commentf("%v", err)) _, err = tk.Exec(`update t set a = dayOfWeek("0000-00-00")`) c.Assert(types.ErrWrongValue.Equal(err), IsTrue) _, err = tk.Exec(`delete from t where a = dayOfWeek(123)`) c.Assert(err, IsNil) _, err = tk.Exec("insert into t value(dayOfMonth('2017-00-00'))") - c.Assert(types.ErrWrongValue.Equal(err), IsTrue) + c.Assert(table.ErrTruncatedWrongValueForField.Equal(err), IsTrue) tk.MustExec("insert into t value(dayOfMonth('0000-00-00'))") tk.MustExec(`update t set a = dayOfMonth("0000-00-00")`) tk.MustExec("set sql_mode = 'NO_ZERO_DATE';") tk.MustExec("insert into t value(dayOfMonth('0000-00-00'))") - tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) + tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) tk.MustExec(`update t set a = dayOfMonth("0000-00-00")`) tk.MustExec("set sql_mode = 'NO_ZERO_DATE,STRICT_TRANS_TABLES';") _, err = tk.Exec("insert into t value(dayOfMonth('0000-00-00'))") - c.Assert(types.ErrWrongValue.Equal(err), IsTrue) + c.Assert(table.ErrTruncatedWrongValueForField.Equal(err), IsTrue) tk.MustExec("insert into t value(0)") _, err = tk.Exec(`update t set a = dayOfMonth("0000-00-00")`) c.Assert(types.ErrWrongValue.Equal(err), IsTrue) @@ -1726,7 +1726,7 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { c.Assert(err, IsNil) _, err = tk.Exec("insert into t value(dayOfYear('0000-00-00'))") - c.Assert(types.ErrWrongValue.Equal(err), IsTrue) + c.Assert(table.ErrTruncatedWrongValueForField.Equal(err), IsTrue) _, err = tk.Exec(`update t set a = dayOfYear("0000-00-00")`) c.Assert(types.ErrWrongValue.Equal(err), IsTrue) _, err = tk.Exec(`delete from t where a = dayOfYear(123)`) @@ -1803,7 +1803,7 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { tk.MustExec(`update t set a = monthname("0000-00-00")`) tk.MustExec("set sql_mode = 'NO_ZERO_DATE'") tk.MustExec("insert into t value(monthname('0000-00-00'))") - tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) + tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) tk.MustExec(`update t set a = monthname("0000-00-00")`) tk.MustExec("set sql_mode = ''") tk.MustExec("insert into t value(monthname('0000-00-00'))") @@ -1814,7 +1814,7 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { c.Assert(err, IsNil) result = tk.MustQuery(`select monthname("2017-12-01"), monthname("0000-00-00"), monthname("0000-01-00"), monthname("0000-01-00 00:00:00")`) result.Check(testkit.Rows("December January January")) - tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) + tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00.000000'")) // for dayname tk.MustExec(`drop table if exists t`) @@ -1823,7 +1823,7 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { tk.MustExec("set sql_mode = 'STRICT_TRANS_TABLES'") _, err = tk.Exec("insert into t value(dayname('0000-00-00'))") - c.Assert(types.ErrWrongValue.Equal(err), IsTrue) + c.Assert(table.ErrTruncatedWrongValueForField.Equal(err), IsTrue) _, err = tk.Exec(`update t set a = dayname("0000-00-00")`) c.Assert(types.ErrWrongValue.Equal(err), IsTrue) _, err = tk.Exec(`delete from t where a = dayname(123)`) @@ -1831,9 +1831,9 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { result = tk.MustQuery(`select dayname("2017-12-01"), dayname("0000-00-00"), dayname("0000-01-00"), dayname("0000-01-00 00:00:00")`) result.Check(testkit.Rows("Friday ")) tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", - "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00.000000'", - "Warning|1525|Incorrect datetime value: '0000-01-00 00:00:00.000000'", - "Warning|1525|Incorrect datetime value: '0000-01-00 00:00:00.000000'")) + "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00.000000'", + "Warning|1292|Incorrect datetime value: '0000-01-00 00:00:00.000000'", + "Warning|1292|Incorrect datetime value: '0000-01-00 00:00:00.000000'")) // for sec_to_time result = tk.MustQuery("select sec_to_time(NULL)") @@ -1865,7 +1865,7 @@ func (s *testIntegrationSuite2) TestTimeBuiltin(c *C) { result = tk.MustQuery("select str_to_date('01-01-2017', '%d'), str_to_date('59', '%d-%Y')") // TODO: MySQL returns " ". result.Check(testkit.Rows("0000-00-01 ")) - tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1525|Incorrect datetime value: '0000-00-00 00:00:00'")) + tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00'")) result = tk.MustQuery("select str_to_date('2018-6-1', '%Y-%m-%d'), str_to_date('2018-6-1', '%Y-%c-%d'), str_to_date('59:20:1', '%s:%i:%k'), str_to_date('59:20:1', '%s:%i:%l')") result.Check(testkit.Rows("2018-06-01 2018-06-01 01:20:59 01:20:59")) @@ -3427,9 +3427,9 @@ func (s *testIntegrationSuite) TestCompareBuiltin(c *C) { tk.MustExec("create table t(a date)") result = tk.MustQuery("desc select a = a from t") result.Check(testkit.Rows( - "Projection_3 10000.00 root eq(test.t.a, test.t.a)->Column#3", - "└─TableReader_5 10000.00 root data:TableFullScan_4", - " └─TableFullScan_4 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo", + "Projection_3 10000.00 root eq(test.t.a, test.t.a)->Column#3", + "└─TableReader_5 10000.00 root data:TableFullScan_4", + " └─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo", )) // for interval @@ -3455,14 +3455,14 @@ func (s *testIntegrationSuite) TestCompareBuiltin(c *C) { result = tk.MustQuery(`select greatest(cast("2017-01-01" as datetime), "123", "234", cast("2018-01-01" as date)), greatest(cast("2017-01-01" as date), "123", null)`) // todo: MySQL returns "2018-01-01 " result.Check(testkit.Rows("2018-01-01 00:00:00 ")) - tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1525|Incorrect time value: '123'", "Warning|1525|Incorrect time value: '234'", "Warning|1525|Incorrect time value: '123'")) + tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Incorrect time value: '123'", "Warning|1292|Incorrect time value: '234'", "Warning|1292|Incorrect time value: '123'")) // for least result = tk.MustQuery(`select least(1, 2, 3), least("a", "b", "c"), least(1.1, 1.2, 1.3), least("123a", 1, 2)`) result.Check(testkit.Rows("1 a 1.1 1")) tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect FLOAT value: '123a'")) result = tk.MustQuery(`select least(cast("2017-01-01" as datetime), "123", "234", cast("2018-01-01" as date)), least(cast("2017-01-01" as date), "123", null)`) result.Check(testkit.Rows("123 ")) - tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1525|Incorrect time value: '123'", "Warning|1525|Incorrect time value: '234'", "Warning|1525|Incorrect time value: '123'")) + tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Incorrect time value: '123'", "Warning|1292|Incorrect time value: '234'", "Warning|1292|Incorrect time value: '123'")) tk.MustQuery(`select 1 < 17666000000000000000, 1 > 17666000000000000000, 1 = 17666000000000000000`).Check(testkit.Rows("1 0 0")) tk.MustExec("drop table if exists t") @@ -3933,7 +3933,7 @@ func (s *testIntegrationSuite) TestTimeLiteral(c *C) { _, err = tk.Exec("select ADDDATE('2008-01-34', -1);") c.Assert(err, IsNil) tk.MustQuery("Show warnings;").Check(testutil.RowsWithSep("|", - "Warning|1525|Incorrect datetime value: '2008-01-34'")) + "Warning|1292|Incorrect datetime value: '2008-01-34'")) } func (s *testIntegrationSuite) TestIssue13822(c *C) { @@ -4381,12 +4381,12 @@ func (s *testIntegrationSuite) TestTiDBDecodePlanFunc(c *C) { defer s.cleanEnv(c) tk.MustQuery("select tidb_decode_plan('')").Check(testkit.Rows("")) tk.MustQuery("select tidb_decode_plan('7APIMAk1XzEzCTAJMQlmdW5jczpjb3VudCgxKQoxCTE3XzE0CTAJMAlpbm5lciBqb2luLCBp" + - "AQyQOlRhYmxlUmVhZGVyXzIxLCBlcXVhbDpbZXEoQ29sdW1uIzEsIA0KCDkpIBkXADIVFywxMCldCjIJMzJfMTgFZXhkYXRhOlNlbGVjdGlvbl" + + "AQyQOlRhYmxlUmVhZGVyXzIxLCBlcXVhbDpbZXEoQ29sdW1uIzEsIA0KCDkpIBkXADIVFywxMCldCjIJMzFfMTgFZXhkYXRhOlNlbGVjdGlvbl" + "8xNwozCTFfMTcJMQkwCWx0HVlATlVMTCksIG5vdChpc251bGwVHAApUhcAUDIpKQo0CTEwXzE2CTEJMTAwMDAJdAHB2Dp0MSwgcmFuZ2U6Wy1p" + "bmYsK2luZl0sIGtlZXAgb3JkZXI6ZmFsc2UsIHN0YXRzOnBzZXVkbwoFtgAyAZcEMAk6tgAEMjAFtgQyMDq2AAg5LCBmtgAAMFa3AAA5FbcAO" + "T63AAAyzrcA')").Check(testkit.Rows("" + "\tStreamAgg_13 \troot\t1 \tfuncs:count(1)\n" + - "\t└─HashLeftJoin_14 \troot\t0 \tinner join, inner:TableReader_21, equal:[eq(Column#1, Column#9) eq(Column#2, Column#10)]\n" + + "\t└─HashJoin_14 \troot\t0 \tinner join, inner:TableReader_21, equal:[eq(Column#1, Column#9) eq(Column#2, Column#10)]\n" + "\t ├─TableReader_18 \troot\t0 \tdata:Selection_17\n" + "\t │ └─Selection_17 \tcop \t0 \tlt(Column#1, NULL), not(isnull(Column#1)), not(isnull(Column#2))\n" + "\t │ └─TableScan_16\tcop \t10000\ttable:t1, range:[-inf,+inf], keep order:false, stats:pseudo\n" + @@ -4890,9 +4890,9 @@ func (s *testIntegrationSuite) TestTimestampDatumEncode(c *C) { tk.MustExec(`create table t (a bigint primary key, b timestamp)`) tk.MustExec(`insert into t values (1, "2019-04-29 11:56:12")`) tk.MustQuery(`explain select * from t where b = (select max(b) from t)`).Check(testkit.Rows( - "TableReader_43 10.00 root data:Selection_42", - "└─Selection_42 10.00 cop[tikv] eq(test.t.b, 2019-04-29 11:56:12)", - " └─TableFullScan_41 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo", + "TableReader_43 10.00 root data:Selection_42", + "└─Selection_42 10.00 cop[tikv] eq(test.t.b, 2019-04-29 11:56:12)", + " └─TableFullScan_41 10000.00 cop[tikv] table:t keep order:false, stats:pseudo", )) tk.MustQuery(`select * from t where b = (select max(b) from t)`).Check(testkit.Rows(`1 2019-04-29 11:56:12`)) } @@ -5341,6 +5341,21 @@ func (s *testIntegrationSuite) TestCastStrToInt(c *C) { } } +func (s *testIntegrationSuite) TestValuesForBinaryLiteral(c *C) { + // See issue #15310 + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test;") + tk.MustExec("create table testValuesBinary(id int primary key auto_increment, a bit(1));") + tk.MustExec("insert into testValuesBinary values(1,1);") + err := tk.ExecToErr("insert into testValuesBinary values(1,1) on duplicate key update id = values(id),a = values(a);") + c.Assert(err, IsNil) + tk.MustQuery("select a=0 from testValuesBinary;").Check(testkit.Rows("0")) + err = tk.ExecToErr("insert into testValuesBinary values(1,0) on duplicate key update id = values(id),a = values(a);") + c.Assert(err, IsNil) + tk.MustQuery("select a=0 from testValuesBinary;").Check(testkit.Rows("1")) + tk.MustExec("drop table testValuesBinary;") +} + func (s *testIntegrationSuite) TestIssue14159(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("DROP TABLE IF EXISTS t") diff --git a/expression/partition_pruner.go b/expression/partition_pruner.go index 1da37459ee267..bbf106a25cd6a 100644 --- a/expression/partition_pruner.go +++ b/expression/partition_pruner.go @@ -117,6 +117,19 @@ func (p *hashPartitionPruner) tryEvalPartitionExpr(piExpr Expression) (val int64 case ast.Div: return rightVal / leftVal, true, false } + } else if pi.FuncName.L == ast.Year || pi.FuncName.L == ast.Month || pi.FuncName.L == ast.ToDays { + col := pi.GetArgs()[0].(*Column) + idx := p.getColID(col) + val := p.constantMap[idx] + if val != nil { + pi.GetArgs()[0] = val + ret, _, err := pi.EvalInt(p.ctx, chunk.Row{}) + if err != nil { + return 0, false, false + } + return ret, true, false + } + return 0, false, false } case *Constant: val, err := pi.Eval(chunk.Row{}) diff --git a/expression/partition_pruner_test.go b/expression/partition_pruner_test.go index 88dd3c93d1d57..8f181d821169a 100644 --- a/expression/partition_pruner_test.go +++ b/expression/partition_pruner_test.go @@ -67,6 +67,8 @@ func (s *testSuite2) TestHashPartitionPruner(c *C) { tk.MustExec("create table t2(id int, a int, b int, primary key(id, a)) partition by hash(id + a) partitions 10;") tk.MustExec("create table t1(id int primary key, a int, b int) partition by hash(id) partitions 10;") tk.MustExec("create table t3(id int, a int, b int, primary key(id, a)) partition by hash(id) partitions 10;") + tk.MustExec("create table t4(d datetime, a int, b int, primary key(d, a)) partition by hash(year(d)) partitions 10;") + tk.MustExec("create table t5(d date, a int, b int, primary key(d, a)) partition by hash(month(d)) partitions 10;") var input []string var output []struct { diff --git a/expression/simple_rewriter.go b/expression/simple_rewriter.go index 3ac17173ee30a..e1b92dc4023e4 100644 --- a/expression/simple_rewriter.go +++ b/expression/simple_rewriter.go @@ -252,8 +252,7 @@ func (sr *simpleRewriter) Leave(originInNode ast.Node) (retNode ast.Node, ok boo if collate.NewCollationEnabled() { var collInfo *charset.Collation // TODO(bb7133): use charset.ValidCharsetAndCollation when its bug is fixed. - if collInfo, sr.err = charset.GetCollationByName(v.Collate); sr.err != nil { - sr.err = charset.ErrUnknownCollation.GenWithStackByArgs(v.Collate) + if collInfo, sr.err = collate.GetCollationByName(v.Collate); sr.err != nil { break } chs := arg.GetType().Charset diff --git a/expression/testdata/expression_suite_out.json b/expression/testdata/expression_suite_out.json index aa0668ff77904..1d0e6fb636ffc 100644 --- a/expression/testdata/expression_suite_out.json +++ b/expression/testdata/expression_suite_out.json @@ -5,274 +5,274 @@ { "SQL": "explain select * from t1 left join t2 on t1.a > t2.a and t1.a = 1", "Result": [ - "HashLeftJoin_6 33233333.33 root CARTESIAN left outer join, left cond:[eq(test.t1.a, 1)]", - "├─TableReader_12(Build) 3323.33 root data:Selection_11", - "│ └─Selection_11 3323.33 cop[tikv] gt(1, test.t2.a)", - "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 33233333.33 root CARTESIAN left outer join, left cond:[eq(test.t1.a, 1)]", + "├─TableReader_12(Build) 3323.33 root data:Selection_11", + "│ └─Selection_11 3323.33 cop[tikv] gt(1, test.t2.a)", + "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t1.a > t2.a where t1.a = 1", "Result": [ - "HashLeftJoin_8 33233.33 root CARTESIAN left outer join", - "├─TableReader_11(Build) 10.00 root data:Selection_10", - "│ └─Selection_10 10.00 cop[tikv] eq(test.t1.a, 1)", - "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_14(Probe) 3323.33 root data:Selection_13", - " └─Selection_13 3323.33 cop[tikv] gt(1, test.t2.a)", - " └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_8 33233.33 root CARTESIAN left outer join", + "├─TableReader_11(Build) 10.00 root data:Selection_10", + "│ └─Selection_10 10.00 cop[tikv] eq(test.t1.a, 1)", + "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_14(Probe) 3323.33 root data:Selection_13", + " └─Selection_13 3323.33 cop[tikv] gt(1, test.t2.a)", + " └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t1.a = t2.a and t1.a > 1", "Result": [ - "HashLeftJoin_6 10000.00 root left outer join, equal:[eq(test.t1.a, test.t2.a)], left cond:[gt(test.t1.a, 1)]", - "├─TableReader_12(Build) 3333.33 root data:Selection_11", - "│ └─Selection_11 3333.33 cop[tikv] gt(test.t2.a, 1), not(isnull(test.t2.a))", - "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 10000.00 root left outer join, equal:[eq(test.t1.a, test.t2.a)], left cond:[gt(test.t1.a, 1)]", + "├─TableReader_12(Build) 3333.33 root data:Selection_11", + "│ └─Selection_11 3333.33 cop[tikv] gt(test.t2.a, 1), not(isnull(test.t2.a))", + "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t1.a = t2.a where t1.a > 1", "Result": [ - "HashLeftJoin_7 4166.67 root left outer join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_14(Build) 3333.33 root data:Selection_13", - "│ └─Selection_13 3333.33 cop[tikv] gt(test.t2.a, 1), not(isnull(test.t2.a))", - "│ └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_11(Probe) 3333.33 root data:Selection_10", - " └─Selection_10 3333.33 cop[tikv] gt(test.t1.a, 1)", - " └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_7 4166.67 root left outer join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_14(Build) 3333.33 root data:Selection_13", + "│ └─Selection_13 3333.33 cop[tikv] gt(test.t2.a, 1), not(isnull(test.t2.a))", + "│ └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_11(Probe) 3333.33 root data:Selection_10", + " └─Selection_10 3333.33 cop[tikv] gt(test.t1.a, 1)", + " └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 right join t2 on t1.a > t2.a where t2.a = 1", "Result": [ - "HashRightJoin_8 33333.33 root CARTESIAN right outer join", - "├─TableReader_14(Build) 10.00 root data:Selection_13", - "│ └─Selection_13 10.00 cop[tikv] eq(test.t2.a, 1)", - "│ └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_11(Probe) 3333.33 root data:Selection_10", - " └─Selection_10 3333.33 cop[tikv] gt(test.t1.a, 1)", - " └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_8 33333.33 root CARTESIAN right outer join", + "├─TableReader_14(Build) 10.00 root data:Selection_13", + "│ └─Selection_13 10.00 cop[tikv] eq(test.t2.a, 1)", + "│ └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_11(Probe) 3333.33 root data:Selection_10", + " └─Selection_10 3333.33 cop[tikv] gt(test.t1.a, 1)", + " └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 right join t2 on t1.a = t2.a where t2.a > 1", "Result": [ - "HashRightJoin_7 4166.67 root right outer join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_11(Build) 3333.33 root data:Selection_10", - "│ └─Selection_10 3333.33 cop[tikv] gt(test.t1.a, 1), not(isnull(test.t1.a))", - "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_14(Probe) 3333.33 root data:Selection_13", - " └─Selection_13 3333.33 cop[tikv] gt(test.t2.a, 1)", - " └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_7 4166.67 root right outer join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_11(Build) 3333.33 root data:Selection_10", + "│ └─Selection_10 3333.33 cop[tikv] gt(test.t1.a, 1), not(isnull(test.t1.a))", + "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_14(Probe) 3333.33 root data:Selection_13", + " └─Selection_13 3333.33 cop[tikv] gt(test.t2.a, 1)", + " └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 right join t2 on t1.a = t2.a and t2.a > 1", "Result": [ - "HashRightJoin_6 10000.00 root right outer join, equal:[eq(test.t1.a, test.t2.a)], right cond:gt(test.t2.a, 1)", - "├─TableReader_10(Build) 3333.33 root data:Selection_9", - "│ └─Selection_9 3333.33 cop[tikv] gt(test.t1.a, 1), not(isnull(test.t1.a))", - "│ └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", - " └─TableFullScan_11 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_6 10000.00 root right outer join, equal:[eq(test.t1.a, test.t2.a)], right cond:gt(test.t2.a, 1)", + "├─TableReader_10(Build) 3333.33 root data:Selection_9", + "│ └─Selection_9 3333.33 cop[tikv] gt(test.t1.a, 1), not(isnull(test.t1.a))", + "│ └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", + " └─TableFullScan_11 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 right join t2 on t1.a > t2.a and t2.a = 1", "Result": [ - "HashRightJoin_6 33333333.33 root CARTESIAN right outer join, right cond:eq(test.t2.a, 1)", - "├─TableReader_10(Build) 3333.33 root data:Selection_9", - "│ └─Selection_9 3333.33 cop[tikv] gt(test.t1.a, 1)", - "│ └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", - " └─TableFullScan_11 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_6 33333333.33 root CARTESIAN right outer join, right cond:eq(test.t2.a, 1)", + "├─TableReader_10(Build) 3333.33 root data:Selection_9", + "│ └─Selection_9 3333.33 cop[tikv] gt(test.t1.a, 1)", + "│ └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", + " └─TableFullScan_11 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t1.a = t2.a and t2.a > 1", "Result": [ - "HashLeftJoin_6 10000.00 root left outer join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_12(Build) 3333.33 root data:Selection_11", - "│ └─Selection_11 3333.33 cop[tikv] gt(test.t2.a, 1), not(isnull(test.t2.a))", - "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 10000.00 root left outer join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_12(Build) 3333.33 root data:Selection_11", + "│ └─Selection_11 3333.33 cop[tikv] gt(test.t2.a, 1), not(isnull(test.t2.a))", + "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t1.a > t2.a and t2.a = 1", "Result": [ - "HashLeftJoin_6 100000.00 root CARTESIAN left outer join, other cond:gt(test.t1.a, test.t2.a)", - "├─TableReader_12(Build) 10.00 root data:Selection_11", - "│ └─Selection_11 10.00 cop[tikv] eq(test.t2.a, 1), not(isnull(test.t2.a))", - "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 100000.00 root CARTESIAN left outer join, other cond:gt(test.t1.a, test.t2.a)", + "├─TableReader_12(Build) 10.00 root data:Selection_11", + "│ └─Selection_11 10.00 cop[tikv] eq(test.t2.a, 1), not(isnull(test.t2.a))", + "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 right join t2 on t1.a > t2.a and t1.a = 1", "Result": [ - "HashRightJoin_6 100000.00 root CARTESIAN right outer join, other cond:gt(test.t1.a, test.t2.a)", - "├─TableReader_10(Build) 10.00 root data:Selection_9", - "│ └─Selection_9 10.00 cop[tikv] eq(test.t1.a, 1), not(isnull(test.t1.a))", - "│ └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", - " └─TableFullScan_11 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_6 100000.00 root CARTESIAN right outer join, other cond:gt(test.t1.a, test.t2.a)", + "├─TableReader_10(Build) 10.00 root data:Selection_9", + "│ └─Selection_9 10.00 cop[tikv] eq(test.t1.a, 1), not(isnull(test.t1.a))", + "│ └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", + " └─TableFullScan_11 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 right join t2 on t1.a = t2.a and t1.a > 1", "Result": [ - "HashRightJoin_6 10000.00 root right outer join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_10(Build) 3333.33 root data:Selection_9", - "│ └─Selection_9 3333.33 cop[tikv] gt(test.t1.a, 1), not(isnull(test.t1.a))", - "│ └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", - " └─TableFullScan_11 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_6 10000.00 root right outer join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_10(Build) 3333.33 root data:Selection_9", + "│ └─Selection_9 3333.33 cop[tikv] gt(test.t1.a, 1), not(isnull(test.t1.a))", + "│ └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11", + " └─TableFullScan_11 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t1.a = t1.b and t1.a > 1", "Result": [ - "HashLeftJoin_6 100000000.00 root CARTESIAN left outer join, left cond:[eq(test.t1.a, test.t1.b) gt(test.t1.a, 1)]", - "├─TableReader_11(Build) 10000.00 root data:TableFullScan_10", - "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 100000000.00 root CARTESIAN left outer join, left cond:[eq(test.t1.a, test.t1.b) gt(test.t1.a, 1)]", + "├─TableReader_11(Build) 10000.00 root data:TableFullScan_10", + "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t2.a = t2.b and t2.a > 1", "Result": [ - "HashLeftJoin_6 26666666.67 root CARTESIAN left outer join", - "├─TableReader_12(Build) 2666.67 root data:Selection_11", - "│ └─Selection_11 2666.67 cop[tikv] eq(test.t2.a, test.t2.b), gt(test.t2.a, 1)", - "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 26666666.67 root CARTESIAN left outer join", + "├─TableReader_12(Build) 2666.67 root data:Selection_11", + "│ └─Selection_11 2666.67 cop[tikv] eq(test.t2.a, test.t2.b), gt(test.t2.a, 1)", + "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on true where t1.a = 1 and false", "Result": [ - "TableDual_8 0.00 root rows:0" + "TableDual_8 0.00 root rows:0" ] }, { "SQL": "explain select * from t1 left join t2 on true where t1.a = 1 and null", "Result": [ - "TableDual_8 0.00 root rows:0" + "TableDual_8 0.00 root rows:0" ] }, { "SQL": "explain select * from t1 left join t2 on true where t1.a = null", "Result": [ - "TableDual_8 0.00 root rows:0" + "TableDual_8 0.00 root rows:0" ] }, { "SQL": "explain select * from t1 left join t2 on true where t1.a = 1 and t1.a = 2", "Result": [ - "TableDual_8 0.00 root rows:0" + "TableDual_8 0.00 root rows:0" ] }, { "SQL": "explain select * from t1 left join t2 on true where t1.a = 1 and t1.a = 1", "Result": [ - "HashLeftJoin_8 80000.00 root CARTESIAN left outer join", - "├─TableReader_11(Build) 10.00 root data:Selection_10", - "│ └─Selection_10 10.00 cop[tikv] eq(test.t1.a, 1)", - "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_12", - " └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_8 80000.00 root CARTESIAN left outer join", + "├─TableReader_11(Build) 10.00 root data:Selection_10", + "│ └─Selection_10 10.00 cop[tikv] eq(test.t1.a, 1)", + "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_12", + " └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on false", "Result": [ - "HashLeftJoin_6 80000000.00 root CARTESIAN left outer join", - "├─TableDual_10(Build) 8000.00 root rows:0", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 80000000.00 root CARTESIAN left outer join", + "├─TableDual_10(Build) 8000.00 root rows:0", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 right join t2 on false", "Result": [ - "HashRightJoin_6 80000000.00 root CARTESIAN right outer join", - "├─TableDual_8(Build) 8000.00 root rows:0", - "└─TableReader_10(Probe) 10000.00 root data:TableFullScan_9", - " └─TableFullScan_9 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_6 80000000.00 root CARTESIAN right outer join", + "├─TableDual_8(Build) 8000.00 root rows:0", + "└─TableReader_10(Probe) 10000.00 root data:TableFullScan_9", + " └─TableFullScan_9 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t1.a = 1 and t1.a = 2", "Result": [ - "HashLeftJoin_6 80000000.00 root CARTESIAN left outer join", - "├─TableDual_10(Build) 8000.00 root rows:0", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 80000000.00 root CARTESIAN left outer join", + "├─TableDual_10(Build) 8000.00 root rows:0", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t1.a =1 where t1.a = 2", "Result": [ - "HashLeftJoin_8 80000.00 root CARTESIAN left outer join", - "├─TableReader_11(Build) 10.00 root data:Selection_10", - "│ └─Selection_10 10.00 cop[tikv] eq(test.t1.a, 2)", - "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableDual_12(Probe) 8000.00 root rows:0" + "HashJoin_8 80000.00 root CARTESIAN left outer join", + "├─TableReader_11(Build) 10.00 root data:Selection_10", + "│ └─Selection_10 10.00 cop[tikv] eq(test.t1.a, 2)", + "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableDual_12(Probe) 8000.00 root rows:0" ] }, { "SQL": "explain select * from t1 left join t2 on t2.a = 1 and t2.a = 2", "Result": [ - "HashLeftJoin_6 10000.00 root CARTESIAN left outer join", - "├─TableReader_12(Build) 0.00 root data:Selection_11", - "│ └─Selection_11 0.00 cop[tikv] eq(test.t2.a, 1), eq(test.t2.a, 2)", - "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 10000.00 root CARTESIAN left outer join", + "├─TableReader_12(Build) 0.00 root data:Selection_11", + "│ └─Selection_11 0.00 cop[tikv] eq(test.t2.a, 1), eq(test.t2.a, 2)", + "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on t1.a = 1 or (t1.a = 2 and t1.a = 3)", "Result": [ - "HashLeftJoin_6 100000000.00 root CARTESIAN left outer join, left cond:[or(eq(test.t1.a, 1), 0)]", - "├─TableReader_11(Build) 10000.00 root data:TableFullScan_10", - "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", - " └─TableFullScan_8 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_6 100000000.00 root CARTESIAN left outer join, left cond:[or(eq(test.t1.a, 1), 0)]", + "├─TableReader_11(Build) 10000.00 root data:TableFullScan_10", + "│ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_9(Probe) 10000.00 root data:TableFullScan_8", + " └─TableFullScan_8 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 left join t2 on true where t1.a = 1 or (t1.a = 2 and t1.a = 3)", "Result": [ - "HashLeftJoin_8 80000.00 root CARTESIAN left outer join", - "├─TableReader_11(Build) 10.00 root data:Selection_10", - "│ └─Selection_10 10.00 cop[tikv] or(eq(test.t1.a, 1), 0)", - "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_12", - " └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_8 80000.00 root CARTESIAN left outer join", + "├─TableReader_11(Build) 10.00 root data:Selection_10", + "│ └─Selection_10 10.00 cop[tikv] or(eq(test.t1.a, 1), 0)", + "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_12", + " └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 where t1.b > 1 or t1.b in (select b from t2)", "Result": [ - "Projection_7 8000.00 root test.t1.id, test.t1.a, test.t1.b", - "└─Selection_8 8000.00 root or(gt(test.t1.b, 1), Column#7)", - " └─HashLeftJoin_9 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.b, test.t2.b)", - " ├─TableReader_13(Build) 10000.00 root data:TableFullScan_12", - " │ └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - " └─TableReader_11(Probe) 10000.00 root data:TableFullScan_10", - " └─TableFullScan_10 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "Projection_7 8000.00 root test.t1.id, test.t1.a, test.t1.b", + "└─Selection_8 8000.00 root or(gt(test.t1.b, 1), Column#7)", + " └─HashJoin_9 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.b, test.t2.b)", + " ├─TableReader_13(Build) 10000.00 root data:TableFullScan_12", + " │ └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + " └─TableReader_11(Probe) 10000.00 root data:TableFullScan_10", + " └─TableFullScan_10 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] } ] diff --git a/expression/testdata/partition_pruner_in.json b/expression/testdata/partition_pruner_in.json index 13664d5716d48..6f6e80fa85ff3 100644 --- a/expression/testdata/partition_pruner_in.json +++ b/expression/testdata/partition_pruner_in.json @@ -15,7 +15,10 @@ // Negtive cases. "explain select * from t1 left join t2 on true where t1.a = 1 and false", "explain select * from t1 left join t2 on true where t1.a = 1 and null", - "explain select * from t1 left join t2 on true where t1.a = null" + "explain select * from t1 left join t2 on true where t1.a = null", + // Case with date. + "explain select * from t4 where d = '2019-10-07 10:40:00' and a = 1", + "explain select * from t5 where d = '2019-10-07'" ] } ] diff --git a/expression/testdata/partition_pruner_out.json b/expression/testdata/partition_pruner_out.json index 0c89289ca14c3..fb96bb79b086b 100644 --- a/expression/testdata/partition_pruner_out.json +++ b/expression/testdata/partition_pruner_out.json @@ -5,78 +5,93 @@ { "SQL": "explain select * from t1 where id = 7 and a = 6", "Result": [ - "Selection_7 0.00 root eq(test_partition.t1.a, 6)", - "└─Point_Get_6 1.00 root table:t1, handle:7, partition:p7" + "Selection_7 0.00 root eq(test_partition.t1.a, 6)", + "└─Point_Get_6 1.00 root table:t1, partition:p7 handle:7" ] }, { "SQL": "explain select * from t3 where id = 9 and a = 1", "Result": [ - "Point_Get_1 1.00 root table:t3, index:id a, partition:p9" + "Point_Get_1 1.00 root table:t3, partition:p9, index:PRIMARY(id, a) " ] }, { "SQL": "explain select * from t2 where id = 9 and a = -110", "Result": [ - "Point_Get_6 1.00 root table:t2, index:id a, partition:p1" + "Point_Get_6 1.00 root table:t2, partition:p1, index:PRIMARY(id, a) " ] }, { "SQL": "explain select * from t1 where id = -17", "Result": [ - "Point_Get_6 1.00 root table:t1, handle:-17, partition:p7" + "Point_Get_6 1.00 root table:t1, partition:p7 handle:-17" ] }, { "SQL": "explain select * from t2 where id = a and a = b and b = 2", "Result": [ - "TableReader_8 8.00 root data:Selection_7", - "└─Selection_7 8.00 cop[tikv] eq(test_partition.t2.a, test_partition.t2.b), eq(test_partition.t2.b, 2), eq(test_partition.t2.id, test_partition.t2.a)", - " └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p4, keep order:false, stats:pseudo" + "TableReader_8 8.00 root data:Selection_7", + "└─Selection_7 8.00 cop[tikv] eq(test_partition.t2.a, test_partition.t2.b), eq(test_partition.t2.b, 2), eq(test_partition.t2.id, test_partition.t2.a)", + " └─TableFullScan_6 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from t1 join t2 on (t1.id = t2.id) where t1.id = 5 and t2.a = 7", "Result": [ - "HashLeftJoin_10 1.00 root CARTESIAN inner join", - "├─Point_Get_13(Build) 1.00 root table:t2, index:id a, partition:p2", - "└─Point_Get_12(Probe) 1.00 root table:t1, handle:5, partition:p5" + "HashJoin_10 1.00 root CARTESIAN inner join", + "├─Point_Get_13(Build) 1.00 root table:t2, partition:p2, index:PRIMARY(id, a) ", + "└─Point_Get_12(Probe) 1.00 root table:t1, partition:p5 handle:5" ] }, { "SQL": "explain select * from t1 left join t2 on t1.id = 1 and t2.a = 2 where t2.id = 7", "Result": [ - "HashLeftJoin_9 1.00 root CARTESIAN inner join", - "├─Point_Get_12(Build) 1.00 root table:t2, index:id a, partition:p9", - "└─Point_Get_11(Probe) 1.00 root table:t1, handle:1, partition:p1" + "HashJoin_9 1.00 root CARTESIAN inner join", + "├─Point_Get_12(Build) 1.00 root table:t2, partition:p9, index:PRIMARY(id, a) ", + "└─Point_Get_11(Probe) 1.00 root table:t1, partition:p1 handle:1" ] }, { "SQL": "explain select * from t2 join t1 on t1.id = t2.id and t2.a = t1.id and t2.id = 12", "Result": [ - "HashLeftJoin_9 1.00 root CARTESIAN inner join", - "├─Point_Get_12(Build) 1.00 root table:t1, handle:12, partition:p2", - "└─Point_Get_11(Probe) 1.00 root table:t2, index:id a, partition:p4" + "HashJoin_9 1.00 root CARTESIAN inner join", + "├─Point_Get_12(Build) 1.00 root table:t1, partition:p2 handle:12", + "└─Point_Get_11(Probe) 1.00 root table:t2, partition:p4, index:PRIMARY(id, a) " ] }, { "SQL": "explain select * from t1 left join t2 on true where t1.a = 1 and false", "Result": [ - "TableDual_8 0.00 root rows:0" + "TableDual_8 0.00 root rows:0" ] }, { "SQL": "explain select * from t1 left join t2 on true where t1.a = 1 and null", "Result": [ - "TableDual_8 0.00 root rows:0" + "TableDual_8 0.00 root rows:0" ] }, { "SQL": "explain select * from t1 left join t2 on true where t1.a = null", "Result": [ - "TableDual_8 0.00 root rows:0" + "TableDual_8 0.00 root rows:0" + ] + }, + { + "SQL": "explain select * from t4 where d = '2019-10-07 10:40:00' and a = 1", + "Result": [ + "Point_Get_6 1.00 root table:t4, partition:p9, index:PRIMARY(d, a) " + ] + }, + { + "SQL": "explain select * from t5 where d = '2019-10-07'", + "Result": [ + "IndexLookUp_11 10.00 root ", + "├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:t5, partition:p0, index:PRIMARY(d, a) range:[2019-10-07,2019-10-07], keep order:false, stats:pseudo", + "└─TableRowIDScan_10(Probe) 10.00 cop[tikv] table:t5, partition:p0 keep order:false, stats:pseudo" ] } ] } ] + diff --git a/go.sum b/go.sum index ed94b8ad844a1..79473a8cb3cd0 100644 --- a/go.sum +++ b/go.sum @@ -195,8 +195,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lawyerphx/parser v0.0.0-20200316023126-7af13c9e0b85 h1:my5oTuBLzT1knvQnwaF7RXxNuzvzqhioNM8OcHYF2/A= -github.com/lawyerphx/parser v0.0.0-20200316023126-7af13c9e0b85/go.mod h1:9v0Edh8IbgjGYW2ArJr19E+bvL8zKahsFp+ixWeId+4= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= diff --git a/infoschema/cluster.go b/infoschema/cluster.go index 2bb5505ed76e6..097cfb0c12447 100644 --- a/infoschema/cluster.go +++ b/infoschema/cluster.go @@ -19,7 +19,6 @@ import ( "github.com/pingcap/parser/mysql" "github.com/pingcap/tidb/domain/infosync" - "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util" ) @@ -30,13 +29,13 @@ import ( const ( // ClusterTableSlowLog is the string constant of cluster slow query memory table. ClusterTableSlowLog = "CLUSTER_SLOW_QUERY" - clusterTableProcesslist = "CLUSTER_PROCESSLIST" + ClusterTableProcesslist = "CLUSTER_PROCESSLIST" ) // memTableToClusterTables means add memory table to cluster table. var memTableToClusterTables = map[string]string{ TableSlowQuery: ClusterTableSlowLog, - tableProcesslist: clusterTableProcesslist, + TableProcesslist: ClusterTableProcesslist, } func init() { @@ -72,11 +71,6 @@ func isClusterTableByName(dbName, tableName string) bool { return false } -func dataForClusterProcesslist(ctx sessionctx.Context) (rows [][]types.Datum, err error) { - rows = dataForProcesslist(ctx) - return AppendHostInfoToRows(rows) -} - // AppendHostInfoToRows appends host info to the rows. func AppendHostInfoToRows(rows [][]types.Datum) ([][]types.Datum, error) { serverInfo, err := infosync.GetServerInfo() diff --git a/infoschema/metric_table_def.go b/infoschema/metric_table_def.go index ec2492705b6f5..53682b962c62c 100644 --- a/infoschema/metric_table_def.go +++ b/infoschema/metric_table_def.go @@ -3084,4 +3084,14 @@ var MetricTableMap = map[string]MetricTableDef{ Labels: []string{"instance"}, Comment: "The total size of snapshot size", }, + "tikv_config_rocksdb": { + PromQL: "tikv_config_rocksdb{$LABEL_CONDITIONS}", + Labels: []string{"instance", "cf", "name"}, + Comment: "TiKV rocksdb config value", + }, + "tikv_config_raftstore": { + PromQL: "tikv_config_raftstore{$LABEL_CONDITIONS}", + Labels: []string{"instance", "name"}, + Comment: "TiKV rocksdb config value", + }, } diff --git a/infoschema/perfschema/tables.go b/infoschema/perfschema/tables.go index a15f502eeae09..b29cb1b424e14 100644 --- a/infoschema/perfschema/tables.go +++ b/infoschema/perfschema/tables.go @@ -24,10 +24,12 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/failpoint" "github.com/pingcap/parser/model" + "github.com/pingcap/parser/mysql" "github.com/pingcap/parser/terror" "github.com/pingcap/tidb/infoschema" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/meta/autoid" + "github.com/pingcap/tidb/privilege" "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/types" @@ -200,11 +202,19 @@ func (vt *perfSchemaTable) Type() table.Type { } func (vt *perfSchemaTable) getRows(ctx sessionctx.Context, cols []*table.Column) (fullRows [][]types.Datum, err error) { + // Extract user and privilege info (is super user?) here + // for statement summary tables' access privilege check + user := ctx.GetSessionVars().User + isSuper := false + if pm := privilege.GetPrivilegeManager(ctx); pm != nil { + isSuper = pm.RequestVerificationWithUser("", "", "", mysql.SuperPriv, user) + } + switch vt.meta.Name.O { case tableNameEventsStatementsSummaryByDigest: - fullRows = stmtsummary.StmtSummaryByDigestMap.ToCurrentDatum() + fullRows = stmtsummary.StmtSummaryByDigestMap.ToCurrentDatum(user, isSuper) case tableNameEventsStatementsSummaryByDigestHistory: - fullRows = stmtsummary.StmtSummaryByDigestMap.ToHistoryDatum() + fullRows = stmtsummary.StmtSummaryByDigestMap.ToHistoryDatum(user, isSuper) case tableNameTiDBProfileCPU: fullRows, err = (&profile.Collector{}).ProfileGraph("cpu") case tableNameTiDBProfileMemory: @@ -256,11 +266,19 @@ func (vt *perfSchemaTable) getRows(ctx sessionctx.Context, cols []*table.Column) } func getClusterMemTableRows(ctx sessionctx.Context, tableName string) (rows [][]types.Datum, err error) { + // Extract user and privilege info (is super user?) here + // for statement summary tables' access privilege check + user := ctx.GetSessionVars().User + isSuper := false + if pm := privilege.GetPrivilegeManager(ctx); pm != nil { + isSuper = pm.RequestVerificationWithUser("", "", "", mysql.SuperPriv, user) + } + switch tableName { case tableNameClusterEventsStatementsSummaryByDigest: - rows = stmtsummary.StmtSummaryByDigestMap.ToCurrentDatum() + rows = stmtsummary.StmtSummaryByDigestMap.ToCurrentDatum(user, isSuper) case tableNameClusterEventsStatementsSummaryByDigestHistory: - rows = stmtsummary.StmtSummaryByDigestMap.ToHistoryDatum() + rows = stmtsummary.StmtSummaryByDigestMap.ToHistoryDatum(user, isSuper) default: err = errors.Errorf("unknown cluster table: %v", tableName) } diff --git a/infoschema/perfschema/tables_test.go b/infoschema/perfschema/tables_test.go index 5b5bc1ab0587d..60b6b214e01c5 100644 --- a/infoschema/perfschema/tables_test.go +++ b/infoschema/perfschema/tables_test.go @@ -27,6 +27,7 @@ import ( . "github.com/pingcap/check" "github.com/pingcap/failpoint" + "github.com/pingcap/parser/auth" "github.com/pingcap/parser/terror" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/infoschema/perfschema" @@ -150,7 +151,7 @@ func (s *testTableSuite) TestStmtSummaryTable(c *C) { from performance_schema.events_statements_summary_by_digest where digest_text like 'select * from t%'`, ).Check(testkit.Rows("select test test.t t:k 1 2 0 0 0 0 0 0 0 0 0 select * from t where a=2 \tIndexLookUp_10\troot\t100\t\n" + - "\t├─IndexScan_8 \tcop \t100\ttable:t, index:a, range:[2,2], keep order:false, stats:pseudo\n" + + "\t├─IndexScan_8 \tcop \t100\ttable:t, index:k(a), range:[2,2], keep order:false, stats:pseudo\n" + "\t└─TableScan_9 \tcop \t100\ttable:t, keep order:false, stats:pseudo")) // select ... order by @@ -170,7 +171,7 @@ func (s *testTableSuite) TestStmtSummaryTable(c *C) { from performance_schema.events_statements_summary_by_digest where digest_text like 'select * from t%'`, ).Check(testkit.Rows("select test test.t t:k 2 4 0 0 0 0 0 0 0 0 0 select * from t where a=2 \tIndexLookUp_10\troot\t100\t\n" + - "\t├─IndexScan_8 \tcop \t100\ttable:t, index:a, range:[2,2], keep order:false, stats:pseudo\n" + + "\t├─IndexScan_8 \tcop \t100\ttable:t, index:k(a), range:[2,2], keep order:false, stats:pseudo\n" + "\t└─TableScan_9 \tcop \t100\ttable:t, keep order:false, stats:pseudo")) // Disable it again. @@ -219,11 +220,11 @@ func (s *testTableSuite) TestStmtSummaryTable(c *C) { from performance_schema.events_statements_summary_by_digest where digest_text like 'select * from t%'`, ).Check(testkit.Rows("select test test.t t:k 1 2 0 0 0 0 0 0 0 0 0 select * from t where a=2 \tIndexLookUp_10\troot\t1000\t\n" + - "\t├─IndexScan_8 \tcop \t1000\ttable:t, index:a, range:[2,2], keep order:false, stats:pseudo\n" + + "\t├─IndexScan_8 \tcop \t1000\ttable:t, index:k(a), range:[2,2], keep order:false, stats:pseudo\n" + "\t└─TableScan_9 \tcop \t1000\ttable:t, keep order:false, stats:pseudo")) // Disable it in global scope. - tk.MustExec("set global tidb_enable_stmt_summary = off") + tk.MustExec("set global tidb_enable_stmt_summary = false") // Create a new session to test. tk = testkit.NewTestKitWithInit(c, s.store) @@ -237,7 +238,7 @@ func (s *testTableSuite) TestStmtSummaryTable(c *C) { from performance_schema.events_statements_summary_by_digest where digest_text like 'select * from t%'`, ).Check(testkit.Rows("select test test.t t:k 2 4 0 0 0 0 0 0 0 0 0 select * from t where a=2 \tIndexLookUp_10\troot\t1000\t\n" + - "\t├─IndexScan_8 \tcop \t1000\ttable:t, index:a, range:[2,2], keep order:false, stats:pseudo\n" + + "\t├─IndexScan_8 \tcop \t1000\ttable:t, index:k(a), range:[2,2], keep order:false, stats:pseudo\n" + "\t└─TableScan_9 \tcop \t1000\ttable:t, keep order:false, stats:pseudo")) // Unset session variable. @@ -250,6 +251,71 @@ func (s *testTableSuite) TestStmtSummaryTable(c *C) { max_prewrite_regions, avg_affected_rows, query_sample_text, plan from performance_schema.events_statements_summary_by_digest`, ).Check(testkit.Rows()) + + // Create a new session to test + tk = testkit.NewTestKitWithInit(c, s.store) + + tk.MustExec("set global tidb_enable_stmt_summary = on") + tk.MustExec("set global tidb_stmt_summary_history_size = 24") + + // Create a new user to test statements summary table privilege + tk.MustExec("create user 'test_user'@'localhost'") + tk.MustExec("grant select on *.* to 'test_user'@'localhost'") + tk.Se.Auth(&auth.UserIdentity{ + Username: "root", + Hostname: "%", + AuthUsername: "root", + AuthHostname: "%", + }, nil, nil) + tk.MustExec("select * from t where a=1") + result := tk.MustQuery(`select * + from performance_schema.events_statements_summary_by_digest + where digest_text like 'select * from t%'`, + ) + // Super user can query all reocrds + c.Assert(len(result.Rows()), Equals, 1) + result = tk.MustQuery(`select * + from performance_schema.events_statements_summary_by_digest_history + where digest_text like 'select * from t%'`, + ) + c.Assert(len(result.Rows()), Equals, 1) + tk.Se.Auth(&auth.UserIdentity{ + Username: "test_user", + Hostname: "localhost", + AuthUsername: "test_user", + AuthHostname: "localhost", + }, nil, nil) + result = tk.MustQuery(`select * + from performance_schema.events_statements_summary_by_digest + where digest_text like 'select * from t%'`, + ) + // Ordinary users can not see others' records + c.Assert(len(result.Rows()), Equals, 0) + result = tk.MustQuery(`select * + from performance_schema.events_statements_summary_by_digest_history + where digest_text like 'select * from t%'`, + ) + c.Assert(len(result.Rows()), Equals, 0) + tk.MustExec("select * from t where a=1") + result = tk.MustQuery(`select * + from performance_schema.events_statements_summary_by_digest + where digest_text like 'select * from t%'`, + ) + c.Assert(len(result.Rows()), Equals, 1) + tk.MustExec("select * from t where a=1") + result = tk.MustQuery(`select * + from performance_schema.events_statements_summary_by_digest_history + where digest_text like 'select * from t%'`, + ) + c.Assert(len(result.Rows()), Equals, 1) + // use root user to set variables back + tk.Se.Auth(&auth.UserIdentity{ + Username: "root", + Hostname: "%", + AuthUsername: "root", + AuthHostname: "%", + }, nil, nil) + tk.MustExec("set global tidb_enable_stmt_summary = off") } // Test events_statements_summary_by_digest_history. @@ -292,6 +358,53 @@ func (s *testTableSuite) TestStmtSummaryHistoryTable(c *C) { ).Check(testkit.Rows()) } +// Test events_statements_summary_by_digest_history. +func (s *testTableSuite) TestStmtSummaryInternalQuery(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) + + tk.MustExec("drop table if exists t") + tk.MustExec("create table t(a int, b varchar(10), key k(a))") + + // We use the sql binding evolve to check the internal query summary. + tk.MustExec("set @@tidb_use_plan_baselines = 1") + tk.MustExec("set @@tidb_evolve_plan_baselines = 1") + tk.MustExec("create global binding for select * from t where t.a = 1 using select * from t ignore index(k) where t.a = 1") + tk.MustExec("set global tidb_enable_stmt_summary = 1") + tk.MustQuery("select @@global.tidb_enable_stmt_summary").Check(testkit.Rows("1")) + defer tk.MustExec("set global tidb_enable_stmt_summary = ''") + // Invalidate the cache manually so that tidb_enable_stmt_summary works immediately. + s.dom.GetGlobalVarsCache().Disable() + // Disable refreshing summary. + tk.MustExec("set global tidb_stmt_summary_refresh_interval = 999999999") + tk.MustQuery("select @@global.tidb_stmt_summary_refresh_interval").Check(testkit.Rows("999999999")) + + // Test Internal + + // Create a new session to test. + tk = testkit.NewTestKitWithInit(c, s.store) + + tk.MustExec("select * from t where t.a = 1") + tk.MustQuery(`select exec_count, digest_text + from performance_schema.events_statements_summary_by_digest + where digest_text like "select original_sql , bind_sql , default_db , status%"`).Check(testkit.Rows()) + + // Enable internal query and evolve baseline. + tk.MustExec("set global tidb_stmt_summary_internal_query = 1") + defer tk.MustExec("set global tidb_stmt_summary_internal_query = false") + + // Create a new session to test. + tk = testkit.NewTestKitWithInit(c, s.store) + + tk.MustExec("admin flush bindings") + tk.MustExec("admin evolve bindings") + + tk.MustQuery(`select exec_count, digest_text + from performance_schema.events_statements_summary_by_digest + where digest_text like "select original_sql , bind_sql , default_db , status%"`).Check(testkit.Rows( + "1 select original_sql , bind_sql , default_db , status , create_time , update_time , charset , collation from mysql . bind_info" + + " where update_time > ? order by update_time")) +} + func currentSourceDir() string { _, file, _, _ := runtime.Caller(0) return filepath.Dir(file) diff --git a/infoschema/tables.go b/infoschema/tables.go old mode 100755 new mode 100644 index 62eaefea63fa9..6b11ed6a596b0 --- a/infoschema/tables.go +++ b/infoschema/tables.go @@ -32,7 +32,6 @@ import ( "github.com/pingcap/tidb/domain/infosync" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/meta/autoid" - "github.com/pingcap/tidb/privilege" "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/variable" "github.com/pingcap/tidb/store/helper" @@ -49,8 +48,9 @@ const ( // TableSchemata is the string constant of infoschema table. TableSchemata = "SCHEMATA" // TableTables is the string constant of infoschema table. - TableTables = "TABLES" - tableColumns = "COLUMNS" + TableTables = "TABLES" + // TableColumns is the string constant of infoschema table + TableColumns = "COLUMNS" tableColumnStatistics = "COLUMN_STATISTICS" // TableStatistics is the string constant of infoschema table TableStatistics = "STATISTICS" @@ -60,8 +60,9 @@ const ( TableCollations = "COLLATIONS" tableFiles = "FILES" // CatalogVal is the string constant of TABLE_CATALOG. - CatalogVal = "def" - tableProfiling = "PROFILING" + CatalogVal = "def" + // TableProfiling is the string constant of infoschema table. + TableProfiling = "PROFILING" // TablePartitions is the string constant of infoschema table. TablePartitions = "PARTITIONS" // TableKeyColumn is the string constant of KEY_COLUMN_USAGE. @@ -92,7 +93,8 @@ const ( tableTableSpaces = "TABLESPACES" // TableCollationCharacterSetApplicability is the string constant of infoschema memory table. TableCollationCharacterSetApplicability = "COLLATION_CHARACTER_SET_APPLICABILITY" - tableProcesslist = "PROCESSLIST" + // TableProcesslist is the string constant of infoschema table. + TableProcesslist = "PROCESSLIST" // TableTiDBIndexes is the string constant of infoschema table TableTiDBIndexes = "TIDB_INDEXES" // TableTiDBHotRegions is the string constant of infoschema table @@ -119,7 +121,8 @@ const ( TableClusterHardware = "CLUSTER_HARDWARE" // TableClusterSystemInfo is the string constant of cluster system info table. TableClusterSystemInfo = "CLUSTER_SYSTEMINFO" - tableTiFlashReplica = "TIFLASH_REPLICA" + // TableTiFlashReplica is the string constant of tiflash replica table. + TableTiFlashReplica = "TIFLASH_REPLICA" // TableInspectionResult is the string constant of inspection result table. TableInspectionResult = "INSPECTION_RESULT" // TableMetricTables is a table that contains all metrics table definition. @@ -132,19 +135,23 @@ const ( TableInspectionSummary = "INSPECTION_SUMMARY" // TableInspectionRules is the string constant of currently implemented inspection and summary rules. TableInspectionRules = "INSPECTION_RULES" + // TableDDLJobs is the string constant of DDL job table. + TableDDLJobs = "DDL_JOBS" + // TableSequences is the string constant of all sequences created by user. + TableSequences = "SEQUENCES" ) var tableIDMap = map[string]int64{ TableSchemata: autoid.InformationSchemaDBID + 1, TableTables: autoid.InformationSchemaDBID + 2, - tableColumns: autoid.InformationSchemaDBID + 3, + TableColumns: autoid.InformationSchemaDBID + 3, tableColumnStatistics: autoid.InformationSchemaDBID + 4, TableStatistics: autoid.InformationSchemaDBID + 5, TableCharacterSets: autoid.InformationSchemaDBID + 6, TableCollations: autoid.InformationSchemaDBID + 7, tableFiles: autoid.InformationSchemaDBID + 8, CatalogVal: autoid.InformationSchemaDBID + 9, - tableProfiling: autoid.InformationSchemaDBID + 10, + TableProfiling: autoid.InformationSchemaDBID + 10, TablePartitions: autoid.InformationSchemaDBID + 11, TableKeyColumn: autoid.InformationSchemaDBID + 12, tableReferConst: autoid.InformationSchemaDBID + 13, @@ -167,7 +174,7 @@ var tableIDMap = map[string]int64{ tableOptimizerTrace: autoid.InformationSchemaDBID + 30, tableTableSpaces: autoid.InformationSchemaDBID + 31, TableCollationCharacterSetApplicability: autoid.InformationSchemaDBID + 32, - tableProcesslist: autoid.InformationSchemaDBID + 33, + TableProcesslist: autoid.InformationSchemaDBID + 33, TableTiDBIndexes: autoid.InformationSchemaDBID + 34, TableSlowQuery: autoid.InformationSchemaDBID + 35, TableTiDBHotRegions: autoid.InformationSchemaDBID + 36, @@ -179,9 +186,9 @@ var tableIDMap = map[string]int64{ TableClusterInfo: autoid.InformationSchemaDBID + 42, TableClusterConfig: autoid.InformationSchemaDBID + 43, TableClusterLoad: autoid.InformationSchemaDBID + 44, - tableTiFlashReplica: autoid.InformationSchemaDBID + 45, + TableTiFlashReplica: autoid.InformationSchemaDBID + 45, ClusterTableSlowLog: autoid.InformationSchemaDBID + 46, - clusterTableProcesslist: autoid.InformationSchemaDBID + 47, + ClusterTableProcesslist: autoid.InformationSchemaDBID + 47, TableClusterLog: autoid.InformationSchemaDBID + 48, TableClusterHardware: autoid.InformationSchemaDBID + 49, TableClusterSystemInfo: autoid.InformationSchemaDBID + 50, @@ -191,6 +198,8 @@ var tableIDMap = map[string]int64{ TableMetricTables: autoid.InformationSchemaDBID + 54, TableInspectionSummary: autoid.InformationSchemaDBID + 55, TableInspectionRules: autoid.InformationSchemaDBID + 56, + TableDDLJobs: autoid.InformationSchemaDBID + 57, + TableSequences: autoid.InformationSchemaDBID + 58, } type columnInfo struct { @@ -979,6 +988,36 @@ var tableMetricSummaryByLabelCols = []columnInfo{ {name: "COMMENT", tp: mysql.TypeVarchar, size: 256}, } +var tableDDLJobsCols = []columnInfo{ + {name: "JOB_ID", tp: mysql.TypeLonglong, size: 21}, + {name: "DB_NAME", tp: mysql.TypeVarchar, size: 64}, + {name: "TABLE_NAME", tp: mysql.TypeVarchar, size: 64}, + {name: "JOB_TYPE", tp: mysql.TypeVarchar, size: 64}, + {name: "SCHEMA_STATE", tp: mysql.TypeVarchar, size: 64}, + {name: "SCHEMA_ID", tp: mysql.TypeLonglong, size: 21}, + {name: "TABLE_ID", tp: mysql.TypeLonglong, size: 21}, + {name: "ROW_COUNT", tp: mysql.TypeLonglong, size: 21}, + {name: "START_TIME", tp: mysql.TypeVarchar, size: 64}, + {name: "END_TIME", tp: mysql.TypeVarchar, size: 64}, + {name: "STATE", tp: mysql.TypeVarchar, size: 64}, + {name: "QUERY", tp: mysql.TypeVarchar, size: 64}, +} + +var tableSequencesCols = []columnInfo{ + {name: "TABLE_CATALOG", tp: mysql.TypeVarchar, size: 512, flag: mysql.NotNullFlag}, + {name: "SEQUENCE_SCHEMA", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag}, + {name: "SEQUENCE_NAME", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag}, + {name: "CACHE", tp: mysql.TypeTiny, flag: mysql.NotNullFlag}, + {name: "CACHE_VALUE", tp: mysql.TypeLonglong, size: 21}, + {name: "CYCLE", tp: mysql.TypeTiny, flag: mysql.NotNullFlag}, + {name: "INCREMENT", tp: mysql.TypeLonglong, size: 21, flag: mysql.NotNullFlag}, + {name: "MAX_VALUE", tp: mysql.TypeLonglong, size: 21}, + {name: "MIN_VALUE", tp: mysql.TypeLonglong, size: 21}, + {name: "ORDER", tp: mysql.TypeTiny, flag: mysql.NotNullFlag}, + {name: "START", tp: mysql.TypeLonglong, size: 21}, + {name: "COMMENT", tp: mysql.TypeVarchar, size: 64}, +} + func dataForTiKVRegionStatus(ctx sessionctx.Context) (records [][]types.Datum, err error) { tikvStore, ok := ctx.GetStore().(tikv.Storage) if !ok { @@ -1082,36 +1121,6 @@ func dataForTiKVStoreStatus(ctx sessionctx.Context) (records [][]types.Datum, er return records, nil } -func dataForProcesslist(ctx sessionctx.Context) [][]types.Datum { - sm := ctx.GetSessionManager() - if sm == nil { - return nil - } - - loginUser := ctx.GetSessionVars().User - var hasProcessPriv bool - if pm := privilege.GetPrivilegeManager(ctx); pm != nil { - if pm.RequestVerification(ctx.GetSessionVars().ActiveRoles, "", "", "", mysql.ProcessPriv) { - hasProcessPriv = true - } - } - - pl := sm.ShowProcessList() - records := make([][]types.Datum, 0, len(pl)) - for _, pi := range pl { - // If you have the PROCESS privilege, you can see all threads. - // Otherwise, you can see only your own threads. - if !hasProcessPriv && loginUser != nil && pi.User != loginUser.Username { - continue - } - - rows := pi.ToRow(ctx.GetSessionVars().StmtCtx.TimeZone) - record := types.MakeDatums(rows...) - records = append(records, record) - } - return records -} - // GetShardingInfo returns a nil or description string for the sharding information of given TableInfo. // The returned description string may be: // - "NOT_SHARDED": for tables that SHARD_ROW_ID_BITS is not specified. @@ -1137,109 +1146,6 @@ func GetShardingInfo(dbInfo *model.DBInfo, tableInfo *model.TableInfo) interface return shardingInfo } -func dataForColumns(ctx sessionctx.Context, schemas []*model.DBInfo) [][]types.Datum { - checker := privilege.GetPrivilegeManager(ctx) - var rows [][]types.Datum - for _, schema := range schemas { - for _, table := range schema.Tables { - if checker != nil && !checker.RequestVerification(ctx.GetSessionVars().ActiveRoles, schema.Name.L, table.Name.L, "", mysql.AllPrivMask) { - continue - } - - rs := dataForColumnsInTable(schema, table) - rows = append(rows, rs...) - } - } - return rows -} - -func dataForColumnsInTable(schema *model.DBInfo, tbl *model.TableInfo) [][]types.Datum { - rows := make([][]types.Datum, 0, len(tbl.Columns)) - for i, col := range tbl.Columns { - if col.Hidden { - continue - } - var charMaxLen, charOctLen, numericPrecision, numericScale, datetimePrecision interface{} - colLen, decimal := col.Flen, col.Decimal - defaultFlen, defaultDecimal := mysql.GetDefaultFieldLengthAndDecimal(col.Tp) - if decimal == types.UnspecifiedLength { - decimal = defaultDecimal - } - if colLen == types.UnspecifiedLength { - colLen = defaultFlen - } - if col.Tp == mysql.TypeSet { - // Example: In MySQL set('a','bc','def','ghij') has length 13, because - // len('a')+len('bc')+len('def')+len('ghij')+len(ThreeComma)=13 - // Reference link: https://bugs.mysql.com/bug.php?id=22613 - colLen = 0 - for _, ele := range col.Elems { - colLen += len(ele) - } - if len(col.Elems) != 0 { - colLen += (len(col.Elems) - 1) - } - charMaxLen = colLen - charOctLen = colLen - } else if col.Tp == mysql.TypeEnum { - // Example: In MySQL enum('a', 'ab', 'cdef') has length 4, because - // the longest string in the enum is 'cdef' - // Reference link: https://bugs.mysql.com/bug.php?id=22613 - colLen = 0 - for _, ele := range col.Elems { - if len(ele) > colLen { - colLen = len(ele) - } - } - charMaxLen = colLen - charOctLen = colLen - } else if types.IsString(col.Tp) { - charMaxLen = colLen - charOctLen = colLen - } else if types.IsTypeFractionable(col.Tp) { - datetimePrecision = decimal - } else if types.IsTypeNumeric(col.Tp) { - numericPrecision = colLen - if col.Tp != mysql.TypeFloat && col.Tp != mysql.TypeDouble { - numericScale = decimal - } else if decimal != -1 { - numericScale = decimal - } - } - columnType := col.FieldType.InfoSchemaStr() - columnDesc := table.NewColDesc(table.ToColumn(col)) - var columnDefault interface{} - if columnDesc.DefaultValue != nil { - columnDefault = fmt.Sprintf("%v", columnDesc.DefaultValue) - } - record := types.MakeDatums( - CatalogVal, // TABLE_CATALOG - schema.Name.O, // TABLE_SCHEMA - tbl.Name.O, // TABLE_NAME - col.Name.O, // COLUMN_NAME - i+1, // ORIGINAL_POSITION - columnDefault, // COLUMN_DEFAULT - columnDesc.Null, // IS_NULLABLE - types.TypeToStr(col.Tp, col.Charset), // DATA_TYPE - charMaxLen, // CHARACTER_MAXIMUM_LENGTH - charOctLen, // CHARACTER_OCTET_LENGTH - numericPrecision, // NUMERIC_PRECISION - numericScale, // NUMERIC_SCALE - datetimePrecision, // DATETIME_PRECISION - columnDesc.Charset, // CHARACTER_SET_NAME - columnDesc.Collation, // COLLATION_NAME - columnType, // COLUMN_TYPE - columnDesc.Key, // COLUMN_KEY - columnDesc.Extra, // EXTRA - "select,insert,update,references", // PRIVILEGES - columnDesc.Comment, // COLUMN_COMMENT - col.GeneratedExprString, // GENERATION_EXPRESSION - ) - rows = append(rows, record) - } - return rows -} - const ( // PrimaryKeyType is the string constant of PRIMARY KEY. PrimaryKeyType = "PRIMARY KEY" @@ -1249,33 +1155,6 @@ const ( UniqueKeyType = "UNIQUE" ) -// dataForPseudoProfiling returns pseudo data for table profiling when system variable `profiling` is set to `ON`. -func dataForPseudoProfiling() [][]types.Datum { - var rows [][]types.Datum - row := types.MakeDatums( - 0, // QUERY_ID - 0, // SEQ - "", // STATE - types.NewDecFromInt(0), // DURATION - types.NewDecFromInt(0), // CPU_USER - types.NewDecFromInt(0), // CPU_SYSTEM - 0, // CONTEXT_VOLUNTARY - 0, // CONTEXT_INVOLUNTARY - 0, // BLOCK_OPS_IN - 0, // BLOCK_OPS_OUT - 0, // MESSAGES_SENT - 0, // MESSAGES_RECEIVED - 0, // PAGE_FAULTS_MAJOR - 0, // PAGE_FAULTS_MINOR - 0, // SWAPS - "", // SOURCE_FUNCTION - "", // SOURCE_FILE - 0, // SOURCE_LINE - ) - rows = append(rows, row) - return rows -} - // ServerInfo represents the basic server information of single cluster component type ServerInfo struct { ServerType string @@ -1434,59 +1313,16 @@ func GetTiKVServerInfo(ctx sessionctx.Context) ([]ServerInfo, error) { return servers, nil } -// dataForTableTiFlashReplica constructs data for table tiflash replica info. -func dataForTableTiFlashReplica(ctx sessionctx.Context, schemas []*model.DBInfo) [][]types.Datum { - var rows [][]types.Datum - progressMap, err := infosync.GetTiFlashTableSyncProgress(context.Background()) - if err != nil { - ctx.GetSessionVars().StmtCtx.AppendWarning(err) - } - for _, schema := range schemas { - for _, tbl := range schema.Tables { - if tbl.TiFlashReplica == nil { - continue - } - progress := 1.0 - if !tbl.TiFlashReplica.Available { - if pi := tbl.GetPartitionInfo(); pi != nil && len(pi.Definitions) > 0 { - progress = 0 - for _, p := range pi.Definitions { - if tbl.TiFlashReplica.IsPartitionAvailable(p.ID) { - progress += 1 - } else { - progress += progressMap[p.ID] - } - } - progress = progress / float64(len(pi.Definitions)) - } else { - progress = progressMap[tbl.ID] - } - } - record := types.MakeDatums( - schema.Name.O, // TABLE_SCHEMA - tbl.Name.O, // TABLE_NAME - tbl.ID, // TABLE_ID - int64(tbl.TiFlashReplica.Count), // REPLICA_COUNT - strings.Join(tbl.TiFlashReplica.LocationLabels, ","), // LOCATION_LABELS - tbl.TiFlashReplica.Available, // AVAILABLE - progress, // PROGRESS - ) - rows = append(rows, record) - } - } - return rows -} - var tableNameToColumns = map[string][]columnInfo{ TableSchemata: schemataCols, TableTables: tablesCols, - tableColumns: columnsCols, + TableColumns: columnsCols, tableColumnStatistics: columnStatisticsCols, TableStatistics: statisticsCols, TableCharacterSets: charsetCols, TableCollations: collationsCols, tableFiles: filesCols, - tableProfiling: profilingCols, + TableProfiling: profilingCols, TablePartitions: partitionsCols, TableKeyColumn: keyColumnUsageCols, tableReferConst: referConstCols, @@ -1509,7 +1345,7 @@ var tableNameToColumns = map[string][]columnInfo{ tableOptimizerTrace: tableOptimizerTraceCols, tableTableSpaces: tableTableSpacesCols, TableCollationCharacterSetApplicability: tableCollationCharacterSetApplicabilityCols, - tableProcesslist: tableProcesslistCols, + TableProcesslist: tableProcesslistCols, TableTiDBIndexes: tableTiDBIndexesCols, TableSlowQuery: slowQueryCols, TableTiDBHotRegions: TableTiDBHotRegionsCols, @@ -1522,7 +1358,7 @@ var tableNameToColumns = map[string][]columnInfo{ TableClusterConfig: tableClusterConfigCols, TableClusterLog: tableClusterLogCols, TableClusterLoad: tableClusterLoadCols, - tableTiFlashReplica: tableTableTiFlashReplicaCols, + TableTiFlashReplica: tableTableTiFlashReplicaCols, TableClusterHardware: tableClusterHardwareCols, TableClusterSystemInfo: tableClusterSystemInfoCols, TableInspectionResult: tableInspectionResultCols, @@ -1531,6 +1367,8 @@ var tableNameToColumns = map[string][]columnInfo{ TableMetricTables: tableMetricTablesCols, TableInspectionSummary: tableInspectionSummaryCols, TableInspectionRules: tableInspectionRulesCols, + TableDDLJobs: tableDDLJobsCols, + TableSequences: tableSequencesCols, } func createInfoSchemaTable(_ autoid.Allocators, meta *model.TableInfo) (table.Table, error) { @@ -1571,13 +1409,7 @@ func (it *infoschemaTable) getRows(ctx sessionctx.Context, cols []*table.Column) dbs := is.AllSchemas() sort.Sort(SchemasSorter(dbs)) switch it.meta.Name.O { - case tableColumns: - fullRows = dataForColumns(ctx, dbs) case tableFiles: - case tableProfiling: - if v, ok := ctx.GetSessionVars().GetSystemVar("profiling"); ok && variable.TiDBOptOn(v) { - fullRows = dataForPseudoProfiling() - } case tableReferConst: case tablePlugins, tableTriggers: case tableRoutines: @@ -1592,17 +1424,10 @@ func (it *infoschemaTable) getRows(ctx sessionctx.Context, cols []*table.Column) case tableSessionStatus: case tableOptimizerTrace: case tableTableSpaces: - case tableProcesslist: - fullRows = dataForProcesslist(ctx) case tableTiKVStoreStatus: fullRows, err = dataForTiKVStoreStatus(ctx) case tableTiKVRegionStatus: fullRows, err = dataForTiKVRegionStatus(ctx) - case tableTiFlashReplica: - fullRows = dataForTableTiFlashReplica(ctx, dbs) - // Data for cluster processlist memory table. - case clusterTableProcesslist: - fullRows, err = dataForClusterProcesslist(ctx) } if err != nil { return nil, err diff --git a/infoschema/tables_test.go b/infoschema/tables_test.go index d22e8f0044e1b..ea84d073bf439 100644 --- a/infoschema/tables_test.go +++ b/infoschema/tables_test.go @@ -38,7 +38,6 @@ import ( "github.com/pingcap/tidb/meta/autoid" "github.com/pingcap/tidb/server" "github.com/pingcap/tidb/session" - "github.com/pingcap/tidb/statistics" "github.com/pingcap/tidb/store/helper" "github.com/pingcap/tidb/store/mockstore" "github.com/pingcap/tidb/util" @@ -506,13 +505,6 @@ func (s *testTableSuite) TestSomeTables(c *C) { )) } -func (s *testTableSuite) TestProfiling(c *C) { - tk := testkit.NewTestKit(c, s.store) - tk.MustQuery("select * from information_schema.profiling").Check(testkit.Rows()) - tk.MustExec("set @@profiling=1") - tk.MustQuery("select * from information_schema.profiling").Check(testkit.Rows("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0")) -} - func prepareSlowLogfile(c *C, slowLogFileName string) { f, err := os.OpenFile(slowLogFileName, os.O_CREATE|os.O_WRONLY, 0644) c.Assert(err, IsNil) @@ -654,20 +646,6 @@ func (s *testTableSuite) TestReloadDropDatabase(c *C) { c.Assert(ok, IsFalse) } -func (s *testTableSuite) TestForTableTiFlashReplica(c *C) { - tk := testkit.NewTestKit(c, s.store) - statistics.ClearHistoryJobs() - tk.MustExec("use test") - tk.MustExec("drop table if exists t") - tk.MustExec("create table t (a int, b int, index idx(a))") - tk.MustExec("alter table t set tiflash replica 2 location labels 'a','b';") - tk.MustQuery("select TABLE_SCHEMA,TABLE_NAME,REPLICA_COUNT,LOCATION_LABELS,AVAILABLE, PROGRESS from information_schema.tiflash_replica").Check(testkit.Rows("test t 2 a,b 0 0")) - tbl, err := domain.GetDomain(tk.Se).InfoSchema().TableByName(model.NewCIStr("test"), model.NewCIStr("t")) - c.Assert(err, IsNil) - tbl.Meta().TiFlashReplica.Available = true - tk.MustQuery("select TABLE_SCHEMA,TABLE_NAME,REPLICA_COUNT,LOCATION_LABELS,AVAILABLE, PROGRESS from information_schema.tiflash_replica").Check(testkit.Rows("test t 2 a,b 1 1")) -} - func (s *testClusterTableSuite) TestForClusterServerInfo(c *C) { tk := testkit.NewTestKit(c, s.store) instances := []string{ diff --git a/planner/cascades/integration_test.go b/planner/cascades/integration_test.go index 6f331a6f708a9..60c187d0a5c24 100644 --- a/planner/cascades/integration_test.go +++ b/planner/cascades/integration_test.go @@ -55,8 +55,8 @@ func (s *testIntegrationSuite) TestSimpleProjDual(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("set session tidb_enable_cascades_planner = 1") tk.MustQuery("explain select 1").Check(testkit.Rows( - "Projection_3 1.00 root 1->Column#1", - "└─TableDual_4 1.00 root rows:1", + "Projection_3 1.00 root 1->Column#1", + "└─TableDual_4 1.00 root rows:1", )) tk.MustQuery("select 1").Check(testkit.Rows( "1", diff --git a/planner/cascades/testdata/integration_suite_out.json b/planner/cascades/testdata/integration_suite_out.json index 4a48661e5e449..90a73a156c2b0 100644 --- a/planner/cascades/testdata/integration_suite_out.json +++ b/planner/cascades/testdata/integration_suite_out.json @@ -5,9 +5,9 @@ { "SQL": "select b from t where a > 1", "Plan": [ - "Projection_8 3333.33 root test.t.b", - "└─TableReader_9 3333.33 root data:TableRangeScan_10", - " └─TableRangeScan_10 3333.33 cop[tikv] table:t, range:(1,+inf], keep order:false, stats:pseudo" + "Projection_8 3333.33 root test.t.b", + "└─TableReader_9 3333.33 root data:TableRangeScan_10", + " └─TableRangeScan_10 3333.33 cop[tikv] table:t range:(1,+inf], keep order:false, stats:pseudo" ], "Result": [ "4", @@ -17,19 +17,19 @@ { "SQL": "select b from t where a > 1 and a < 3", "Plan": [ - "Projection_8 2.00 root test.t.b", - "└─TableReader_9 2.00 root data:TableRangeScan_10", - " └─TableRangeScan_10 2.00 cop[tikv] table:t, range:(1,3), keep order:false, stats:pseudo" + "Projection_8 2.00 root test.t.b", + "└─TableReader_9 2.00 root data:TableRangeScan_10", + " └─TableRangeScan_10 2.00 cop[tikv] table:t range:(1,3), keep order:false, stats:pseudo" ], "Result": null }, { "SQL": "select b from t where a > 1 and b < 6", "Plan": [ - "Projection_9 2666.67 root test.t.b", - "└─TableReader_10 2666.67 root data:Selection_11", - " └─Selection_11 2666.67 cop[tikv] lt(test.t.b, 6)", - " └─TableRangeScan_12 3333.33 cop[tikv] table:t, range:(1,+inf], keep order:false, stats:pseudo" + "Projection_9 2666.67 root test.t.b", + "└─TableReader_10 2666.67 root data:Selection_11", + " └─Selection_11 2666.67 cop[tikv] lt(test.t.b, 6)", + " └─TableRangeScan_12 3333.33 cop[tikv] table:t range:(1,+inf], keep order:false, stats:pseudo" ], "Result": [ "4" @@ -38,9 +38,9 @@ { "SQL": "select a from t where a * 3 + 1 > 9 and a < 5", "Plan": [ - "TableReader_9 4.00 root data:Selection_10", - "└─Selection_10 4.00 cop[tikv] gt(plus(mul(test.t.a, 3), 1), 9)", - " └─TableRangeScan_11 5.00 cop[tikv] table:t, range:[-inf,5), keep order:false, stats:pseudo" + "TableReader_9 4.00 root data:Selection_10", + "└─Selection_10 4.00 cop[tikv] gt(plus(mul(test.t.a, 3), 1), 9)", + " └─TableRangeScan_11 5.00 cop[tikv] table:t range:[-inf,5), keep order:false, stats:pseudo" ], "Result": [ "3" @@ -49,10 +49,10 @@ { "SQL": "select a from t group by a having sum(b) > 4", "Plan": [ - "Projection_13 8000.00 root test.t.a", - "└─TableReader_14 8000.00 root data:Selection_15", - " └─Selection_15 8000.00 cop[tikv] gt(cast(test.t.b), 4)", - " └─TableFullScan_16 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_13 8000.00 root test.t.a", + "└─TableReader_14 8000.00 root data:Selection_15", + " └─Selection_15 8000.00 cop[tikv] gt(cast(test.t.b), 4)", + " └─TableFullScan_16 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "5" @@ -66,8 +66,8 @@ { "SQL": "select a from t order by a", "Plan": [ - "TableReader_7 10000.00 root data:TableFullScan_8", - "└─TableFullScan_8 10000.00 cop[tikv] table:t, keep order:true, stats:pseudo" + "TableReader_7 10000.00 root data:TableFullScan_8", + "└─TableFullScan_8 10000.00 cop[tikv] table:t keep order:true, stats:pseudo" ], "Result": [ "1", @@ -79,9 +79,9 @@ { "SQL": "select b from t order by b", "Plan": [ - "Sort_11 10000.00 root test.t.b:asc", - "└─TableReader_9 10000.00 root data:TableFullScan_10", - " └─TableFullScan_10 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Sort_11 10000.00 root test.t.b:asc", + "└─TableReader_9 10000.00 root data:TableFullScan_10", + " └─TableFullScan_10 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "11", @@ -93,13 +93,13 @@ { "SQL": "select b from t order by a+b", "Plan": [ - "Projection_7 10000.00 root test.t.b", - "└─Projection_12 10000.00 root test.t.b, test.t.a", - " └─Sort_8 10000.00 root Column#4:asc", - " └─Projection_13 10000.00 root test.t.b, test.t.a, plus(test.t.a, test.t.b)->Column#4", - " └─Projection_9 10000.00 root test.t.b, test.t.a", - " └─TableReader_10 10000.00 root data:TableFullScan_11", - " └─TableFullScan_11 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_7 10000.00 root test.t.b", + "└─Projection_12 10000.00 root test.t.b, test.t.a", + " └─Sort_8 10000.00 root Column#4:asc", + " └─Projection_13 10000.00 root test.t.b, test.t.a, plus(test.t.a, test.t.b)->Column#4", + " └─Projection_9 10000.00 root test.t.b, test.t.a", + " └─TableReader_10 10000.00 root data:TableFullScan_11", + " └─TableFullScan_11 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "11", @@ -111,13 +111,13 @@ { "SQL": "select b from t order by b, a+b, a", "Plan": [ - "Projection_7 10000.00 root test.t.b", - "└─Projection_12 10000.00 root test.t.b, test.t.a", - " └─Sort_8 10000.00 root test.t.b:asc, Column#4:asc, test.t.a:asc", - " └─Projection_13 10000.00 root test.t.b, test.t.a, plus(test.t.a, test.t.b)->Column#4", - " └─Projection_9 10000.00 root test.t.b, test.t.a", - " └─TableReader_10 10000.00 root data:TableFullScan_11", - " └─TableFullScan_11 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_7 10000.00 root test.t.b", + "└─Projection_12 10000.00 root test.t.b, test.t.a", + " └─Sort_8 10000.00 root test.t.b:asc, Column#4:asc, test.t.a:asc", + " └─Projection_13 10000.00 root test.t.b, test.t.a, plus(test.t.a, test.t.b)->Column#4", + " └─Projection_9 10000.00 root test.t.b, test.t.a", + " └─TableReader_10 10000.00 root data:TableFullScan_11", + " └─TableFullScan_11 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "11", @@ -134,10 +134,10 @@ { "SQL": "select sum(a) from t", "Plan": [ - "HashAgg_12 1.00 root funcs:sum(Column#4)->Column#3", - "└─TableReader_13 1.00 root data:HashAgg_14", - " └─HashAgg_14 1.00 cop[tikv] funcs:sum(test.t.a)->Column#4", - " └─TableFullScan_10 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "HashAgg_12 1.00 root funcs:sum(Column#4)->Column#3", + "└─TableReader_13 1.00 root data:HashAgg_14", + " └─HashAgg_14 1.00 cop[tikv] funcs:sum(test.t.a)->Column#4", + " └─TableFullScan_10 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "10" @@ -146,10 +146,10 @@ { "SQL": "select max(a), min(b) from t", "Plan": [ - "HashAgg_11 1.00 root funcs:max(Column#5)->Column#3, funcs:min(Column#6)->Column#4", - "└─TableReader_12 1.00 root data:HashAgg_13", - " └─HashAgg_13 1.00 cop[tikv] funcs:max(test.t.a)->Column#5, funcs:min(test.t.b)->Column#6", - " └─TableFullScan_10 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "HashAgg_11 1.00 root funcs:max(Column#5)->Column#3, funcs:min(Column#6)->Column#4", + "└─TableReader_12 1.00 root data:HashAgg_13", + " └─HashAgg_13 1.00 cop[tikv] funcs:max(test.t.a)->Column#5, funcs:min(test.t.b)->Column#6", + " └─TableFullScan_10 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "4 11" @@ -158,12 +158,12 @@ { "SQL": "select b, avg(a) from t group by b order by b", "Plan": [ - "Projection_10 8000.00 root test.t.b, Column#3", - "└─Sort_19 8000.00 root test.t.b:asc", - " └─HashAgg_12 8000.00 root group by:Column#9, funcs:avg(Column#7)->Column#3, funcs:firstrow(Column#8)->test.t.b", - " └─Projection_15 10000.00 root cast(test.t.a, decimal(65,4) BINARY)->Column#7, test.t.b, test.t.b", - " └─TableReader_13 10000.00 root data:TableFullScan_14", - " └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_10 8000.00 root test.t.b, Column#3", + "└─Sort_19 8000.00 root test.t.b:asc", + " └─HashAgg_12 8000.00 root group by:Column#9, funcs:avg(Column#7)->Column#3, funcs:firstrow(Column#8)->test.t.b", + " └─Projection_15 10000.00 root cast(test.t.a, decimal(65,4) BINARY)->Column#7, test.t.b, test.t.b", + " └─TableReader_13 10000.00 root data:TableFullScan_14", + " └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "11 1.0000", @@ -175,12 +175,12 @@ { "SQL": "select b, sum(a) from t group by b order by b", "Plan": [ - "Projection_10 8000.00 root test.t.b, Column#3", - "└─Sort_19 8000.00 root test.t.b:asc", - " └─HashAgg_16 8000.00 root group by:test.t.b, funcs:sum(Column#4)->Column#3, funcs:firstrow(test.t.b)->test.t.b", - " └─TableReader_17 8000.00 root data:HashAgg_18", - " └─HashAgg_18 8000.00 cop[tikv] group by:test.t.b, funcs:sum(test.t.a)->Column#4", - " └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_10 8000.00 root test.t.b, Column#3", + "└─Sort_19 8000.00 root test.t.b:asc", + " └─HashAgg_16 8000.00 root group by:test.t.b, funcs:sum(Column#4)->Column#3, funcs:firstrow(test.t.b)->test.t.b", + " └─TableReader_17 8000.00 root data:HashAgg_18", + " └─HashAgg_18 8000.00 cop[tikv] group by:test.t.b, funcs:sum(test.t.a)->Column#4", + " └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "11 1", @@ -192,14 +192,14 @@ { "SQL": "select b, avg(a) from t group by b having sum(a) > 1 order by b", "Plan": [ - "Projection_12 6400.00 root test.t.b, Column#3", - "└─Projection_14 6400.00 root test.t.b, Column#3, Column#4", - " └─Sort_27 6400.00 root test.t.b:asc", - " └─Selection_26 6400.00 root gt(Column#4, 1)", - " └─HashAgg_17 8000.00 root group by:Column#14, funcs:avg(Column#11)->Column#3, funcs:sum(Column#12)->Column#4, funcs:firstrow(Column#13)->test.t.b", - " └─Projection_20 10000.00 root cast(test.t.a, decimal(65,4) BINARY)->Column#11, cast(test.t.a, decimal(65,0) BINARY)->Column#12, test.t.b, test.t.b", - " └─TableReader_18 10000.00 root data:TableFullScan_19", - " └─TableFullScan_19 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_12 6400.00 root test.t.b, Column#3", + "└─Projection_14 6400.00 root test.t.b, Column#3, Column#4", + " └─Sort_27 6400.00 root test.t.b:asc", + " └─Selection_26 6400.00 root gt(Column#4, 1)", + " └─HashAgg_17 8000.00 root group by:Column#14, funcs:avg(Column#11)->Column#3, funcs:sum(Column#12)->Column#4, funcs:firstrow(Column#13)->test.t.b", + " └─Projection_20 10000.00 root cast(test.t.a, decimal(65,4) BINARY)->Column#11, cast(test.t.a, decimal(65,0) BINARY)->Column#12, test.t.b, test.t.b", + " └─TableReader_18 10000.00 root data:TableFullScan_19", + " └─TableFullScan_19 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "22 2.0000", @@ -210,10 +210,10 @@ { "SQL": "select max(a+b) from t", "Plan": [ - "HashAgg_31 1.00 root funcs:max(Column#4)->Column#3", - "└─TableReader_32 1.00 root data:HashAgg_33", - " └─HashAgg_33 1.00 cop[tikv] funcs:max(plus(test.t.a, test.t.b))->Column#4", - " └─TableFullScan_29 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "HashAgg_31 1.00 root funcs:max(Column#4)->Column#3", + "└─TableReader_32 1.00 root data:HashAgg_33", + " └─HashAgg_33 1.00 cop[tikv] funcs:max(plus(test.t.a, test.t.b))->Column#4", + " └─TableFullScan_29 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "48" @@ -222,10 +222,10 @@ { "SQL": "select sum(a) from t group by a, a+b order by a", "Plan": [ - "Projection_10 10000.00 root Column#3", - "└─Projection_12 10000.00 root cast(test.t.a, decimal(65,0) BINARY)->Column#3, test.t.a", - " └─TableReader_13 10000.00 root data:TableFullScan_14", - " └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:true, stats:pseudo" + "Projection_10 10000.00 root Column#3", + "└─Projection_12 10000.00 root cast(test.t.a, decimal(65,0) BINARY)->Column#3, test.t.a", + " └─TableReader_13 10000.00 root data:TableFullScan_14", + " └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:true, stats:pseudo" ], "Result": [ "1", @@ -237,13 +237,13 @@ { "SQL": "select b, sum(a) from t group by b having b > 1 order by b", "Plan": [ - "Projection_14 6400.00 root test.t.b, Column#3", - "└─Sort_24 6400.00 root test.t.b:asc", - " └─HashAgg_21 6400.00 root group by:test.t.b, funcs:sum(Column#4)->Column#3, funcs:firstrow(test.t.b)->test.t.b", - " └─TableReader_22 6400.00 root data:HashAgg_23", - " └─HashAgg_23 6400.00 cop[tikv] group by:test.t.b, funcs:sum(test.t.a)->Column#4", - " └─Selection_18 8000.00 cop[tikv] gt(test.t.b, 1)", - " └─TableFullScan_19 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_14 6400.00 root test.t.b, Column#3", + "└─Sort_24 6400.00 root test.t.b:asc", + " └─HashAgg_21 6400.00 root group by:test.t.b, funcs:sum(Column#4)->Column#3, funcs:firstrow(test.t.b)->test.t.b", + " └─TableReader_22 6400.00 root data:HashAgg_23", + " └─HashAgg_23 6400.00 cop[tikv] group by:test.t.b, funcs:sum(test.t.a)->Column#4", + " └─Selection_18 8000.00 cop[tikv] gt(test.t.b, 1)", + " └─TableFullScan_19 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "11 1", @@ -255,13 +255,13 @@ { "SQL": "select c, sum(a) from (select a+b as c, a from t) t1 group by c having c > 1 order by c", "Plan": [ - "Projection_18 6400.00 root Column#3, Column#4", - "└─Sort_30 6400.00 root Column#3:asc", - " └─HashAgg_26 6400.00 root group by:Column#9, funcs:sum(Column#7)->Column#4, funcs:firstrow(Column#9)->Column#3", - " └─TableReader_27 6400.00 root data:HashAgg_28", - " └─HashAgg_28 6400.00 cop[tikv] group by:plus(test.t.a, test.t.b), funcs:sum(test.t.a)->Column#7", - " └─Selection_23 8000.00 cop[tikv] gt(plus(test.t.a, test.t.b), 1)", - " └─TableFullScan_24 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_18 6400.00 root Column#3, Column#4", + "└─Sort_30 6400.00 root Column#3:asc", + " └─HashAgg_26 6400.00 root group by:Column#9, funcs:sum(Column#7)->Column#4, funcs:firstrow(Column#9)->Column#3", + " └─TableReader_27 6400.00 root data:HashAgg_28", + " └─HashAgg_28 6400.00 cop[tikv] group by:plus(test.t.a, test.t.b), funcs:sum(test.t.a)->Column#7", + " └─Selection_23 8000.00 cop[tikv] gt(plus(test.t.a, test.t.b), 1)", + " └─TableFullScan_24 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "12 1", @@ -273,11 +273,11 @@ { "SQL": "select max(a.a) from t a left join t b on a.a = b.a", "Plan": [ - "HashAgg_33 1.00 root funcs:max(test.t.a)->Column#5", - "└─Limit_35 1.00 root offset:0, count:1", - " └─TableReader_40 1.00 root data:Limit_41", - " └─Limit_41 1.00 cop[tikv] offset:0, count:1", - " └─TableFullScan_39 1.00 cop[tikv] table:a, keep order:true, desc, stats:pseudo" + "HashAgg_33 1.00 root funcs:max(test.t.a)->Column#5", + "└─Limit_35 1.00 root offset:0, count:1", + " └─TableReader_40 1.00 root data:Limit_41", + " └─Limit_41 1.00 cop[tikv] offset:0, count:1", + " └─TableFullScan_39 1.00 cop[tikv] table:a keep order:true, desc, stats:pseudo" ], "Result": [ "4" @@ -286,10 +286,10 @@ { "SQL": "select avg(a.b) from t a left join t b on a.a = b.a", "Plan": [ - "HashAgg_14 1.00 root funcs:avg(Column#6, Column#7)->Column#5", - "└─TableReader_15 1.00 root data:HashAgg_16", - " └─HashAgg_16 1.00 cop[tikv] funcs:avg(test.t.b)->Column#6", - " └─TableFullScan_12 10000.00 cop[tikv] table:a, keep order:false, stats:pseudo" + "HashAgg_14 1.00 root funcs:avg(Column#6, Column#7)->Column#5", + "└─TableReader_15 1.00 root data:HashAgg_16", + " └─HashAgg_16 1.00 cop[tikv] funcs:avg(test.t.b)->Column#6", + " └─TableFullScan_12 10000.00 cop[tikv] table:a keep order:false, stats:pseudo" ], "Result": [ "27.5000" @@ -298,9 +298,9 @@ { "SQL": "select t1.a, max(t1.b) from t as t1 left join (select * from t) as t2 on t1.a = t2.a and t1.b = 3 group by t1.a order by a", "Plan": [ - "Projection_14 10000.00 root test.t.a, cast(test.t.b, int(11))->Column#5", - "└─TableReader_15 10000.00 root data:TableFullScan_16", - " └─TableFullScan_16 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo" + "Projection_14 10000.00 root test.t.a, cast(test.t.b, int(11))->Column#5", + "└─TableReader_15 10000.00 root data:TableFullScan_16", + " └─TableFullScan_16 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo" ], "Result": [ "1 11", @@ -312,9 +312,9 @@ { "SQL": "select t1.a, sum(distinct t1.b) from t as t1 left join (select * from t) as t2 on t1.b = t2.b group by t1.a order by a", "Plan": [ - "Projection_13 10000.00 root test.t.a, cast(test.t.b, decimal(65,0) BINARY)->Column#5", - "└─TableReader_14 10000.00 root data:TableFullScan_15", - " └─TableFullScan_15 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo" + "Projection_13 10000.00 root test.t.a, cast(test.t.b, decimal(65,0) BINARY)->Column#5", + "└─TableReader_14 10000.00 root data:TableFullScan_15", + " └─TableFullScan_15 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo" ], "Result": [ "1 11", @@ -326,9 +326,9 @@ { "SQL": "select t2.a, max(t2.b) from t as t1 right join (select * from t) as t2 on t1.a = t2.a group by t2.a order by a", "Plan": [ - "Projection_14 10000.00 root test.t.a, cast(test.t.b, int(11))->Column#5", - "└─TableReader_15 10000.00 root data:TableFullScan_16", - " └─TableFullScan_16 10000.00 cop[tikv] table:t, keep order:true, stats:pseudo" + "Projection_14 10000.00 root test.t.a, cast(test.t.b, int(11))->Column#5", + "└─TableReader_15 10000.00 root data:TableFullScan_16", + " └─TableFullScan_16 10000.00 cop[tikv] table:t keep order:true, stats:pseudo" ], "Result": [ "1 11", @@ -340,9 +340,9 @@ { "SQL": "select t3.a, max(t3.b) from (select t1.a, t1.b from t as t1 left join t as t2 on t1.b = t2.b) t3 group by t3.a order by a", "Plan": [ - "Projection_13 10000.00 root test.t.a, cast(test.t.b, int(11))->Column#5", - "└─TableReader_14 10000.00 root data:TableFullScan_15", - " └─TableFullScan_15 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo" + "Projection_13 10000.00 root test.t.a, cast(test.t.b, int(11))->Column#5", + "└─TableReader_14 10000.00 root data:TableFullScan_15", + " └─TableFullScan_15 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo" ], "Result": [ "1 11", @@ -354,11 +354,11 @@ { "SQL": "select max(a) from t", "Plan": [ - "HashAgg_21 1.00 root funcs:max(test.t.a)->Column#3", - "└─Limit_23 1.00 root offset:0, count:1", - " └─TableReader_28 1.00 root data:Limit_29", - " └─Limit_29 1.00 cop[tikv] offset:0, count:1", - " └─TableFullScan_27 1.00 cop[tikv] table:t, keep order:true, desc, stats:pseudo" + "HashAgg_21 1.00 root funcs:max(test.t.a)->Column#3", + "└─Limit_23 1.00 root offset:0, count:1", + " └─TableReader_28 1.00 root data:Limit_29", + " └─Limit_29 1.00 cop[tikv] offset:0, count:1", + " └─TableFullScan_27 1.00 cop[tikv] table:t keep order:true, desc, stats:pseudo" ], "Result": [ "4" @@ -367,10 +367,10 @@ { "SQL": "select sum(case when a > 0 and a <= 1000 then b else 0 end) from t", "Plan": [ - "HashAgg_16 1.00 root funcs:sum(Column#4)->Column#3", - "└─TableReader_17 1.00 root data:HashAgg_18", - " └─HashAgg_18 1.00 cop[tikv] funcs:sum(test.t.b)->Column#4", - " └─TableRangeScan_14 250.00 cop[tikv] table:t, range:(0,1000], keep order:false, stats:pseudo" + "HashAgg_16 1.00 root funcs:sum(Column#4)->Column#3", + "└─TableReader_17 1.00 root data:HashAgg_18", + " └─HashAgg_18 1.00 cop[tikv] funcs:sum(test.t.b)->Column#4", + " └─TableRangeScan_14 250.00 cop[tikv] table:t range:(0,1000], keep order:false, stats:pseudo" ], "Result": [ "110" @@ -379,10 +379,10 @@ { "SQL": "select sum(case when a > 0 then (case when a <= 1000 then b end) else 0 end) from t", "Plan": [ - "HashAgg_19 1.00 root funcs:sum(Column#4)->Column#3", - "└─TableReader_20 1.00 root data:HashAgg_21", - " └─HashAgg_21 1.00 cop[tikv] funcs:sum(test.t.b)->Column#4", - " └─TableRangeScan_17 250.00 cop[tikv] table:t, range:(0,1000], keep order:false, stats:pseudo" + "HashAgg_19 1.00 root funcs:sum(Column#4)->Column#3", + "└─TableReader_20 1.00 root data:HashAgg_21", + " └─HashAgg_21 1.00 cop[tikv] funcs:sum(test.t.b)->Column#4", + " └─TableRangeScan_17 250.00 cop[tikv] table:t range:(0,1000], keep order:false, stats:pseudo" ], "Result": [ "110" @@ -391,10 +391,10 @@ { "SQL": "select sum(case when a <= 0 or a > 1000 then 0.0 else b end) from t", "Plan": [ - "HashAgg_16 1.00 root funcs:sum(Column#4)->Column#3", - "└─TableReader_17 1.00 root data:HashAgg_18", - " └─HashAgg_18 1.00 cop[tikv] funcs:sum(cast(test.t.b))->Column#4", - " └─TableRangeScan_14 250.00 cop[tikv] table:t, range:(0,1000], keep order:false, stats:pseudo" + "HashAgg_16 1.00 root funcs:sum(Column#4)->Column#3", + "└─TableReader_17 1.00 root data:HashAgg_18", + " └─HashAgg_18 1.00 cop[tikv] funcs:sum(cast(test.t.b))->Column#4", + " └─TableRangeScan_14 250.00 cop[tikv] table:t range:(0,1000], keep order:false, stats:pseudo" ], "Result": [ "110.0" @@ -403,10 +403,10 @@ { "SQL": "select count(case when a > 0 and a <= 1000 then b end) from t", "Plan": [ - "HashAgg_15 1.00 root funcs:count(Column#4)->Column#3", - "└─TableReader_16 1.00 root data:HashAgg_17", - " └─HashAgg_17 1.00 cop[tikv] funcs:count(test.t.b)->Column#4", - " └─TableRangeScan_14 250.00 cop[tikv] table:t, range:(0,1000], keep order:false, stats:pseudo" + "HashAgg_15 1.00 root funcs:count(Column#4)->Column#3", + "└─TableReader_16 1.00 root data:HashAgg_17", + " └─HashAgg_17 1.00 cop[tikv] funcs:count(test.t.b)->Column#4", + " └─TableRangeScan_14 250.00 cop[tikv] table:t range:(0,1000], keep order:false, stats:pseudo" ], "Result": [ "4" @@ -415,10 +415,10 @@ { "SQL": "select count(case when a <= 0 or a > 1000 then null else b end) from t", "Plan": [ - "HashAgg_15 1.00 root funcs:count(Column#4)->Column#3", - "└─TableReader_16 1.00 root data:HashAgg_17", - " └─HashAgg_17 1.00 cop[tikv] funcs:count(test.t.b)->Column#4", - " └─TableRangeScan_14 250.00 cop[tikv] table:t, range:(0,1000], keep order:false, stats:pseudo" + "HashAgg_15 1.00 root funcs:count(Column#4)->Column#3", + "└─TableReader_16 1.00 root data:HashAgg_17", + " └─HashAgg_17 1.00 cop[tikv] funcs:count(test.t.b)->Column#4", + " └─TableRangeScan_14 250.00 cop[tikv] table:t range:(0,1000], keep order:false, stats:pseudo" ], "Result": [ "4" @@ -427,9 +427,9 @@ { "SQL": "select count(distinct case when a > 0 and a <= 1000 then b end) from t", "Plan": [ - "HashAgg_10 1.00 root funcs:count(distinct test.t.b)->Column#3", - "└─TableReader_11 250.00 root data:TableRangeScan_12", - " └─TableRangeScan_12 250.00 cop[tikv] table:t, range:(0,1000], keep order:false, stats:pseudo" + "HashAgg_10 1.00 root funcs:count(distinct test.t.b)->Column#3", + "└─TableReader_11 250.00 root data:TableRangeScan_12", + " └─TableRangeScan_12 250.00 cop[tikv] table:t range:(0,1000], keep order:false, stats:pseudo" ], "Result": [ "4" @@ -438,12 +438,12 @@ { "SQL": "select count(b), sum(b), avg(b), b, max(b), min(b), bit_and(b), bit_or(b), bit_xor(b) from t group by a having sum(b) >= 0 and count(b) >= 0 order by b", "Plan": [ - "Projection_13 8000.00 root Column#3, Column#4, Column#5, test.t.b, Column#6, Column#7, Column#8, Column#9, Column#10", - "└─Projection_15 8000.00 root if(isnull(test.t.b), 0, 1)->Column#3, cast(test.t.b, decimal(65,0) BINARY)->Column#4, cast(test.t.b, decimal(65,4) BINARY)->Column#5, test.t.b, cast(test.t.b, int(11))->Column#6, cast(test.t.b, int(11))->Column#7, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#8, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#9, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#10, cast(test.t.b, decimal(65,0) BINARY)->Column#4, if(isnull(test.t.b), 0, 1)->Column#3", - " └─Sort_22 8000.00 root test.t.b:asc", - " └─TableReader_19 8000.00 root data:Selection_20", - " └─Selection_20 8000.00 cop[tikv] ge(cast(test.t.b), 0), ge(if(isnull(test.t.b), 0, 1), 0)", - " └─TableFullScan_21 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_13 8000.00 root Column#3, Column#4, Column#5, test.t.b, Column#6, Column#7, Column#8, Column#9, Column#10", + "└─Projection_15 8000.00 root if(isnull(test.t.b), 0, 1)->Column#3, cast(test.t.b, decimal(65,0) BINARY)->Column#4, cast(test.t.b, decimal(65,4) BINARY)->Column#5, test.t.b, cast(test.t.b, int(11))->Column#6, cast(test.t.b, int(11))->Column#7, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#8, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#9, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#10, cast(test.t.b, decimal(65,0) BINARY)->Column#4, if(isnull(test.t.b), 0, 1)->Column#3", + " └─Sort_22 8000.00 root test.t.b:asc", + " └─TableReader_19 8000.00 root data:Selection_20", + " └─Selection_20 8000.00 cop[tikv] ge(cast(test.t.b), 0), ge(if(isnull(test.t.b), 0, 1), 0)", + " └─TableFullScan_21 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "1 11 11.0000 11 11 11 11 11 11", @@ -460,10 +460,10 @@ { "SQL": "select a from t limit 2", "Plan": [ - "Limit_7 2.00 root offset:0, count:2", - "└─TableReader_8 2.00 root data:Limit_9", - " └─Limit_9 2.00 cop[tikv] offset:0, count:2", - " └─TableFullScan_10 2.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Limit_7 2.00 root offset:0, count:2", + "└─TableReader_8 2.00 root data:Limit_9", + " └─Limit_9 2.00 cop[tikv] offset:0, count:2", + " └─TableFullScan_10 2.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "1", @@ -473,10 +473,10 @@ { "SQL": "select a from t limit 1 offset 2", "Plan": [ - "Limit_7 1.00 root offset:2, count:1", - "└─TableReader_8 3.00 root data:Limit_9", - " └─Limit_9 3.00 cop[tikv] offset:0, count:3", - " └─TableFullScan_10 3.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Limit_7 1.00 root offset:2, count:1", + "└─TableReader_8 3.00 root data:Limit_9", + " └─Limit_9 3.00 cop[tikv] offset:0, count:3", + " └─TableFullScan_10 3.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "3" @@ -485,10 +485,10 @@ { "SQL": "select b from t order by b limit 3", "Plan": [ - "TopN_9 3.00 root test.t.b:asc, offset:0, count:3", - "└─TableReader_11 3.00 root data:TopN_12", - " └─TopN_12 3.00 cop[tikv] test.t.b:asc, offset:0, count:3", - " └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "TopN_9 3.00 root test.t.b:asc, offset:0, count:3", + "└─TableReader_11 3.00 root data:TopN_12", + " └─TopN_12 3.00 cop[tikv] test.t.b:asc, offset:0, count:3", + " └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "11", @@ -499,10 +499,10 @@ { "SQL": "select a from t order by a limit 1 offset 2", "Plan": [ - "Limit_10 1.00 root offset:2, count:1", - "└─TableReader_16 3.00 root data:Limit_17", - " └─Limit_17 3.00 cop[tikv] offset:0, count:3", - " └─TableFullScan_15 3.00 cop[tikv] table:t, keep order:true, stats:pseudo" + "Limit_10 1.00 root offset:2, count:1", + "└─TableReader_16 3.00 root data:Limit_17", + " └─Limit_17 3.00 cop[tikv] offset:0, count:3", + " └─TableFullScan_15 3.00 cop[tikv] table:t keep order:true, stats:pseudo" ], "Result": [ "3" @@ -511,14 +511,14 @@ { "SQL": "select * from ((select a as aa from t t1) union all (select b as aa from t t2)) as t3 order by aa", "Plan": [ - "Sort_23 20000.00 root Column#5:asc", - "└─Union_16 20000.00 root ", - " ├─Projection_17 10000.00 root test.t.a", - " │ └─TableReader_18 10000.00 root data:TableFullScan_19", - " │ └─TableFullScan_19 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - " └─Projection_20 10000.00 root test.t.b", - " └─TableReader_21 10000.00 root data:TableFullScan_22", - " └─TableFullScan_22 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "Sort_23 20000.00 root Column#5:asc", + "└─Union_16 20000.00 root ", + " ├─Projection_17 10000.00 root test.t.a", + " │ └─TableReader_18 10000.00 root data:TableFullScan_19", + " │ └─TableFullScan_19 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + " └─Projection_20 10000.00 root test.t.b", + " └─TableReader_21 10000.00 root data:TableFullScan_22", + " └─TableFullScan_22 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ], "Result": [ "1", @@ -534,10 +534,10 @@ { "SQL": "select a, b, lag(a,1) over (order by b) from t order by b", "Plan": [ - "Window_10 10000.00 root lag(test.t.a, 1)->Column#4 over(order by test.t.b asc)", - "└─Sort_15 10000.00 root test.t.b:asc", - " └─TableReader_13 10000.00 root data:TableFullScan_14", - " └─TableFullScan_14 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Window_10 10000.00 root lag(test.t.a, 1)->Column#4 over(order by test.t.b asc)", + "└─Sort_15 10000.00 root test.t.b:asc", + " └─TableReader_13 10000.00 root data:TableFullScan_14", + " └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "1 11 ", @@ -549,12 +549,12 @@ { "SQL": "select * from (select a+1 as c, a+b as d from t) as t1 order by c+d limit 10", "Plan": [ - "Projection_22 10.00 root plus(test.t.a, 1)->Column#3, plus(test.t.a, test.t.b)->Column#4", - "└─TopN_23 10.00 root Column#5:asc, offset:0, count:10", - " └─Projection_25 10.00 root test.t.a, test.t.b, plus(plus(test.t.a, 1), plus(test.t.a, test.t.b))->Column#5", - " └─TableReader_26 10.00 root data:TopN_27", - " └─TopN_27 10.00 cop[tikv] plus(plus(test.t.a, 1), plus(test.t.a, test.t.b)):asc, offset:0, count:10", - " └─TableFullScan_28 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_22 10.00 root plus(test.t.a, 1)->Column#3, plus(test.t.a, test.t.b)->Column#4", + "└─TopN_23 10.00 root Column#5:asc, offset:0, count:10", + " └─Projection_25 10.00 root test.t.a, test.t.b, plus(plus(test.t.a, 1), plus(test.t.a, test.t.b))->Column#5", + " └─TableReader_26 10.00 root data:TopN_27", + " └─TopN_27 10.00 cop[tikv] plus(plus(test.t.a, 1), plus(test.t.a, test.t.b)):asc, offset:0, count:10", + " └─TableFullScan_28 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "2 12", @@ -566,8 +566,8 @@ { "SQL": "select t1.a, t1.b from t as t1 left join t as t2 on t1.a = t2.a and t1.b = 3 order by a", "Plan": [ - "TableReader_24 12500.00 root data:TableFullScan_25", - "└─TableFullScan_25 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo" + "TableReader_24 12500.00 root data:TableFullScan_25", + "└─TableFullScan_25 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo" ], "Result": [ "1 11", @@ -584,8 +584,8 @@ { "SQL": "select b from t", "Plan": [ - "IndexReader_13 10000.00 root index:IndexFullScan_14", - "└─IndexFullScan_14 10000.00 cop[tikv] table:t, index:b, keep order:false, stats:pseudo" + "IndexReader_13 10000.00 root index:IndexFullScan_14", + "└─IndexFullScan_14 10000.00 cop[tikv] table:t, index:idx_b(b) keep order:false, stats:pseudo" ], "Result": [ "2", @@ -596,9 +596,9 @@ { "SQL": "select a from t order by b", "Plan": [ - "Projection_11 10000.00 root test.t.a", - "└─IndexReader_15 10000.00 root index:IndexFullScan_16", - " └─IndexFullScan_16 10000.00 cop[tikv] table:t, index:b, keep order:true, stats:pseudo" + "Projection_11 10000.00 root test.t.a", + "└─IndexReader_15 10000.00 root index:IndexFullScan_16", + " └─IndexFullScan_16 10000.00 cop[tikv] table:t, index:idx_b(b) keep order:true, stats:pseudo" ], "Result": [ "1", @@ -609,8 +609,8 @@ { "SQL": "select c from t", "Plan": [ - "IndexReader_9 10000.00 root index:IndexFullScan_10", - "└─IndexFullScan_10 10000.00 cop[tikv] table:t, index:c, b, keep order:false, stats:pseudo" + "IndexReader_9 10000.00 root index:IndexFullScan_10", + "└─IndexFullScan_10 10000.00 cop[tikv] table:t, index:idx_c_b(c, b) keep order:false, stats:pseudo" ], "Result": [ "3", @@ -621,9 +621,9 @@ { "SQL": "select a from t order by c", "Plan": [ - "Projection_9 10000.00 root test.t.a", - "└─IndexReader_12 10000.00 root index:IndexFullScan_13", - " └─IndexFullScan_13 10000.00 cop[tikv] table:t, index:c, b, keep order:true, stats:pseudo" + "Projection_9 10000.00 root test.t.a", + "└─IndexReader_12 10000.00 root index:IndexFullScan_13", + " └─IndexFullScan_13 10000.00 cop[tikv] table:t, index:idx_c_b(c, b) keep order:true, stats:pseudo" ], "Result": [ "1", @@ -634,8 +634,8 @@ { "SQL": "select a, b from t where b > 5 order by b", "Plan": [ - "IndexReader_18 8000.00 root index:IndexRangeScan_19", - "└─IndexRangeScan_19 3333.33 cop[tikv] table:t, index:b, range:(5,+inf], keep order:true, stats:pseudo" + "IndexReader_18 8000.00 root index:IndexRangeScan_19", + "└─IndexRangeScan_19 3333.33 cop[tikv] table:t, index:idx_b(b) range:(5,+inf], keep order:true, stats:pseudo" ], "Result": [ "7 8" @@ -644,8 +644,8 @@ { "SQL": "select a, b, c from t where c = 3 and b > 1 order by b", "Plan": [ - "IndexReader_15 8000.00 root index:IndexRangeScan_16", - "└─IndexRangeScan_16 33.33 cop[tikv] table:t, index:c, b, range:(3 1,3 +inf], keep order:true, stats:pseudo" + "IndexReader_15 8000.00 root index:IndexRangeScan_16", + "└─IndexRangeScan_16 33.33 cop[tikv] table:t, index:idx_c_b(c, b) range:(3 1,3 +inf], keep order:true, stats:pseudo" ], "Result": [ "1 2 3" @@ -654,10 +654,10 @@ { "SQL": "select a, b from t where c > 1 and b > 1 order by c", "Plan": [ - "Projection_14 8000.00 root test.t.a, test.t.b", - "└─IndexReader_18 8000.00 root index:Selection_19", - " └─Selection_19 2666.67 cop[tikv] gt(test.t.b, 1)", - " └─IndexRangeScan_20 3333.33 cop[tikv] table:t, index:c, b, range:(1,+inf], keep order:true, stats:pseudo" + "Projection_14 8000.00 root test.t.a, test.t.b", + "└─IndexReader_18 8000.00 root index:Selection_19", + " └─Selection_19 2666.67 cop[tikv] gt(test.t.b, 1)", + " └─IndexRangeScan_20 3333.33 cop[tikv] table:t, index:idx_c_b(c, b) range:(1,+inf], keep order:true, stats:pseudo" ], "Result": [ "1 2", @@ -673,12 +673,12 @@ { "SQL": "select t1.a, t1.b from t1, t2 where t1.a = t2.a and t1.a > 2", "Plan": [ - "Projection_16 4166.67 root test.t1.a, test.t1.b", - "└─MergeJoin_19 4166.67 root inner join, left key:test.t1.a, right key:test.t2.a", - " ├─TableReader_27(Build) 3333.33 root data:TableRangeScan_28", - " │ └─TableRangeScan_28 3333.33 cop[tikv] table:t2, range:(2,+inf], keep order:true, stats:pseudo", - " └─TableReader_24(Probe) 3333.33 root data:TableRangeScan_25", - " └─TableRangeScan_25 3333.33 cop[tikv] table:t1, range:(2,+inf], keep order:true, stats:pseudo" + "Projection_16 4166.67 root test.t1.a, test.t1.b", + "└─MergeJoin_19 4166.67 root inner join, left key:test.t1.a, right key:test.t2.a", + " ├─TableReader_27(Build) 3333.33 root data:TableRangeScan_28", + " │ └─TableRangeScan_28 3333.33 cop[tikv] table:t2 range:(2,+inf], keep order:true, stats:pseudo", + " └─TableReader_24(Probe) 3333.33 root data:TableRangeScan_25", + " └─TableRangeScan_25 3333.33 cop[tikv] table:t1 range:(2,+inf], keep order:true, stats:pseudo" ], "Result": [ "3 33" @@ -687,13 +687,13 @@ { "SQL": "select t1.a, t1.b from t1, t2 where t1.a > t2.a and t2.b > 200", "Plan": [ - "Projection_12 80000000.00 root test.t1.a, test.t1.b", - "└─HashLeftJoin_14 80000000.00 root CARTESIAN inner join, other cond:gt(test.t1.a, test.t2.a)", - " ├─TableReader_17(Build) 8000.00 root data:Selection_18", - " │ └─Selection_18 8000.00 cop[tikv] gt(test.t2.b, 200)", - " │ └─TableFullScan_19 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - " └─TableReader_15(Probe) 10000.00 root data:TableFullScan_16", - " └─TableFullScan_16 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "Projection_12 80000000.00 root test.t1.a, test.t1.b", + "└─HashJoin_14 80000000.00 root CARTESIAN inner join, other cond:gt(test.t1.a, test.t2.a)", + " ├─TableReader_17(Build) 8000.00 root data:Selection_18", + " │ └─Selection_18 8000.00 cop[tikv] gt(test.t2.b, 200)", + " │ └─TableFullScan_19 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + " └─TableReader_15(Probe) 10000.00 root data:TableFullScan_16", + " └─TableFullScan_16 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ], "Result": [ "3 33", @@ -704,13 +704,13 @@ { "SQL": "select t1.a, t1.b from t1 left join t2 on t1.a = t2.a where t1.a > 2 and t2.b > 200", "Plan": [ - "Projection_17 3333.33 root test.t1.a, test.t1.b", - "└─Selection_18 3333.33 root gt(test.t2.b, 200)", - " └─MergeJoin_21 4166.67 root left outer join, left key:test.t1.a, right key:test.t2.a", - " ├─TableReader_29(Build) 3333.33 root data:TableRangeScan_30", - " │ └─TableRangeScan_30 3333.33 cop[tikv] table:t2, range:(2,+inf], keep order:true, stats:pseudo", - " └─TableReader_26(Probe) 3333.33 root data:TableRangeScan_27", - " └─TableRangeScan_27 3333.33 cop[tikv] table:t1, range:(2,+inf], keep order:true, stats:pseudo" + "Projection_17 3333.33 root test.t1.a, test.t1.b", + "└─Selection_18 3333.33 root gt(test.t2.b, 200)", + " └─MergeJoin_21 4166.67 root left outer join, left key:test.t1.a, right key:test.t2.a", + " ├─TableReader_29(Build) 3333.33 root data:TableRangeScan_30", + " │ └─TableRangeScan_30 3333.33 cop[tikv] table:t2 range:(2,+inf], keep order:true, stats:pseudo", + " └─TableReader_26(Probe) 3333.33 root data:TableRangeScan_27", + " └─TableRangeScan_27 3333.33 cop[tikv] table:t1 range:(2,+inf], keep order:true, stats:pseudo" ], "Result": [ "3 33" @@ -719,14 +719,14 @@ { "SQL": "select t2.a, t2.b from t1 right join t2 on t1.a = t2.a where t1.a > 2 and t2.b > 200", "Plan": [ - "Projection_13 8000.00 root test.t2.a, test.t2.b", - "└─Selection_14 8000.00 root gt(test.t1.a, 2)", - " └─MergeJoin_17 10000.00 root right outer join, left key:test.t1.a, right key:test.t2.a", - " ├─TableReader_23(Build) 10000.00 root data:TableFullScan_24", - " │ └─TableFullScan_24 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo", - " └─TableReader_26(Probe) 8000.00 root data:Selection_27", - " └─Selection_27 8000.00 cop[tikv] gt(test.t2.b, 200)", - " └─TableFullScan_28 10000.00 cop[tikv] table:t2, keep order:true, stats:pseudo" + "Projection_13 8000.00 root test.t2.a, test.t2.b", + "└─Selection_14 8000.00 root gt(test.t1.a, 2)", + " └─MergeJoin_17 10000.00 root right outer join, left key:test.t1.a, right key:test.t2.a", + " ├─TableReader_23(Build) 10000.00 root data:TableFullScan_24", + " │ └─TableFullScan_24 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo", + " └─TableReader_26(Probe) 8000.00 root data:Selection_27", + " └─Selection_27 8000.00 cop[tikv] gt(test.t2.b, 200)", + " └─TableFullScan_28 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo" ], "Result": [ "3 333" @@ -735,12 +735,12 @@ { "SQL": "select t1.a, t1.b from t1, t2 where t1.a = t2.a order by t1.a", "Plan": [ - "Projection_12 12500.00 root test.t1.a, test.t1.b", - "└─MergeJoin_13 12500.00 root inner join, left key:test.t1.a, right key:test.t2.a", - " ├─TableReader_19(Build) 10000.00 root data:TableFullScan_20", - " │ └─TableFullScan_20 10000.00 cop[tikv] table:t2, keep order:true, stats:pseudo", - " └─TableReader_14(Probe) 10000.00 root data:TableFullScan_15", - " └─TableFullScan_15 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo" + "Projection_12 12500.00 root test.t1.a, test.t1.b", + "└─MergeJoin_13 12500.00 root inner join, left key:test.t1.a, right key:test.t2.a", + " ├─TableReader_19(Build) 10000.00 root data:TableFullScan_20", + " │ └─TableFullScan_20 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo", + " └─TableReader_14(Probe) 10000.00 root data:TableFullScan_15", + " └─TableFullScan_15 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo" ], "Result": [ "1 11", @@ -751,11 +751,11 @@ { "SQL": "select * from t1 join t2 on t1.a = t2.a", "Plan": [ - "MergeJoin_11 12500.00 root inner join, left key:test.t1.a, right key:test.t2.a", - "├─TableReader_19(Build) 10000.00 root data:TableFullScan_20", - "│ └─TableFullScan_20 10000.00 cop[tikv] table:t2, keep order:true, stats:pseudo", - "└─TableReader_16(Probe) 10000.00 root data:TableFullScan_17", - " └─TableFullScan_17 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo" + "MergeJoin_11 12500.00 root inner join, left key:test.t1.a, right key:test.t2.a", + "├─TableReader_19(Build) 10000.00 root data:TableFullScan_20", + "│ └─TableFullScan_20 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo", + "└─TableReader_16(Probe) 10000.00 root data:TableFullScan_17", + " └─TableFullScan_17 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo" ], "Result": [ "1 11 1 111", @@ -771,17 +771,17 @@ { "SQL": "select a = (select a from t2 where t1.b = t2.b order by a limit 1) from t1", "Plan": [ - "Projection_18 10000.00 root eq(test.t1.a, test.t2.a)->Column#5", - "└─Apply_20 10000.00 root CARTESIAN left outer join", - " ├─TableReader_21(Build) 10000.00 root data:TableFullScan_22", - " │ └─TableFullScan_22 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - " └─MaxOneRow_23(Probe) 1.00 root ", - " └─Projection_24 1.00 root test.t2.a", - " └─Limit_26 1.00 root offset:0, count:1", - " └─TableReader_34 1.00 root data:Limit_35", - " └─Limit_35 1.00 cop[tikv] offset:0, count:1", - " └─Selection_32 1.00 cop[tikv] eq(test.t1.b, test.t2.b)", - " └─TableFullScan_33 1.00 cop[tikv] table:t2, keep order:true, stats:pseudo" + "Projection_18 10000.00 root eq(test.t1.a, test.t2.a)->Column#5", + "└─Apply_20 10000.00 root CARTESIAN left outer join", + " ├─TableReader_21(Build) 10000.00 root data:TableFullScan_22", + " │ └─TableFullScan_22 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + " └─MaxOneRow_23(Probe) 1.00 root ", + " └─Projection_24 1.00 root test.t2.a", + " └─Limit_26 1.00 root offset:0, count:1", + " └─TableReader_34 1.00 root data:Limit_35", + " └─Limit_35 1.00 cop[tikv] offset:0, count:1", + " └─Selection_32 1.00 cop[tikv] eq(test.t1.b, test.t2.b)", + " └─TableFullScan_33 1.00 cop[tikv] table:t2 keep order:true, stats:pseudo" ], "Result": [ "1", @@ -793,25 +793,25 @@ { "SQL": "select sum(a), (select t1.a from t1 where t1.a = t2.a limit 1), (select t1.b from t1 where t1.b = t2.b limit 1) from t2", "Plan": [ - "Projection_28 1.00 root Column#3, test.t1.a, test.t1.b", - "└─Apply_30 1.00 root CARTESIAN left outer join", - " ├─Apply_32(Build) 1.00 root CARTESIAN left outer join", - " │ ├─HashAgg_37(Build) 1.00 root funcs:sum(Column#8)->Column#3, funcs:firstrow(Column#9)->test.t2.a, funcs:firstrow(Column#10)->test.t2.b", - " │ │ └─TableReader_38 1.00 root data:HashAgg_39", - " │ │ └─HashAgg_39 1.00 cop[tikv] funcs:sum(test.t2.a)->Column#8, funcs:firstrow(test.t2.a)->Column#9, funcs:firstrow(test.t2.b)->Column#10", - " │ │ └─TableFullScan_35 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - " │ └─MaxOneRow_40(Probe) 1.00 root ", - " │ └─Limit_41 1.00 root offset:0, count:1", - " │ └─TableReader_42 1.00 root data:Limit_43", - " │ └─Limit_43 1.00 cop[tikv] offset:0, count:1", - " │ └─Selection_44 1.00 cop[tikv] eq(test.t1.a, test.t2.a)", - " │ └─TableFullScan_45 1.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - " └─MaxOneRow_46(Probe) 1.00 root ", - " └─Limit_47 1.00 root offset:0, count:1", - " └─TableReader_48 1.00 root data:Limit_49", - " └─Limit_49 1.00 cop[tikv] offset:0, count:1", - " └─Selection_50 1.00 cop[tikv] eq(test.t1.b, test.t2.b)", - " └─TableFullScan_51 1.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "Projection_28 1.00 root Column#3, test.t1.a, test.t1.b", + "└─Apply_30 1.00 root CARTESIAN left outer join", + " ├─Apply_32(Build) 1.00 root CARTESIAN left outer join", + " │ ├─HashAgg_37(Build) 1.00 root funcs:sum(Column#8)->Column#3, funcs:firstrow(Column#9)->test.t2.a, funcs:firstrow(Column#10)->test.t2.b", + " │ │ └─TableReader_38 1.00 root data:HashAgg_39", + " │ │ └─HashAgg_39 1.00 cop[tikv] funcs:sum(test.t2.a)->Column#8, funcs:firstrow(test.t2.a)->Column#9, funcs:firstrow(test.t2.b)->Column#10", + " │ │ └─TableFullScan_35 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + " │ └─MaxOneRow_40(Probe) 1.00 root ", + " │ └─Limit_41 1.00 root offset:0, count:1", + " │ └─TableReader_42 1.00 root data:Limit_43", + " │ └─Limit_43 1.00 cop[tikv] offset:0, count:1", + " │ └─Selection_44 1.00 cop[tikv] eq(test.t1.a, test.t2.a)", + " │ └─TableFullScan_45 1.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + " └─MaxOneRow_46(Probe) 1.00 root ", + " └─Limit_47 1.00 root offset:0, count:1", + " └─TableReader_48 1.00 root data:Limit_49", + " └─Limit_49 1.00 cop[tikv] offset:0, count:1", + " └─Selection_50 1.00 cop[tikv] eq(test.t1.b, test.t2.b)", + " └─TableFullScan_51 1.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ], "Result": [ "6 1 11" @@ -820,11 +820,11 @@ { "SQL": "select a from t1 where exists(select 1 from t2 where t1.a = t2.a)", "Plan": [ - "MergeJoin_27 10000.00 root semi join, left key:test.t1.a, right key:test.t2.a", - "├─TableReader_32(Build) 10000.00 root data:TableFullScan_33", - "│ └─TableFullScan_33 10000.00 cop[tikv] table:t2, keep order:true, stats:pseudo", - "└─TableReader_29(Probe) 10000.00 root data:TableFullScan_30", - " └─TableFullScan_30 10000.00 cop[tikv] table:t1, keep order:true, stats:pseudo" + "MergeJoin_27 10000.00 root semi join, left key:test.t1.a, right key:test.t2.a", + "├─TableReader_32(Build) 10000.00 root data:TableFullScan_33", + "│ └─TableFullScan_33 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo", + "└─TableReader_29(Probe) 10000.00 root data:TableFullScan_30", + " └─TableFullScan_30 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo" ], "Result": [ "1", @@ -840,7 +840,7 @@ { "SQL": "select * from information_schema.processlist", "Plan": [ - "MemTableScan_3 10000.00 root table:PROCESSLIST" + "MemTableScan_3 10000.00 root table:PROCESSLIST " ], "Result": null } @@ -852,12 +852,12 @@ { "SQL": "select a from (select a from t where b > 2 order by a limit 3 offset 1) as t1 order by a limit 2 offset 1", "Plan": [ - "Projection_22 2.00 root test.t.a", - "└─Limit_24 2.00 root offset:2, count:2", - " └─TableReader_32 4.00 root data:Limit_33", - " └─Limit_33 4.00 cop[tikv] offset:0, count:4", - " └─Selection_30 4.00 cop[tikv] gt(test.t.b, 2)", - " └─TableFullScan_31 4.00 cop[tikv] table:t, keep order:true, stats:pseudo" + "Projection_22 2.00 root test.t.a", + "└─Limit_24 2.00 root offset:2, count:2", + " └─TableReader_32 4.00 root data:Limit_33", + " └─Limit_33 4.00 cop[tikv] offset:0, count:4", + " └─Selection_30 4.00 cop[tikv] gt(test.t.b, 2)", + " └─TableFullScan_31 4.00 cop[tikv] table:t keep order:true, stats:pseudo" ], "Result": [ "3", @@ -867,10 +867,10 @@ { "SQL": "select * from (select * from t order by a limit 3) as t1 order by a limit 5", "Plan": [ - "Limit_15 3.00 root offset:0, count:3", - "└─TableReader_21 3.00 root data:Limit_22", - " └─Limit_22 3.00 cop[tikv] offset:0, count:3", - " └─TableFullScan_20 3.00 cop[tikv] table:t, keep order:true, stats:pseudo" + "Limit_15 3.00 root offset:0, count:3", + "└─TableReader_21 3.00 root data:Limit_22", + " └─Limit_22 3.00 cop[tikv] offset:0, count:3", + " └─TableFullScan_20 3.00 cop[tikv] table:t keep order:true, stats:pseudo" ], "Result": [ "1 11", @@ -881,39 +881,39 @@ { "SQL": "select b from (select b from t order by b limit 10 offset 10) as t1 order by b limit 10 offset 5", "Plan": [ - "TopN_14 5.00 root test.t.b:asc, offset:15, count:5", - "└─TableReader_16 20.00 root data:TopN_17", - " └─TopN_17 20.00 cop[tikv] test.t.b:asc, offset:0, count:20", - " └─TableFullScan_19 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "TopN_14 5.00 root test.t.b:asc, offset:15, count:5", + "└─TableReader_16 20.00 root data:TopN_17", + " └─TopN_17 20.00 cop[tikv] test.t.b:asc, offset:0, count:20", + " └─TableFullScan_19 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": null }, { "SQL": "select b from (select b from t order by b limit 10 offset 2) as t1 order by b limit 3 offset 5", "Plan": [ - "TopN_14 3.00 root test.t.b:asc, offset:7, count:3", - "└─TableReader_16 10.00 root data:TopN_17", - " └─TopN_17 10.00 cop[tikv] test.t.b:asc, offset:0, count:10", - " └─TableFullScan_19 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "TopN_14 3.00 root test.t.b:asc, offset:7, count:3", + "└─TableReader_16 10.00 root data:TopN_17", + " └─TopN_17 10.00 cop[tikv] test.t.b:asc, offset:0, count:10", + " └─TableFullScan_19 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": null }, { "SQL": "select a from (select a from t order by a limit 3 offset 5) as t1 order by a limit 3 offset 5", "Plan": [ - "TableDual_11 0.00 root rows:0" + "TableDual_11 0.00 root rows:0" ], "Result": null }, { "SQL": "select a from (select a from t where b > 2 order by a, b limit 3 offset 1) as t1 order by a limit 2 offset 1", "Plan": [ - "Projection_22 2.00 root test.t.a", - "└─TopN_23 2.00 root test.t.a:asc, test.t.b:asc, offset:2, count:2", - " └─TableReader_25 4.00 root data:TopN_26", - " └─TopN_26 4.00 cop[tikv] test.t.a:asc, test.t.b:asc, offset:0, count:4", - " └─Selection_28 8000.00 cop[tikv] gt(test.t.b, 2)", - " └─TableFullScan_29 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "Projection_22 2.00 root test.t.a", + "└─TopN_23 2.00 root test.t.a:asc, test.t.b:asc, offset:2, count:2", + " └─TableReader_25 4.00 root data:TopN_26", + " └─TopN_26 4.00 cop[tikv] test.t.a:asc, test.t.b:asc, offset:0, count:4", + " └─Selection_28 8000.00 cop[tikv] gt(test.t.b, 2)", + " └─TableFullScan_29 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Result": [ "3", @@ -923,12 +923,12 @@ { "SQL": "select * from (select * from t order by a limit 3) as t1 order by a, b limit 5", "Plan": [ - "Limit_14 3.00 root offset:0, count:5", - "└─Sort_26 3.00 root test.t.a:asc, test.t.b:asc", - " └─Limit_16 3.00 root offset:0, count:3", - " └─TableReader_22 3.00 root data:Limit_23", - " └─Limit_23 3.00 cop[tikv] offset:0, count:3", - " └─TableFullScan_21 3.00 cop[tikv] table:t, keep order:true, stats:pseudo" + "Limit_14 3.00 root offset:0, count:5", + "└─Sort_26 3.00 root test.t.a:asc, test.t.b:asc", + " └─Limit_16 3.00 root offset:0, count:3", + " └─TableReader_22 3.00 root data:Limit_23", + " └─Limit_23 3.00 cop[tikv] offset:0, count:3", + " └─TableFullScan_21 3.00 cop[tikv] table:t keep order:true, stats:pseudo" ], "Result": [ "1 11", @@ -944,8 +944,8 @@ { "SQL": "select * from pt1", "Plan": [ - "TableReader_5 10000.00 root data:TableFullScan_6", - "└─TableFullScan_6 10000.00 cop[tikv] table:pt1, keep order:false, stats:pseudo" + "TableReader_5 10000.00 root data:TableFullScan_6", + "└─TableFullScan_6 10000.00 cop[tikv] table:pt1 keep order:false, stats:pseudo" ], "Result": null } @@ -957,14 +957,14 @@ { "SQL": "select /*+ HASH_JOIN(t1) */ t1.b, t2.b from t1, t2 where t1.a = t2.a;", "Plan": [ - "Projection_14 10000.00 root test.t1.b, test.t2.b", - "└─HashRightJoin_15 10000.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", - " ├─TableReader_17(Build) 8000.00 root data:Selection_18", - " │ └─Selection_18 8000.00 cop[tikv] not(isnull(test.t1.a))", - " │ └─TableFullScan_19 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - " └─TableReader_20(Probe) 8000.00 root data:Selection_21", - " └─Selection_21 8000.00 cop[tikv] not(isnull(test.t2.a))", - " └─TableFullScan_22 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "Projection_14 10000.00 root test.t1.b, test.t2.b", + "└─HashJoin_15 10000.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", + " ├─TableReader_17(Build) 8000.00 root data:Selection_18", + " │ └─Selection_18 8000.00 cop[tikv] not(isnull(test.t1.a))", + " │ └─TableFullScan_19 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + " └─TableReader_20(Probe) 8000.00 root data:Selection_21", + " └─Selection_21 8000.00 cop[tikv] not(isnull(test.t2.a))", + " └─TableFullScan_22 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ], "Result": [ "1 1" @@ -973,11 +973,11 @@ { "SQL": "select /*+ HASH_JOIN(t1) */ t1.b, t2.b from t1 inner join t2 on t1.a = t2.a;", "Plan": [ - "HashRightJoin_9 12500.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", - "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", - " └─TableFullScan_14 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_9 12500.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", + "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", + " └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ], "Result": [ "1 1" @@ -986,11 +986,11 @@ { "SQL": "select /*+ HASH_JOIN(t1) */ t1.b, t2.b from t1 left outer join t2 on t1.a = t2.a;", "Plan": [ - "HashLeftJoin_10 12500.00 root left outer join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_13(Build) 10000.00 root data:TableFullScan_14", - "│ └─TableFullScan_14 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_11(Probe) 10000.00 root data:TableFullScan_12", - " └─TableFullScan_12 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_10 12500.00 root left outer join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_13(Build) 10000.00 root data:TableFullScan_14", + "│ └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_11(Probe) 10000.00 root data:TableFullScan_12", + " └─TableFullScan_12 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ], "Result": [ "1 1", @@ -1000,11 +1000,11 @@ { "SQL": "select /*+ HASH_JOIN(t1) */ t1.b, t2.b from t1 right outer join t2 on t1.a = t2.a;", "Plan": [ - "HashRightJoin_9 12500.00 root right outer join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", - "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", - " └─TableFullScan_14 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_9 12500.00 root right outer join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", + "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", + " └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ], "Result": [ "1 1", @@ -1014,12 +1014,12 @@ { "SQL": "select 1 from (select /*+ HASH_JOIN(t1) */ t1.a in (select t2.a from t2) from t1) x;", "Plan": [ - "Projection_17 10000.00 root 1->Column#8", - "└─HashLeftJoin_18 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.a, test.t2.a)", - " ├─IndexReader_25(Build) 10000.00 root index:IndexFullScan_26", - " │ └─IndexFullScan_26 10000.00 cop[tikv] table:t2, index:a, keep order:false, stats:pseudo", - " └─IndexReader_21(Probe) 10000.00 root index:IndexFullScan_22", - " └─IndexFullScan_22 10000.00 cop[tikv] table:t1, index:a, keep order:false, stats:pseudo" + "Projection_17 10000.00 root 1->Column#8", + "└─HashJoin_18 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.a, test.t2.a)", + " ├─IndexReader_25(Build) 10000.00 root index:IndexFullScan_26", + " │ └─IndexFullScan_26 10000.00 cop[tikv] table:t2, index:idx_a(a) keep order:false, stats:pseudo", + " └─IndexReader_21(Probe) 10000.00 root index:IndexFullScan_22", + " └─IndexFullScan_22 10000.00 cop[tikv] table:t1, index:idx_a(a) keep order:false, stats:pseudo" ], "Result": [ "1", @@ -1029,12 +1029,12 @@ { "SQL": "select 1 from (select /*+ HASH_JOIN(t1) */ t1.a not in (select t2.a from t2) from t1) x;", "Plan": [ - "Projection_17 10000.00 root 1->Column#8", - "└─HashLeftJoin_18 10000.00 root CARTESIAN anti left outer semi join, other cond:eq(test.t1.a, test.t2.a)", - " ├─IndexReader_25(Build) 10000.00 root index:IndexFullScan_26", - " │ └─IndexFullScan_26 10000.00 cop[tikv] table:t2, index:a, keep order:false, stats:pseudo", - " └─IndexReader_21(Probe) 10000.00 root index:IndexFullScan_22", - " └─IndexFullScan_22 10000.00 cop[tikv] table:t1, index:a, keep order:false, stats:pseudo" + "Projection_17 10000.00 root 1->Column#8", + "└─HashJoin_18 10000.00 root CARTESIAN anti left outer semi join, other cond:eq(test.t1.a, test.t2.a)", + " ├─IndexReader_25(Build) 10000.00 root index:IndexFullScan_26", + " │ └─IndexFullScan_26 10000.00 cop[tikv] table:t2, index:idx_a(a) keep order:false, stats:pseudo", + " └─IndexReader_21(Probe) 10000.00 root index:IndexFullScan_22", + " └─IndexFullScan_22 10000.00 cop[tikv] table:t1, index:idx_a(a) keep order:false, stats:pseudo" ], "Result": [ "1", @@ -1044,11 +1044,11 @@ { "SQL": "select /*+ INL_JOIN(t1) */ t1.b, t2.b from t1 inner join t2 on t1.a = t2.a;", "Plan": [ - "HashRightJoin_9 12500.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", - "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", - " └─TableFullScan_14 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_9 12500.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", + "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", + " └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ], "Result": [ "1 1" @@ -1057,11 +1057,11 @@ { "SQL": "select /*+ INL_HASH_JOIN(t1) */ t1.b, t2.b from t1 inner join t2 on t1.a = t2.a;", "Plan": [ - "HashRightJoin_9 12500.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", - "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", - " └─TableFullScan_14 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_9 12500.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", + "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", + " └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ], "Result": [ "1 1" @@ -1070,11 +1070,11 @@ { "SQL": "select /*+ INL_MERGE_JOIN(t1) */ t1.b, t2.b from t1 inner join t2 on t1.a = t2.a;", "Plan": [ - "HashRightJoin_9 12500.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", - "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", - " └─TableFullScan_14 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_9 12500.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_11(Build) 10000.00 root data:TableFullScan_12", + "│ └─TableFullScan_12 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_14", + " └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ], "Result": [ "1 1" diff --git a/planner/core/cache.go b/planner/core/cache.go index 066acc69bb223..546b797ded7dc 100644 --- a/planner/core/cache.go +++ b/planner/core/cache.go @@ -139,8 +139,12 @@ func NewPSTMTPlanCacheValue(plan Plan, names []*types.FieldName) *PSTMTPlanCache // CachedPrepareStmt store prepared ast from PrepareExec and other related fields type CachedPrepareStmt struct { - PreparedAst *ast.Prepared - VisitInfos []visitInfo - ColumnInfos interface{} - Executor interface{} + PreparedAst *ast.Prepared + VisitInfos []visitInfo + ColumnInfos interface{} + Executor interface{} + NormalizedSQL string + NormalizedPlan string + SQLDigest string + PlanDigest string } diff --git a/planner/core/cbo_test.go b/planner/core/cbo_test.go index 13a33d745c5f4..8f738426a15d2 100644 --- a/planner/core/cbo_test.go +++ b/planner/core/cbo_test.go @@ -94,11 +94,10 @@ func (s *testAnalyzeSuite) TestExplainAnalyze(c *C) { rs := tk.MustQuery("explain analyze select t1.a, t1.b, sum(t1.c) from t1 join t2 on t1.a = t2.b where t1.a > 1") c.Assert(len(rs.Rows()), Equals, 10) for _, row := range rs.Rows() { - c.Assert(len(row), Equals, 8) + c.Assert(len(row), Equals, 9) execInfo := row[5].(string) c.Assert(strings.Contains(execInfo, "time"), Equals, true) c.Assert(strings.Contains(execInfo, "loops"), Equals, true) - c.Assert(strings.Contains(execInfo, "rows"), Equals, true) } } @@ -123,13 +122,13 @@ func (s *testAnalyzeSuite) TestCBOWithoutAnalyze(c *C) { c.Assert(h.DumpStatsDeltaToKV(handle.DumpAll), IsNil) c.Assert(h.Update(dom.InfoSchema()), IsNil) testKit.MustQuery("explain select * from t1, t2 where t1.a = t2.a").Check(testkit.Rows( - "HashLeftJoin_8 7.49 root inner join, equal:[eq(test.t1.a, test.t2.a)]", - "├─TableReader_15(Build) 5.99 root data:Selection_14", - "│ └─Selection_14 5.99 cop[tikv] not(isnull(test.t2.a))", - "│ └─TableFullScan_13 6.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_12(Probe) 5.99 root data:Selection_11", - " └─Selection_11 5.99 cop[tikv] not(isnull(test.t1.a))", - " └─TableFullScan_10 6.00 cop[tikv] table:t1, keep order:false, stats:pseudo", + "HashJoin_8 7.49 root inner join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader_15(Build) 5.99 root data:Selection_14", + "│ └─Selection_14 5.99 cop[tikv] not(isnull(test.t2.a))", + "│ └─TableFullScan_13 6.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_12(Probe) 5.99 root data:Selection_11", + " └─Selection_11 5.99 cop[tikv] not(isnull(test.t1.a))", + " └─TableFullScan_10 6.00 cop[tikv] table:t1 keep order:false, stats:pseudo", )) testKit.MustQuery("explain format = 'hint' select * from t1, t2 where t1.a = t2.a").Check(testkit.Rows( "USE_INDEX(@`sel_1` `test`.`t1` ), USE_INDEX(@`sel_1` `test`.`t2` ), HASH_JOIN(@`sel_1` `test`.`t1`)")) @@ -181,11 +180,11 @@ func (s *testAnalyzeSuite) TestTableDual(c *C) { c.Assert(h.Update(dom.InfoSchema()), IsNil) testKit.MustQuery(`explain select * from t where 1 = 0`).Check(testkit.Rows( - `TableDual_6 0.00 root rows:0`, + `TableDual_6 0.00 root rows:0`, )) testKit.MustQuery(`explain select * from t where 1 = 1 limit 0`).Check(testkit.Rows( - `TableDual_5 0.00 root rows:0`, + `TableDual_5 0.00 root rows:0`, )) } @@ -215,10 +214,10 @@ func (s *testAnalyzeSuite) TestEstimation(c *C) { c.Assert(h.DumpStatsDeltaToKV(handle.DumpAll), IsNil) c.Assert(h.Update(dom.InfoSchema()), IsNil) testKit.MustQuery("explain select count(*) from t group by a").Check(testkit.Rows( - "HashAgg_9 2.00 root group by:test.t.a, funcs:count(Column#4)->Column#3", - "└─TableReader_10 2.00 root data:HashAgg_5", - " └─HashAgg_5 2.00 cop[tikv] group by:test.t.a, funcs:count(1)->Column#4", - " └─TableFullScan_8 8.00 cop[tikv] table:t, keep order:false", + "HashAgg_9 2.00 root group by:test.t.a, funcs:count(Column#4)->Column#3", + "└─TableReader_10 2.00 root data:HashAgg_5", + " └─HashAgg_5 2.00 cop[tikv] group by:test.t.a, funcs:count(1)->Column#4", + " └─TableFullScan_8 8.00 cop[tikv] table:t keep order:false", )) } @@ -406,15 +405,15 @@ func (s *testAnalyzeSuite) TestOutdatedAnalyze(c *C) { c.Assert(h.Update(dom.InfoSchema()), IsNil) statistics.RatioOfPseudoEstimate.Store(10.0) testKit.MustQuery("explain select * from t where a <= 5 and b <= 5").Check(testkit.Rows( - "TableReader_7 35.91 root data:Selection_6", - "└─Selection_6 35.91 cop[tikv] le(test.t.a, 5), le(test.t.b, 5)", - " └─TableFullScan_5 80.00 cop[tikv] table:t, keep order:false", + "TableReader_7 35.91 root data:Selection_6", + "└─Selection_6 35.91 cop[tikv] le(test.t.a, 5), le(test.t.b, 5)", + " └─TableFullScan_5 80.00 cop[tikv] table:t keep order:false", )) statistics.RatioOfPseudoEstimate.Store(0.7) testKit.MustQuery("explain select * from t where a <= 5 and b <= 5").Check(testkit.Rows( - "TableReader_7 8.84 root data:Selection_6", - "└─Selection_6 8.84 cop[tikv] le(test.t.a, 5), le(test.t.b, 5)", - " └─TableFullScan_5 80.00 cop[tikv] table:t, keep order:false, stats:pseudo", + "TableReader_7 8.84 root data:Selection_6", + "└─Selection_6 8.84 cop[tikv] le(test.t.a, 5), le(test.t.b, 5)", + " └─TableFullScan_5 80.00 cop[tikv] table:t keep order:false, stats:pseudo", )) } @@ -546,10 +545,10 @@ func (s *testAnalyzeSuite) TestInconsistentEstimation(c *C) { // the `a = 5 and c = 5` will get 10, it is not consistent. tk.MustQuery("explain select * from t use index(ab) where a = 5 and c = 5"). Check(testkit.Rows( - "IndexLookUp_8 10.00 root ", - "├─IndexRangeScan_5(Build) 12.50 cop[tikv] table:t, index:a, b, range:[5,5], keep order:false", - "└─Selection_7(Probe) 10.00 cop[tikv] eq(test.t.c, 5)", - " └─TableRowIDScan_6 12.50 cop[tikv] table:t, keep order:false", + "IndexLookUp_8 10.00 root ", + "├─IndexRangeScan_5(Build) 12.50 cop[tikv] table:t, index:ab(a, b) range:[5,5], keep order:false", + "└─Selection_7(Probe) 10.00 cop[tikv] eq(test.t.c, 5)", + " └─TableRowIDScan_6 12.50 cop[tikv] table:t keep order:false", )) } diff --git a/planner/core/common_plans.go b/planner/core/common_plans.go index 4e6cc481e3692..5d179f24fa1c9 100644 --- a/planner/core/common_plans.go +++ b/planner/core/common_plans.go @@ -263,6 +263,7 @@ func (e *Execute) checkPreparedPriv(ctx context.Context, sctx sessionctx.Context } func (e *Execute) getPhysicalPlan(ctx context.Context, sctx sessionctx.Context, is infoschema.InfoSchema, preparedStmt *CachedPrepareStmt) error { + stmtCtx := sctx.GetSessionVars().StmtCtx prepared := preparedStmt.PreparedAst if prepared.CachedPlan != nil { // Rewriting the expression in the select.where condition will convert its @@ -282,11 +283,11 @@ func (e *Execute) getPhysicalPlan(ctx context.Context, sctx sessionctx.Context, } e.names = names e.Plan = plan - sctx.GetSessionVars().StmtCtx.PointExec = true + stmtCtx.PointExec = true return nil } var cacheKey kvcache.Key - sctx.GetSessionVars().StmtCtx.UseCache = prepared.UseCache + stmtCtx.UseCache = prepared.UseCache if prepared.UseCache { cacheKey = NewPSTMTPlanCacheKey(sctx.GetSessionVars(), e.ExecID, prepared.SchemaVersion) if cacheValue, exists := sctx.PreparedPlanCache().Get(cacheKey); exists { @@ -305,6 +306,7 @@ func (e *Execute) getPhysicalPlan(ctx context.Context, sctx sessionctx.Context, } e.names = cachedVal.OutPutNames e.Plan = cachedVal.Plan + stmtCtx.SetPlanDigest(preparedStmt.NormalizedPlan, preparedStmt.PlanDigest) return nil } } @@ -312,7 +314,7 @@ func (e *Execute) getPhysicalPlan(ctx context.Context, sctx sessionctx.Context, if err != nil { return err } - err = e.tryCachePointPlan(ctx, sctx, prepared, is, p) + err = e.tryCachePointPlan(ctx, sctx, preparedStmt, is, p) if err != nil { return err } @@ -320,7 +322,10 @@ func (e *Execute) getPhysicalPlan(ctx context.Context, sctx sessionctx.Context, e.Plan = p _, isTableDual := p.(*PhysicalTableDual) if !isTableDual && prepared.UseCache { - sctx.PreparedPlanCache().Put(cacheKey, NewPSTMTPlanCacheValue(p, names)) + cached := NewPSTMTPlanCacheValue(p, names) + preparedStmt.NormalizedPlan, preparedStmt.PlanDigest = NormalizePlan(p) + stmtCtx.SetPlanDigest(preparedStmt.NormalizedPlan, preparedStmt.PlanDigest) + sctx.PreparedPlanCache().Put(cacheKey, cached) } return err } @@ -328,11 +333,12 @@ func (e *Execute) getPhysicalPlan(ctx context.Context, sctx sessionctx.Context, // tryCachePointPlan will try to cache point execution plan, there may be some // short paths for these executions, currently "point select" and "point update" func (e *Execute) tryCachePointPlan(ctx context.Context, sctx sessionctx.Context, - prepared *ast.Prepared, is infoschema.InfoSchema, p Plan) error { + preparedStmt *CachedPrepareStmt, is infoschema.InfoSchema, p Plan) error { var ( - ok bool - err error - names types.NameSlice + prepared = preparedStmt.PreparedAst + ok bool + err error + names types.NameSlice ) switch p.(type) { case *PointGetPlan: @@ -356,6 +362,8 @@ func (e *Execute) tryCachePointPlan(ctx context.Context, sctx sessionctx.Context // just cache point plan now prepared.CachedPlan = p prepared.CachedNames = names + preparedStmt.NormalizedPlan, preparedStmt.PlanDigest = NormalizePlan(p) + sctx.GetSessionVars().StmtCtx.SetPlanDigest(preparedStmt.NormalizedPlan, preparedStmt.PlanDigest) } return err } @@ -733,9 +741,9 @@ func (e *Explain) prepareSchema() error { switch { case format == ast.ExplainFormatROW && !e.Analyze: - fieldNames = []string{"id", "estRows", "task", "operator info"} + fieldNames = []string{"id", "estRows", "task", "access object", "operator info"} case format == ast.ExplainFormatROW && e.Analyze: - fieldNames = []string{"id", "estRows", "actRows", "task", "operator info", "execution info", "memory", "disk"} + fieldNames = []string{"id", "estRows", "actRows", "task", "access object", "execution info", "operator info", "memory", "disk"} case format == ast.ExplainFormatDOT: fieldNames = []string{"dot contents"} case format == ast.ExplainFormatHint: @@ -852,15 +860,15 @@ func (e *Explain) explainPlanInRowFormat(p Plan, taskType, driverSide, indent st err = e.explainPlanInRowFormat(x.indexPlan, "cop[tikv]", "(Build)", childIndent, false) err = e.explainPlanInRowFormat(x.tablePlan, "cop[tikv]", "(Probe)", childIndent, true) case *PhysicalIndexMergeReader: - for i := 0; i < len(x.partialPlans); i++ { - if x.tablePlan == nil && i == len(x.partialPlans)-1 { - err = e.explainPlanInRowFormat(x.partialPlans[i], "cop[tikv]", "", childIndent, true) + for i, pchild := range x.partialPlans { + if x.tablePlan != nil || i < len(x.partialPlans)-1 { + err = e.explainPlanInRowFormat(pchild, "cop[tikv]", "(Build)", childIndent, false) } else { - err = e.explainPlanInRowFormat(x.partialPlans[i], "cop[tikv]", "", childIndent, false) + err = e.explainPlanInRowFormat(pchild, "cop[tikv]", "(Probe)", childIndent, true) } } if x.tablePlan != nil { - err = e.explainPlanInRowFormat(x.tablePlan, "cop[tikv]", "", childIndent, true) + err = e.explainPlanInRowFormat(x.tablePlan, "cop[tikv]", "(Probe)", childIndent, true) } case *Insert: if x.SelectPlan != nil { @@ -876,40 +884,52 @@ func (e *Explain) explainPlanInRowFormat(p Plan, taskType, driverSide, indent st } case *Execute: if x.Plan != nil { - err = e.explainPlanInRowFormat(x.Plan, "root", "", childIndent, true) + err = e.explainPlanInRowFormat(x.Plan, "root", "", indent, true) } } return } // prepareOperatorInfo generates the following information for every plan: -// operator id, task type, operator info, and the estemated rows. -// `estRows` used to be called `count`, see issue/14603. +// operator id, estimated rows, task type, access object and other operator info. func (e *Explain) prepareOperatorInfo(p Plan, taskType, driverSide, indent string, isLastChild bool) { - operatorInfo := p.ExplainInfo() + if p.ExplainID().String() == "_0" { + return + } + + id := texttree.PrettyIdentifier(p.ExplainID().String()+driverSide, indent, isLastChild) + estRows := "N/A" if si := p.statsInfo(); si != nil { estRows = strconv.FormatFloat(si.RowCount, 'f', 2, 64) } - explainID := p.ExplainID().String() - row := []string{texttree.PrettyIdentifier(explainID+driverSide, indent, isLastChild), estRows, taskType, operatorInfo} + + var accessObject, operatorInfo string + if plan, ok := p.(dataAccesser); ok { + accessObject = plan.AccessObject() + operatorInfo = plan.OperatorInfo(false) + } else { + operatorInfo = p.ExplainInfo() + } + + var row []string if e.Analyze { runtimeStatsColl := e.ctx.GetSessionVars().StmtCtx.RuntimeStatsColl - // There maybe some mock information for cop task to let runtimeStatsColl.Exists(p.ExplainID()) is true. - // So check copTaskExecDetail first and print the real cop task information if it's not empty. - var analyzeInfo string + explainID := p.ExplainID().String() + var actRows, analyzeInfo string - var actRows int64 + // There maybe some mock information for cop task to let runtimeStatsColl.Exists(p.ExplainID()) is true. + // So check copTaskEkxecDetail first and print the real cop task information if it's not empty. if runtimeStatsColl.ExistsCopStats(explainID) { copstats := runtimeStatsColl.GetCopStats(explainID) analyzeInfo = copstats.String() - actRows = copstats.GetActRows() + actRows = fmt.Sprint(copstats.GetActRows()) } else if runtimeStatsColl.ExistsRootStats(explainID) { rootstats := runtimeStatsColl.GetRootStats(explainID) analyzeInfo = rootstats.String() - actRows = rootstats.GetActRows() + actRows = fmt.Sprint(rootstats.GetActRows()) } else { - analyzeInfo = "time:0ns, loops:0, rows:0" + analyzeInfo = "time:0ns, loops:0" } switch p.(type) { case *PhysicalTableReader, *PhysicalIndexReader, *PhysicalIndexLookUpReader: @@ -917,26 +937,22 @@ func (e *Explain) prepareOperatorInfo(p Plan, taskType, driverSide, indent strin analyzeInfo += ", " + s.String() } } - row = append(row, analyzeInfo) + memoryInfo := "N/A" memTracker := e.ctx.GetSessionVars().StmtCtx.MemTracker.SearchTracker(p.ExplainID().String()) if memTracker != nil { - row = append(row, memTracker.BytesToString(memTracker.MaxConsumed())) - } else { - row = append(row, "N/A") + memoryInfo = memTracker.BytesToString(memTracker.MaxConsumed()) } + diskInfo := "N/A" diskTracker := e.ctx.GetSessionVars().StmtCtx.DiskTracker.SearchTracker(p.ExplainID().String()) if diskTracker != nil { - row = append(row, diskTracker.BytesToString(diskTracker.MaxConsumed())) - } else { - row = append(row, "N/A") + diskInfo = diskTracker.BytesToString(diskTracker.MaxConsumed()) } - // Put 'actRows'(actual rows) next by 'estRows'(estimate rows). - tmp := append([]string{}, row[2:]...) - row = append(row[:2], fmt.Sprint(actRows)) - row = append(row, tmp...) + row = []string{id, estRows, actRows, taskType, accessObject, analyzeInfo, operatorInfo, memoryInfo, diskInfo} + } else { + row = []string{id, estRows, taskType, accessObject, operatorInfo} } e.Rows = append(e.Rows, row) } diff --git a/planner/core/exhaust_physical_plans.go b/planner/core/exhaust_physical_plans.go index 6cd9b397bb221..0c7e938969f23 100644 --- a/planner/core/exhaust_physical_plans.go +++ b/planner/core/exhaust_physical_plans.go @@ -289,6 +289,10 @@ func (p *PhysicalMergeJoin) initCompareFuncs() { // TODO: use hint and remove this variable var ForceUseOuterBuild4Test = false +// ForcedHashLeftJoin4Test is a test option to force using HashLeftJoin +// TODO: use hint and remove this variable +var ForcedHashLeftJoin4Test = false + func (p *LogicalJoin) getHashJoins(prop *property.PhysicalProperty) []PhysicalPlan { if !prop.IsEmpty() { // hash join doesn't promise any orders return nil @@ -312,8 +316,12 @@ func (p *LogicalJoin) getHashJoins(prop *property.PhysicalProperty) []PhysicalPl joins = append(joins, p.getHashJoin(prop, 0, true)) } case InnerJoin: - joins = append(joins, p.getHashJoin(prop, 1, false)) - joins = append(joins, p.getHashJoin(prop, 0, false)) + if ForcedHashLeftJoin4Test { + joins = append(joins, p.getHashJoin(prop, 1, false)) + } else { + joins = append(joins, p.getHashJoin(prop, 1, false)) + joins = append(joins, p.getHashJoin(prop, 0, false)) + } } return joins } @@ -1256,7 +1264,7 @@ func (ijHelper *indexJoinBuildHelper) buildTemplateRange(matchedKeyCnt int, eqAn // tryToGetIndexJoin will get index join by hints. If we can generate a valid index join by hint, the second return value // will be true, which means we force to choose this index join. Otherwise we will select a join algorithm with min-cost. -func (p *LogicalJoin) tryToGetIndexJoin(prop *property.PhysicalProperty) (indexJoins []PhysicalPlan, forced bool) { +func (p *LogicalJoin) tryToGetIndexJoin(prop *property.PhysicalProperty) (indexJoins []PhysicalPlan, canForced bool) { inljRightOuter := (p.preferJoinType & preferLeftAsINLJInner) > 0 inljLeftOuter := (p.preferJoinType & preferRightAsINLJInner) > 0 hasINLJHint := inljLeftOuter || inljRightOuter @@ -1271,10 +1279,29 @@ func (p *LogicalJoin) tryToGetIndexJoin(prop *property.PhysicalProperty) (indexJ forceLeftOuter := inljLeftOuter || inlhjLeftOuter || inlmjLeftOuter forceRightOuter := inljRightOuter || inlhjRightOuter || inlmjRightOuter + needForced := forceLeftOuter || forceRightOuter defer func() { // refine error message - if !forced && (hasINLJHint || hasINLHJHint || hasINLMJHint) { + if !canForced && needForced { + if hasINLMJHint && len(indexJoins) > 0 && len(prop.Items) > 0 { + containIdxMergeJoin := false + for _, idxJoin := range indexJoins { + if _, ok := idxJoin.(*PhysicalIndexMergeJoin); ok { + containIdxMergeJoin = true + break + } + } + // 1. IndexMergeJoin requires stricter conditions than Index(Hash)Join when the output order is needed. + // 2. IndexMergeJoin requires the same conditions with Index(Hash)Join when the output is unordered. + // 3. If ordered-Index(Hash)Join can be chosen but ordered-IndexMergeJoin can not be chosen, we can build a plan with an enforced sort on IndexMergeJoin. + // 4. Thus we can give up the plans here if IndexMergeJoin is nil when `hasINLMJHint` is true. Because we can make sure that an IndexMeregJoin with enforced sort will be built. + if !containIdxMergeJoin { + canForced = true + indexJoins = nil + return + } + } // Construct warning message prefix. var errMsg string switch { @@ -1377,8 +1404,8 @@ func (p *LogicalJoin) tryToGetIndexJoin(prop *property.PhysicalProperty) (indexJ canForceLeft := len(forcedLeftOuterJoins) != 0 && forceLeftOuter canForceRight := len(forcedRightOuterJoins) != 0 && forceRightOuter - forced = canForceLeft || canForceRight - if forced { + canForced = canForceLeft || canForceRight + if canForced { return append(forcedLeftOuterJoins, forcedRightOuterJoins...), true } return append(allLeftOuterJoins, allRightOuterJoins...), false diff --git a/planner/core/explain.go b/planner/core/explain.go index 5ee0edfdb6f9a..126817e8db9ad 100644 --- a/planner/core/explain.go +++ b/planner/core/explain.go @@ -26,6 +26,18 @@ import ( "github.com/pingcap/tidb/util/stringutil" ) +// A plan is dataAccesser means it can access underlying data. +// Include `PhysicalTableScan`, `PhysicalIndexScan`, `PointGetPlan`, `BatchPointScan` and `PhysicalMemTable`. +// ExplainInfo = AccessObject + OperatorInfo +type dataAccesser interface { + + // AccessObject return plan's `table`, `partition` and `index`. + AccessObject() string + + // OperatorInfo return other operator information to be explained. + OperatorInfo(normalized bool) string +} + // ExplainInfo implements Plan interface. func (p *PhysicalLock) ExplainInfo() string { return p.Lock.String() @@ -43,10 +55,16 @@ func (p *PhysicalIndexScan) ExplainID() fmt.Stringer { // ExplainInfo implements Plan interface. func (p *PhysicalIndexScan) ExplainInfo() string { - return p.explainInfo(false) + return p.AccessObject() + ", " + p.OperatorInfo(false) +} + +// ExplainNormalizedInfo implements Plan interface. +func (p *PhysicalIndexScan) ExplainNormalizedInfo() string { + return p.AccessObject() + ", " + p.OperatorInfo(true) } -func (p *PhysicalIndexScan) explainInfo(normalized bool) string { +// AccessObject implements dataAccesser interface. +func (p *PhysicalIndexScan) AccessObject() string { buffer := bytes.NewBufferString("") tblName := p.Table.Name.O if p.TableAsName != nil && p.TableAsName.O != "" { @@ -60,43 +78,47 @@ func (p *PhysicalIndexScan) explainInfo(normalized bool) string { } } if len(p.Index.Columns) > 0 { - buffer.WriteString(", index:") + buffer.WriteString(", index:" + p.Index.Name.O + "(") for i, idxCol := range p.Index.Columns { buffer.WriteString(idxCol.Name.O) if i+1 < len(p.Index.Columns) { buffer.WriteString(", ") } } + buffer.WriteString(")") } + return buffer.String() +} +// OperatorInfo implements dataAccesser interface. +func (p *PhysicalIndexScan) OperatorInfo(normalized bool) string { + buffer := bytes.NewBufferString("") if len(p.rangeInfo) > 0 { - fmt.Fprintf(buffer, ", range: decided by %v", p.rangeInfo) + fmt.Fprintf(buffer, "range: decided by %v, ", p.rangeInfo) } else if p.haveCorCol() { if normalized { - fmt.Fprintf(buffer, ", range: decided by %s", expression.SortedExplainNormalizedExpressionList(p.AccessCondition)) + fmt.Fprintf(buffer, "range: decided by %s, ", expression.SortedExplainNormalizedExpressionList(p.AccessCondition)) } else { - fmt.Fprintf(buffer, ", range: decided by %v", p.AccessCondition) + fmt.Fprintf(buffer, "range: decided by %v, ", p.AccessCondition) } } else if len(p.Ranges) > 0 { if normalized { - fmt.Fprint(buffer, ", range:[?,?]") + fmt.Fprint(buffer, "range:[?,?], ") } else if !p.isFullScan() { - fmt.Fprint(buffer, ", range:") - for i, idxRange := range p.Ranges { - fmt.Fprint(buffer, idxRange.String()) - if i+1 < len(p.Ranges) { - fmt.Fprint(buffer, ", ") - } + fmt.Fprint(buffer, "range:") + for _, idxRange := range p.Ranges { + fmt.Fprint(buffer, idxRange.String()+", ") } } } - fmt.Fprintf(buffer, ", keep order:%v", p.KeepOrder) + fmt.Fprintf(buffer, "keep order:%v, ", p.KeepOrder) if p.Desc { - buffer.WriteString(", desc") + buffer.WriteString("desc, ") } if p.stats.StatsVersion == statistics.PseudoVersion && !normalized { - buffer.WriteString(", stats:pseudo") + buffer.WriteString("stats:pseudo, ") } + buffer.Truncate(buffer.Len() - 2) return buffer.String() } @@ -121,11 +143,6 @@ func (p *PhysicalIndexScan) isFullScan() bool { return true } -// ExplainNormalizedInfo implements Plan interface. -func (p *PhysicalIndexScan) ExplainNormalizedInfo() string { - return p.explainInfo(true) -} - // ExplainID overrides the ExplainID in order to match different range. func (p *PhysicalTableScan) ExplainID() fmt.Stringer { return stringutil.MemoizeStr(func() string { @@ -140,15 +157,16 @@ func (p *PhysicalTableScan) ExplainID() fmt.Stringer { // ExplainInfo implements Plan interface. func (p *PhysicalTableScan) ExplainInfo() string { - return p.explainInfo(false) + return p.AccessObject() + ", " + p.OperatorInfo(false) } // ExplainNormalizedInfo implements Plan interface. func (p *PhysicalTableScan) ExplainNormalizedInfo() string { - return p.explainInfo(true) + return p.AccessObject() + ", " + p.OperatorInfo(true) } -func (p *PhysicalTableScan) explainInfo(normalized bool) string { +// AccessObject implements dataAccesser interface. +func (p *PhysicalTableScan) AccessObject() string { buffer := bytes.NewBufferString("") tblName := p.Table.Name.O if p.TableAsName != nil && p.TableAsName.O != "" { @@ -161,37 +179,41 @@ func (p *PhysicalTableScan) explainInfo(normalized bool) string { fmt.Fprintf(buffer, ", partition:%s", partitionName) } } + return buffer.String() +} + +// OperatorInfo implements dataAccesser interface. +func (p *PhysicalTableScan) OperatorInfo(normalized bool) string { + buffer := bytes.NewBufferString("") if p.pkCol != nil { - fmt.Fprintf(buffer, ", pk col:%s", p.pkCol.ExplainInfo()) + fmt.Fprintf(buffer, "pk col:%s, ", p.pkCol.ExplainInfo()) } if len(p.rangeDecidedBy) > 0 { - fmt.Fprintf(buffer, ", range: decided by %v", p.rangeDecidedBy) + fmt.Fprintf(buffer, "range: decided by %v, ", p.rangeDecidedBy) } else if p.haveCorCol() { if normalized { - fmt.Fprintf(buffer, ", range: decided by %s", expression.SortedExplainNormalizedExpressionList(p.AccessCondition)) + fmt.Fprintf(buffer, "range: decided by %s, ", expression.SortedExplainNormalizedExpressionList(p.AccessCondition)) } else { - fmt.Fprintf(buffer, ", range: decided by %v", p.AccessCondition) + fmt.Fprintf(buffer, "range: decided by %v, ", p.AccessCondition) } } else if len(p.Ranges) > 0 { if normalized { - fmt.Fprint(buffer, ", range:[?,?]") + fmt.Fprint(buffer, "range:[?,?], ") } else if !p.isFullScan() { - fmt.Fprint(buffer, ", range:") - for i, idxRange := range p.Ranges { - fmt.Fprint(buffer, idxRange.String()) - if i+1 < len(p.Ranges) { - fmt.Fprint(buffer, ", ") - } + fmt.Fprint(buffer, "range:") + for _, idxRange := range p.Ranges { + fmt.Fprint(buffer, idxRange.String()+", ") } } } - fmt.Fprintf(buffer, ", keep order:%v", p.KeepOrder) + fmt.Fprintf(buffer, "keep order:%v, ", p.KeepOrder) if p.Desc { - buffer.WriteString(", desc") + buffer.WriteString("desc, ") } if p.stats.StatsVersion == statistics.PseudoVersion && !normalized { - buffer.WriteString(", stats:pseudo") + buffer.WriteString("stats:pseudo, ") } + buffer.Truncate(buffer.Len() - 2) return buffer.String() } @@ -744,12 +766,22 @@ const MetricTableTimeFormat = "2006-01-02 15:04:05.999" // ExplainInfo implements Plan interface. func (p *PhysicalMemTable) ExplainInfo() string { - explain := "table:" + p.Table.Name.O + accessObject, operatorInfo := p.AccessObject(), p.OperatorInfo(false) + if len(operatorInfo) == 0 { + return accessObject + } + return accessObject + ", " + operatorInfo +} + +// AccessObject implements dataAccesser interface. +func (p *PhysicalMemTable) AccessObject() string { + return "table:" + p.Table.Name.O +} + +// OperatorInfo implements dataAccesser interface. +func (p *PhysicalMemTable) OperatorInfo(_ bool) string { if p.Extractor != nil { - info := p.Extractor.explainInfo(p) - if len(info) > 0 { - return explain + ", " + info - } + return p.Extractor.explainInfo(p) } - return explain + return "" } diff --git a/planner/core/expression_rewriter.go b/planner/core/expression_rewriter.go index d7c52695322a5..3cb7fed0439c9 100644 --- a/planner/core/expression_rewriter.go +++ b/planner/core/expression_rewriter.go @@ -999,8 +999,7 @@ func (er *expressionRewriter) Leave(originInNode ast.Node) (retNode ast.Node, ok if collate.NewCollationEnabled() { var collInfo *charset.Collation // TODO(bb7133): use charset.ValidCharsetAndCollation when its bug is fixed. - if collInfo, er.err = charset.GetCollationByName(v.Collate); er.err != nil { - er.err = charset.ErrUnknownCollation.GenWithStackByArgs(v.Collate) + if collInfo, er.err = collate.GetCollationByName(v.Collate); er.err != nil { break } chs := arg.GetType().Charset diff --git a/planner/core/find_best_task.go b/planner/core/find_best_task.go index c7da591ce219b..f58fc518d2dd8 100644 --- a/planner/core/find_best_task.go +++ b/planner/core/find_best_task.go @@ -485,15 +485,7 @@ func (ds *DataSource) findBestTask(prop *property.PhysicalProperty) (t task, err break } } - // TODO: we ignore generate column now, because there are some errors happened when point get on generate columns - hasGenerateCol := false - for _, colInfo := range ds.Columns { - if colInfo.IsGenerated() { - hasGenerateCol = true - break - } - } - if allRangeIsPoint && !hasGenerateCol { + if allRangeIsPoint { var pointGetTask task if len(path.Ranges) == 1 { pointGetTask = ds.convertToPointGet(prop, candidate) @@ -741,7 +733,7 @@ func (ds *DataSource) convertToIndexScan(prop *property.PhysicalProperty, candid physicalTableID: ds.physicalTableID, }.Init(ds.ctx, is.blockOffset) ts.SetSchema(ds.schema.Clone()) - ts.ExpandVirtualColumn() + ts.Columns = ExpandVirtualColumn(ts.Columns, ts.schema, ts.Table.Columns) cop.tablePlan = ts } cop.cst = cost @@ -1128,6 +1120,7 @@ func (ds *DataSource) convertToPointGet(prop *property.PhysicalProperty, candida TblInfo: ds.TableInfo(), outputNames: ds.OutputNames(), LockWaitTime: ds.ctx.GetSessionVars().LockWaitTimeout, + Columns: ds.Columns, }.Init(ds.ctx, ds.stats.ScaleByExpectCnt(1.0), ds.blockOffset) var partitionInfo *model.PartitionDefinition if ds.isPartition { @@ -1198,6 +1191,7 @@ func (ds *DataSource) convertToBatchPointGet(prop *property.PhysicalProperty, ca ctx: ds.ctx, TblInfo: ds.TableInfo(), KeepOrder: !prop.IsEmpty(), + Columns: ds.Columns, }.Init(ds.ctx, ds.stats.ScaleByExpectCnt(float64(len(candidate.path.Ranges))), ds.schema.Clone(), ds.names, ds.blockOffset) if batchPointGetPlan.KeepOrder { batchPointGetPlan.Desc = prop.Items[0].Desc diff --git a/planner/core/initialize.go b/planner/core/initialize.go index 7892aab055921..c2d99df3897e7 100644 --- a/planner/core/initialize.go +++ b/planner/core/initialize.go @@ -304,10 +304,7 @@ func (p PhysicalMemTable) Init(ctx sessionctx.Context, stats *property.StatsInfo // Init initializes PhysicalHashJoin. func (p PhysicalHashJoin) Init(ctx sessionctx.Context, stats *property.StatsInfo, offset int, props ...*property.PhysicalProperty) *PhysicalHashJoin { - tp := plancodec.TypeHashRightJoin - if p.InnerChildIdx == 1 { - tp = plancodec.TypeHashLeftJoin - } + tp := plancodec.TypeHashJoin p.basePhysicalPlan = newBasePhysicalPlan(ctx, tp, &p, offset) p.childrenReqProps = props p.stats = stats @@ -451,6 +448,7 @@ func (p BatchPointGetPlan) Init(ctx sessionctx.Context, stats *property.StatsInf p.schema = schema p.names = names p.stats = stats + p.Columns = ExpandVirtualColumn(p.Columns, p.schema, p.TblInfo.Columns) return &p } diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 85da778e210e6..9561afe216226 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -27,6 +27,7 @@ import ( ) var _ = Suite(&testIntegrationSuite{}) +var _ = SerialSuites(&testIntegrationSerialSuite{}) type testIntegrationSuite struct { testData testutil.TestData @@ -56,6 +57,34 @@ func (s *testIntegrationSuite) TearDownTest(c *C) { c.Assert(err, IsNil) } +type testIntegrationSerialSuite struct { + testData testutil.TestData + store kv.Storage + dom *domain.Domain +} + +func (s *testIntegrationSerialSuite) SetUpSuite(c *C) { + var err error + s.testData, err = testutil.LoadTestSuiteData("testdata", "integration_suite") + c.Assert(err, IsNil) +} + +func (s *testIntegrationSerialSuite) TearDownSuite(c *C) { + c.Assert(s.testData.GenerateOutputIfNeeded(), IsNil) +} + +func (s *testIntegrationSerialSuite) SetUpTest(c *C) { + var err error + s.store, s.dom, err = newStoreWithBootstrap() + c.Assert(err, IsNil) +} + +func (s *testIntegrationSerialSuite) TearDownTest(c *C) { + s.dom.Close() + err := s.store.Close() + c.Assert(err, IsNil) +} + func (s *testIntegrationSuite) TestShowSubquery(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") @@ -245,7 +274,7 @@ func (s *testIntegrationSuite) TestSimplifyOuterJoinWithCast(c *C) { } } -func (s *testIntegrationSuite) TestNoneAccessPathsFoundByIsolationRead(c *C) { +func (s *testIntegrationSerialSuite) TestNoneAccessPathsFoundByIsolationRead(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") @@ -259,8 +288,8 @@ func (s *testIntegrationSuite) TestNoneAccessPathsFoundByIsolationRead(c *C) { // Don't filter mysql.SystemDB by isolation read. tk.MustQuery("explain select * from mysql.stats_meta").Check(testkit.Rows( - "TableReader_5 10000.00 root data:TableFullScan_4", - "└─TableFullScan_4 10000.00 cop[tikv] table:stats_meta, keep order:false, stats:pseudo")) + "TableReader_5 10000.00 root data:TableFullScan_4", + "└─TableFullScan_4 10000.00 cop[tikv] table:stats_meta keep order:false, stats:pseudo")) _, err = tk.Exec("select * from t") c.Assert(err, NotNil) @@ -274,7 +303,7 @@ func (s *testIntegrationSuite) TestNoneAccessPathsFoundByIsolationRead(c *C) { c.Assert(err.Error(), Equals, "[planner:1815]Internal : Can not find access path matching 'tidb_isolation_read_engines'(value: 'tikv,tiflash') and tidb-server config isolation-read(engines: '[tiflash]'). Available values are 'tikv'.") } -func (s *testIntegrationSuite) TestSelPushDownTiFlash(c *C) { +func (s *testIntegrationSerialSuite) TestSelPushDownTiFlash(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("drop table if exists t") @@ -298,20 +327,20 @@ func (s *testIntegrationSuite) TestSelPushDownTiFlash(c *C) { // All conditions should push tiflash. tk.MustQuery(`explain select * from t where t.a > 1 and t.b = "flash" or t.a + 3 * t.a = 5`).Check(testkit.Rows( - "TableReader_7 8000.00 root data:Selection_6", - "└─Selection_6 8000.00 cop[tiflash] or(and(gt(test.t.a, 1), eq(test.t.b, \"flash\")), eq(plus(test.t.a, mul(3, test.t.a)), 5))", - " └─TableFullScan_5 10000.00 cop[tiflash] table:t, keep order:false, stats:pseudo", + "TableReader_7 8000.00 root data:Selection_6", + "└─Selection_6 8000.00 cop[tiflash] or(and(gt(test.t.a, 1), eq(test.t.b, \"flash\")), eq(plus(test.t.a, mul(3, test.t.a)), 5))", + " └─TableFullScan_5 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo", )) // Part of conditions should push tiflash. tk.MustQuery(`explain select * from t where cast(t.a as float) + 3 = 5.1`).Check(testkit.Rows( - "Selection_7 10000.00 root eq(plus(cast(test.t.a), 3), 5.1)", - "└─TableReader_6 10000.00 root data:TableFullScan_5", - " └─TableFullScan_5 10000.00 cop[tiflash] table:t, keep order:false, stats:pseudo", + "Selection_7 10000.00 root eq(plus(cast(test.t.a), 3), 5.1)", + "└─TableReader_6 10000.00 root data:TableFullScan_5", + " └─TableFullScan_5 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo", )) } -func (s *testIntegrationSuite) TestIssue15110(c *C) { +func (s *testIntegrationSerialSuite) TestIssue15110(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("drop table if exists crm_rd_150m") @@ -346,7 +375,7 @@ func (s *testIntegrationSuite) TestIssue15110(c *C) { tk.MustExec("explain SELECT count(*) FROM crm_rd_150m dataset_48 WHERE (CASE WHEN (month(dataset_48.customer_first_date)) <= 30 THEN '新客' ELSE NULL END) IS NOT NULL;") } -func (s *testIntegrationSuite) TestReadFromStorageHint(c *C) { +func (s *testIntegrationSerialSuite) TestReadFromStorageHint(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") @@ -386,7 +415,7 @@ func (s *testIntegrationSuite) TestReadFromStorageHint(c *C) { } } -func (s *testIntegrationSuite) TestReadFromStorageHintAndIsolationRead(c *C) { +func (s *testIntegrationSerialSuite) TestReadFromStorageHintAndIsolationRead(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") @@ -595,3 +624,17 @@ func (s *testIntegrationSuite) TestSubqueryWithTopN(c *C) { tk.MustQuery(tt).Check(testkit.Rows(output[i].Plan...)) } } + +func (s *testIntegrationSuite) TestIssue15546(c *C) { + tk := testkit.NewTestKit(c, s.store) + + tk.MustExec("use test") + tk.MustExec("drop table if exists t, pt, vt") + tk.MustExec("create table t(a int, b int)") + tk.MustExec("insert into t values(1, 1)") + tk.MustExec("create table pt(a int primary key, b int) partition by range(a) (" + + "PARTITION `p0` VALUES LESS THAN (10), PARTITION `p1` VALUES LESS THAN (20), PARTITION `p2` VALUES LESS THAN (30))") + tk.MustExec("insert into pt values(1, 1), (11, 11), (21, 21)") + tk.MustExec("create definer='root'@'localhost' view vt(a, b) as select a, b from t") + tk.MustQuery("select * from pt, vt where pt.a = vt.a").Check(testkit.Rows("1 1 1 1")) +} diff --git a/planner/core/logical_plan_builder.go b/planner/core/logical_plan_builder.go index 5138d35455fdf..5f56c5117d9de 100644 --- a/planner/core/logical_plan_builder.go +++ b/planner/core/logical_plan_builder.go @@ -3166,7 +3166,7 @@ func (b *PlanBuilder) buildUpdate(ctx context.Context, update *ast.UpdateStmt) ( return nil, err } } - if !b.ctx.GetSessionVars().IsAutocommit() || b.ctx.GetSessionVars().InTxn() { + if b.ctx.GetSessionVars().TxnCtx.IsPessimistic { if !update.MultipleTable { p = b.buildSelectLock(p, ast.SelectLockForUpdate) } @@ -3226,9 +3226,42 @@ func (b *PlanBuilder) buildUpdate(ctx context.Context, update *ast.UpdateStmt) ( tblID2table[id], _ = b.is.TableByID(id) } updt.TblColPosInfos, err = buildColumns2Handle(updt.OutputNames(), tblID2Handle, tblID2table, true) + if err == nil { + err = checkUpdateList(b.ctx, tblID2table, updt) + } return updt, err } +// GetUpdateColumns gets the columns of updated lists. +func GetUpdateColumns(ctx sessionctx.Context, orderedList []*expression.Assignment, schemaLen int) ([]bool, error) { + assignFlag := make([]bool, schemaLen) + for _, v := range orderedList { + if !ctx.GetSessionVars().AllowWriteRowID && v.Col.ID == model.ExtraHandleID { + return nil, errors.Errorf("insert, update and replace statements for _tidb_rowid are not supported.") + } + idx := v.Col.Index + assignFlag[idx] = true + } + return assignFlag, nil +} + +func checkUpdateList(ctx sessionctx.Context, tblID2table map[int64]table.Table, updt *Update) error { + assignFlags, err := GetUpdateColumns(ctx, updt.OrderedList, updt.SelectPlan.Schema().Len()) + if err != nil { + return err + } + for _, content := range updt.TblColPosInfos { + tbl := tblID2table[content.TblID] + flags := assignFlags[content.Start:content.End] + for i, col := range tbl.WritableCols() { + if flags[i] && col.State != model.StatePublic { + return ErrUnknownColumn.GenWithStackByArgs(col.Name, clauseMsg[fieldList]) + } + } + } + return nil +} + func (b *PlanBuilder) buildUpdateLists( ctx context.Context, tableList []*ast.TableName, @@ -3406,7 +3439,7 @@ func (b *PlanBuilder) buildDelete(ctx context.Context, delete *ast.DeleteStmt) ( return nil, err } } - if !b.ctx.GetSessionVars().IsAutocommit() || b.ctx.GetSessionVars().InTxn() { + if b.ctx.GetSessionVars().TxnCtx.IsPessimistic { if !delete.IsMultiTable { p = b.buildSelectLock(p, ast.SelectLockForUpdate) } diff --git a/planner/core/memtable_predicate_extractor.go b/planner/core/memtable_predicate_extractor.go index 638f82f80bca2..b4691b1c185be 100644 --- a/planner/core/memtable_predicate_extractor.go +++ b/planner/core/memtable_predicate_extractor.go @@ -400,7 +400,7 @@ func (helper extractHelper) extractTimeRange( timeType := types.NewFieldType(mysql.TypeDatetime) timeType.Decimal = 3 timeDatum, err := datums[0].ConvertTo(ctx.GetSessionVars().StmtCtx, timeType) - if err != nil { + if err != nil || timeDatum.Kind() == types.KindNull { remained = append(remained, expr) continue } @@ -606,7 +606,56 @@ func (e *ClusterLogTableExtractor) Extract( } func (e *ClusterLogTableExtractor) explainInfo(p *PhysicalMemTable) string { - return "" + if e.SkipRequest { + return "skip_request: true" + } + r := new(bytes.Buffer) + st, et := e.GetTimeRange(false) + if st > 0 { + st := time.Unix(0, st*1e6) + r.WriteString(fmt.Sprintf("start_time:%v, ", st.In(p.ctx.GetSessionVars().StmtCtx.TimeZone).Format(MetricTableTimeFormat))) + } + if et < math.MaxInt64 { + et := time.Unix(0, et*1e6) + r.WriteString(fmt.Sprintf("end_time:%v, ", et.In(p.ctx.GetSessionVars().StmtCtx.TimeZone).Format(MetricTableTimeFormat))) + } + if len(e.NodeTypes) > 0 { + r.WriteString(fmt.Sprintf("node_types:[%s], ", extractStringFromStringSet(e.NodeTypes))) + } + if len(e.Instances) > 0 { + r.WriteString(fmt.Sprintf("instances:[%s], ", extractStringFromStringSet(e.Instances))) + } + if len(e.LogLevels) > 0 { + r.WriteString(fmt.Sprintf("log_levels:[%s], ", extractStringFromStringSet(e.LogLevels))) + } + + // remove the last ", " in the message info + s := r.String() + if len(s) > 2 { + return s[:len(s)-2] + } + return s +} + +// GetTimeRange extract startTime and endTime +func (e *ClusterLogTableExtractor) GetTimeRange(isFailpointTestModeSkipCheck bool) (int64, int64) { + startTime := e.StartTime + endTime := e.EndTime + if endTime == 0 { + endTime = math.MaxInt64 + } + if !isFailpointTestModeSkipCheck { + // Just search the recent half an hour logs if the user doesn't specify the start time + const defaultSearchLogDuration = 30 * time.Minute / time.Millisecond + if startTime == 0 { + if endTime == math.MaxInt64 { + startTime = time.Now().UnixNano()/int64(time.Millisecond) - int64(defaultSearchLogDuration) + } else { + startTime = endTime - int64(defaultSearchLogDuration) + } + } + } + return startTime, endTime } // MetricTableExtractor is used to extract some predicates of metrics_schema tables. diff --git a/planner/core/memtable_predicate_extractor_test.go b/planner/core/memtable_predicate_extractor_test.go index 119536d8a2112..8cf7e1d2fb858 100644 --- a/planner/core/memtable_predicate_extractor_test.go +++ b/planner/core/memtable_predicate_extractor_test.go @@ -270,6 +270,12 @@ func (s *extractorSuite) TestClusterLogTableExtractor(c *C) { nodeTypes: nil, instances: nil, }, + { + // Test for invalid time. + sql: "select * from information_schema.cluster_log where time='2019-10-10 10::10'", + nodeTypes: set.NewStringSet(), + instances: set.NewStringSet(), + }, { sql: "select * from information_schema.cluster_log where type='tikv'", nodeTypes: set.NewStringSet("tikv"), diff --git a/planner/core/partition_pruning_test.go b/planner/core/partition_pruning_test.go index c37fbd70201b8..0e4568ffea43c 100644 --- a/planner/core/partition_pruning_test.go +++ b/planner/core/partition_pruning_test.go @@ -44,13 +44,15 @@ func (s *testPartitionPruningSuite) TestCanBePrune(c *C) { "create table t (d datetime not null)", "to_days(d)", ) - lessThan := lessThanData{data: []int64{733108, 733132}, maxvalue: false} + lessThan := lessThanDataInt{data: []int64{733108, 733132}, maxvalue: false} + prunner := &rangePruner{lessThan, tc.col, tc.fn} + queryExpr := tc.expr("d < '2000-03-08 00:00:00'") - result := partitionRangeForCNFExpr(tc.sctx, queryExpr, lessThan, tc.col, tc.fn, fullRange(len(lessThan.data))) + result := partitionRangeForCNFExpr(tc.sctx, queryExpr, prunner, fullRange(len(lessThan.data))) c.Assert(equalPartitionRangeOR(result, partitionRangeOR{{0, 1}}), IsTrue) queryExpr = tc.expr("d > '2018-03-08 00:00:00'") - result = partitionRangeForCNFExpr(tc.sctx, queryExpr, lessThan, tc.col, tc.fn, fullRange(len(lessThan.data))) + result = partitionRangeForCNFExpr(tc.sctx, queryExpr, prunner, fullRange(len(lessThan.data))) c.Assert(equalPartitionRangeOR(result, partitionRangeOR{}), IsTrue) // For the following case: @@ -68,13 +70,15 @@ func (s *testPartitionPruningSuite) TestCanBePrune(c *C) { "create table t (report_updated timestamp)", "unix_timestamp(report_updated)", ) - lessThan = lessThanData{data: []int64{1199145600, 1207008000, 1262304000, 0}, maxvalue: true} + lessThan = lessThanDataInt{data: []int64{1199145600, 1207008000, 1262304000, 0}, maxvalue: true} + prunner = &rangePruner{lessThan, tc.col, tc.fn} + queryExpr = tc.expr("report_updated > '2008-05-01 00:00:00'") - result = partitionRangeForCNFExpr(tc.sctx, queryExpr, lessThan, tc.col, tc.fn, fullRange(len(lessThan.data))) + result = partitionRangeForCNFExpr(tc.sctx, queryExpr, prunner, fullRange(len(lessThan.data))) c.Assert(equalPartitionRangeOR(result, partitionRangeOR{{2, 4}}), IsTrue) queryExpr = tc.expr("report_updated > unix_timestamp('2008-05-01 00:00:00')") - partitionRangeForCNFExpr(tc.sctx, queryExpr, lessThan, tc.col, tc.fn, fullRange(len(lessThan.data))) + partitionRangeForCNFExpr(tc.sctx, queryExpr, prunner, fullRange(len(lessThan.data))) // TODO: Uncomment the check after fixing issue https://github.com/pingcap/tidb/issues/12028 // c.Assert(equalPartitionRangeOR(result, partitionRangeOR{{2, 4}}), IsTrue) // report_updated > unix_timestamp('2008-05-01 00:00:00') is converted to gt(t.t.report_updated, ) @@ -83,7 +87,7 @@ func (s *testPartitionPruningSuite) TestCanBePrune(c *C) { } func (s *testPartitionPruningSuite) TestPruneUseBinarySearch(c *C) { - lessThan := lessThanData{data: []int64{4, 7, 11, 14, 17, 0}, maxvalue: true} + lessThan := lessThanDataInt{data: []int64{4, 7, 11, 14, 17, 0}, maxvalue: true} cases := []struct { input dataForPrune result partitionRange @@ -126,7 +130,7 @@ type testCtx struct { schema *expression.Schema columns []*expression.Column names types.NameSlice - lessThan lessThanData + lessThan lessThanDataInt col *expression.Column fn *expression.ScalarFunction } @@ -165,7 +169,8 @@ func (s *testPartitionPruningSuite) TestPartitionRangeForExpr(c *C) { "create table t (a int)", "a", ) - lessThan := lessThanData{data: []int64{4, 7, 11, 14, 17, 0}, maxvalue: true} + lessThan := lessThanDataInt{data: []int64{4, 7, 11, 14, 17, 0}, maxvalue: true} + prunner := &rangePruner{lessThan, tc.columns[0], nil} cases := []struct { input string result partitionRangeOR @@ -188,7 +193,7 @@ func (s *testPartitionPruningSuite) TestPartitionRangeForExpr(c *C) { expr, err := expression.ParseSimpleExprsWithNames(tc.sctx, ca.input, tc.schema, tc.names) c.Assert(err, IsNil) result := fullRange(lessThan.length()) - result = partitionRangeForExpr(tc.sctx, expr[0], lessThan, tc.columns[0], nil, result) + result = partitionRangeForExpr(tc.sctx, expr[0], prunner, result) c.Assert(equalPartitionRangeOR(ca.result, result), IsTrue, Commentf("unexpected:", ca.input)) } } @@ -266,3 +271,92 @@ func (s *testPartitionPruningSuite) TestPartitionRangeOperation(c *C) { c.Assert(equalPartitionRangeOR(ca.result, result), IsTrue, Commentf("failed %d", i)) } } + +func (s *testPartitionPruningSuite) TestPartitionRangePrunner2VarChar(c *C) { + tc := prepareTestCtx(c, + "create table t (a varchar(32))", + "a", + ) + lessThanDataInt := []string{"'c'", "'f'", "'h'", "'l'", "'t'"} + lessThan := make([]expression.Expression, len(lessThanDataInt)+1) // +1 for maxvalue + for i, str := range lessThanDataInt { + tmp, err := expression.ParseSimpleExprsWithNames(tc.sctx, str, tc.schema, tc.names) + c.Assert(err, IsNil) + lessThan[i] = tmp[0] + } + + prunner := &rangeColumnPruner{lessThan, tc.columns[0], true} + cases := []struct { + input string + result partitionRangeOR + }{ + {"a > 'g'", partitionRangeOR{{2, 6}}}, + {"a < 'h'", partitionRangeOR{{0, 3}}}, + {"a >= 'm'", partitionRangeOR{{4, 6}}}, + {"a > 'm'", partitionRangeOR{{4, 6}}}, + {"a < 'f'", partitionRangeOR{{0, 2}}}, + {"a = 'c'", partitionRangeOR{{1, 2}}}, + {"a > 't'", partitionRangeOR{{5, 6}}}, + {"a > 'c' and a < 'q'", partitionRangeOR{{1, 5}}}, + {"a < 'l' or a >= 'w'", partitionRangeOR{{0, 4}, {5, 6}}}, + {"a is null", partitionRangeOR{{0, 1}}}, + {"'mm' > a", partitionRangeOR{{0, 5}}}, + {"'f' <= a", partitionRangeOR{{2, 6}}}, + {"'f' >= a", partitionRangeOR{{0, 3}}}, + } + + for _, ca := range cases { + expr, err := expression.ParseSimpleExprsWithNames(tc.sctx, ca.input, tc.schema, tc.names) + c.Assert(err, IsNil) + result := fullRange(len(lessThan)) + result = partitionRangeForExpr(tc.sctx, expr[0], prunner, result) + c.Assert(equalPartitionRangeOR(ca.result, result), IsTrue, Commentf("unexpected:", ca.input)) + } +} + +func (s *testPartitionPruningSuite) TestPartitionRangePrunner2Date(c *C) { + tc := prepareTestCtx(c, + "create table t (a date)", + "a", + ) + lessThanDataInt := []string{ + "'1999-06-01'", + "'2000-05-01'", + "'2008-04-01'", + "'2010-03-01'", + "'2016-02-01'", + "'2020-01-01'"} + lessThan := make([]expression.Expression, len(lessThanDataInt)) + for i, str := range lessThanDataInt { + tmp, err := expression.ParseSimpleExprsWithNames(tc.sctx, str, tc.schema, tc.names) + c.Assert(err, IsNil) + lessThan[i] = tmp[0] + } + + prunner := &rangeColumnPruner{lessThan, tc.columns[0], false} + cases := []struct { + input string + result partitionRangeOR + }{ + {"a < '1943-02-12'", partitionRangeOR{{0, 1}}}, + {"a >= '1969-02-13'", partitionRangeOR{{0, 6}}}, + {"a > '2003-03-13'", partitionRangeOR{{2, 6}}}, + {"a < '2006-02-03'", partitionRangeOR{{0, 3}}}, + {"a = '2007-07-07'", partitionRangeOR{{2, 3}}}, + {"a > '1949-10-10'", partitionRangeOR{{0, 6}}}, + {"a > '2016-02-01' and a < '2000-01-03'", partitionRangeOR{}}, + {"a < '1969-11-12' or a >= '2019-09-18'", partitionRangeOR{{0, 1}, {5, 6}}}, + {"a is null", partitionRangeOR{{0, 1}}}, + {"'2003-02-27' >= a", partitionRangeOR{{0, 3}}}, + {"'2014-10-24' < a", partitionRangeOR{{4, 6}}}, + {"'2003-03-30' > a", partitionRangeOR{{0, 3}}}, + } + + for _, ca := range cases { + expr, err := expression.ParseSimpleExprsWithNames(tc.sctx, ca.input, tc.schema, tc.names) + c.Assert(err, IsNil) + result := fullRange(len(lessThan)) + result = partitionRangeForExpr(tc.sctx, expr[0], prunner, result) + c.Assert(equalPartitionRangeOR(ca.result, result), IsTrue, Commentf("unexpected:", ca.input)) + } +} diff --git a/planner/core/physical_plan_test.go b/planner/core/physical_plan_test.go index 3d0488c1ac8e3..f15be5f8d12f5 100644 --- a/planner/core/physical_plan_test.go +++ b/planner/core/physical_plan_test.go @@ -1152,12 +1152,14 @@ func (s *testPlanSuite) TestIndexJoinHint(c *C) { ctx := context.Background() _, err = se.Execute(ctx, "use test") c.Assert(err, IsNil) - _, err = se.Execute(ctx, `drop table if exists test.t1, test.t2;`) + _, err = se.Execute(ctx, `drop table if exists test.t1, test.t2, test.t;`) c.Assert(err, IsNil) _, err = se.Execute(ctx, `create table test.t1(a bigint, b bigint, index idx_a(a), index idx_b(b));`) c.Assert(err, IsNil) _, err = se.Execute(ctx, `create table test.t2(a bigint, b bigint, index idx_a(a), index idx_b(b));`) c.Assert(err, IsNil) + _, err = se.Execute(ctx, "CREATE TABLE `t` ( `a` bigint(20) NOT NULL, `b` tinyint(1) DEFAULT NULL, `c` datetime DEFAULT NULL, `d` int(10) unsigned DEFAULT NULL, `e` varchar(20) DEFAULT NULL, `f` double DEFAULT NULL, `g` decimal(30,5) DEFAULT NULL, `h` float DEFAULT NULL, `i` date DEFAULT NULL, `j` timestamp NULL DEFAULT NULL, PRIMARY KEY (`a`), UNIQUE KEY `b` (`b`), KEY `c` (`c`,`d`,`e`), KEY `f` (`f`), KEY `g` (`g`,`h`), KEY `g_2` (`g`), UNIQUE KEY `g_3` (`g`), KEY `i` (`i`) );") + c.Assert(err, IsNil) var input []string var output []struct { SQL string diff --git a/planner/core/physical_plans.go b/planner/core/physical_plans.go index c77713f103b35..6a68a036ff5f2 100644 --- a/planner/core/physical_plans.go +++ b/planner/core/physical_plans.go @@ -260,20 +260,23 @@ func (ts *PhysicalTableScan) IsPartition() (bool, int64) { } // ExpandVirtualColumn expands the virtual column's dependent columns to ts's schema and column. -func (ts *PhysicalTableScan) ExpandVirtualColumn() { - for _, col := range ts.schema.Columns { +func ExpandVirtualColumn(columns []*model.ColumnInfo, schema *expression.Schema, + colsInfo []*model.ColumnInfo) []*model.ColumnInfo { + schemaColumns := schema.Columns + for _, col := range schemaColumns { if col.VirtualExpr == nil { continue } baseCols := expression.ExtractDependentColumns(col.VirtualExpr) for _, baseCol := range baseCols { - if !ts.schema.Contains(baseCol) { - ts.schema.Columns = append(ts.schema.Columns, baseCol) - ts.Columns = append(ts.Columns, FindColumnInfoByID(ts.Table.Columns, baseCol.ID)) + if !schema.Contains(baseCol) { + schema.Columns = append(schema.Columns, baseCol) + columns = append(columns, FindColumnInfoByID(colsInfo, baseCol.ID)) } } } + return columns } //SetIsChildOfIndexLookUp is to set the bool if is a child of IndexLookUpReader diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go index 79ce8f67d53f1..9d2a9c77a5b18 100644 --- a/planner/core/planbuilder.go +++ b/planner/core/planbuilder.go @@ -397,7 +397,7 @@ func NewPlanBuilder(sctx sessionctx.Context, is infoschema.InfoSchema, processor // Build builds the ast node to a Plan. func (b *PlanBuilder) Build(ctx context.Context, node ast.Node) (Plan, error) { - b.optFlag = flagPrunColumns + b.optFlag |= flagPrunColumns defer func() { // if there is something after flagPrunColumns, do flagPrunColumnsAgain if b.optFlag&flagPrunColumns > 0 && b.optFlag-flagPrunColumns > flagPrunColumns { @@ -1817,7 +1817,15 @@ func collectVisitInfoFromGrantStmt(sctx sessionctx.Context, vi []visitInfo, stmt } func (b *PlanBuilder) getDefaultValue(col *table.Column) (*expression.Constant, error) { - value, err := table.GetColDefaultValue(b.ctx, col.ToInfo()) + var ( + value types.Datum + err error + ) + if col.DefaultIsExpr && col.DefaultExpr != nil { + value, err = table.EvalColDefaultExpr(b.ctx, col.ToInfo(), col.DefaultExpr) + } else { + value, err = table.GetColDefaultValue(b.ctx, col.ToInfo()) + } if err != nil { return nil, err } diff --git a/planner/core/point_get_plan.go b/planner/core/point_get_plan.go index f0fd2a802318e..3c01372b193ec 100644 --- a/planner/core/point_get_plan.go +++ b/planner/core/point_get_plan.go @@ -59,6 +59,7 @@ type PointGetPlan struct { outputNames []*types.FieldName LockWaitTime int64 partitionColumnPos int + Columns []*model.ColumnInfo } type nameValuePair struct { @@ -71,6 +72,7 @@ type nameValuePair struct { func (p PointGetPlan) Init(ctx sessionctx.Context, stats *property.StatsInfo, offset int, props ...*property.PhysicalProperty) *PointGetPlan { p.basePlan = newBasePlan(ctx, plancodec.TypePointGet, offset) p.stats = stats + p.Columns = ExpandVirtualColumn(p.Columns, p.schema, p.TblInfo.Columns) return &p } @@ -90,49 +92,68 @@ func (p *PointGetPlan) ToPB(ctx sessionctx.Context) (*tipb.Executor, error) { return nil, nil } -// ExplainInfo returns operator information to be explained. +// ExplainInfo implements Plan interface. func (p *PointGetPlan) ExplainInfo() string { - return p.explainInfo(false) + accessObject, operatorInfo := p.AccessObject(), p.OperatorInfo(false) + if len(operatorInfo) == 0 { + return accessObject + } + return accessObject + ", " + operatorInfo +} + +// ExplainNormalizedInfo implements Plan interface. +func (p *PointGetPlan) ExplainNormalizedInfo() string { + accessObject, operatorInfo := p.AccessObject(), p.OperatorInfo(true) + if len(operatorInfo) == 0 { + return accessObject + } + return accessObject + ", " + operatorInfo } -// ExplainInfo returns operator information to be explained. -func (p *PointGetPlan) explainInfo(normalized bool) string { +// AccessObject implements dataAccesser interface. +func (p *PointGetPlan) AccessObject() string { buffer := bytes.NewBufferString("") tblName := p.TblInfo.Name.O fmt.Fprintf(buffer, "table:%s", tblName) + if p.PartitionInfo != nil { + fmt.Fprintf(buffer, ", partition:%s", p.PartitionInfo.Name.L) + } if p.IndexInfo != nil { - fmt.Fprintf(buffer, ", index:") - for i, col := range p.IndexInfo.Columns { - buffer.WriteString(col.Name.O) - if i < len(p.IndexInfo.Columns)-1 { - buffer.WriteString(" ") + buffer.WriteString(", index:" + p.IndexInfo.Name.O + "(") + for i, idxCol := range p.IndexInfo.Columns { + buffer.WriteString(idxCol.Name.O) + if i+1 < len(p.IndexInfo.Columns) { + buffer.WriteString(", ") } } - } else { + buffer.WriteString(")") + } + return buffer.String() +} + +// OperatorInfo implements dataAccesser interface. +func (p *PointGetPlan) OperatorInfo(normalized bool) string { + buffer := bytes.NewBufferString("") + if p.IndexInfo == nil { if normalized { - fmt.Fprintf(buffer, ", handle:?") + fmt.Fprintf(buffer, "handle:?, ") } else { if p.UnsignedHandle { - fmt.Fprintf(buffer, ", handle:%d", uint64(p.Handle)) + fmt.Fprintf(buffer, "handle:%d, ", uint64(p.Handle)) } else { - fmt.Fprintf(buffer, ", handle:%d", p.Handle) + fmt.Fprintf(buffer, "handle:%d, ", p.Handle) } } } if p.Lock { - fmt.Fprintf(buffer, ", lock") + fmt.Fprintf(buffer, "lock, ") } - if p.PartitionInfo != nil { - fmt.Fprintf(buffer, ", partition:%s", p.PartitionInfo.Name.L) + if buffer.Len() >= 2 { + buffer.Truncate(buffer.Len() - 2) } return buffer.String() } -// ExplainNormalizedInfo returns normalized operator information to be explained. -func (p *PointGetPlan) ExplainNormalizedInfo() string { - return p.explainInfo(true) -} - // GetChildReqProps gets the required property by child index. func (p *PointGetPlan) GetChildReqProps(idx int) *property.PhysicalProperty { return nil @@ -165,7 +186,7 @@ func (p *PointGetPlan) SetChild(i int, child PhysicalPlan) {} // ResolveIndices resolves the indices for columns. After doing this, the columns can evaluate the rows by their indices. func (p *PointGetPlan) ResolveIndices() error { - return nil + return resolveIndicesForVirtualColumn(p.schema.Columns, p.schema) } // OutputNames returns the outputting names of each column. @@ -212,6 +233,7 @@ type BatchPointGetPlan struct { Desc bool Lock bool LockWaitTime int64 + Columns []*model.ColumnInfo } // attach2Task makes the current physical plan as the father of task's physicalPlan and updates the cost of @@ -225,43 +247,55 @@ func (p *BatchPointGetPlan) ToPB(ctx sessionctx.Context) (*tipb.Executor, error) return nil, nil } -// ExplainInfo returns operator information to be explained. +// ExplainInfo implements Plan interface. func (p *BatchPointGetPlan) ExplainInfo() string { - return p.explainInfo(false) + return p.AccessObject() + ", " + p.OperatorInfo(false) } -func (p *BatchPointGetPlan) explainInfo(normalized bool) string { +// ExplainNormalizedInfo implements Plan interface. +func (p *BatchPointGetPlan) ExplainNormalizedInfo() string { + return p.AccessObject() + ", " + p.OperatorInfo(true) +} + +// AccessObject implements physicalScan interface. +func (p *BatchPointGetPlan) AccessObject() string { buffer := bytes.NewBufferString("") tblName := p.TblInfo.Name.O fmt.Fprintf(buffer, "table:%s", tblName) if p.IndexInfo != nil { - fmt.Fprintf(buffer, ", index:") - for i, col := range p.IndexInfo.Columns { - buffer.WriteString(col.Name.O) - if i < len(p.IndexInfo.Columns)-1 { - buffer.WriteString(" ") + buffer.WriteString(", index:" + p.IndexInfo.Name.O + "(") + for i, idxCol := range p.IndexInfo.Columns { + buffer.WriteString(idxCol.Name.O) + if i+1 < len(p.IndexInfo.Columns) { + buffer.WriteString(", ") } } - } else { + buffer.WriteString(")") + } + return buffer.String() +} + +// OperatorInfo implements dataAccesser interface. +func (p *BatchPointGetPlan) OperatorInfo(normalized bool) string { + buffer := bytes.NewBufferString("") + if p.IndexInfo == nil { if normalized { - fmt.Fprintf(buffer, ", handle:?") + fmt.Fprintf(buffer, "handle:?, ") } else { - fmt.Fprintf(buffer, ", handle:%v", p.Handles) + fmt.Fprintf(buffer, "handle:%v, ", p.Handles) } } - fmt.Fprintf(buffer, ", keep order:%v", p.KeepOrder) - fmt.Fprintf(buffer, ", desc:%v", p.Desc) + fmt.Fprintf(buffer, "keep order:%v, ", p.KeepOrder) + fmt.Fprintf(buffer, "desc:%v, ", p.Desc) if p.Lock { - fmt.Fprintf(buffer, ", lock") + fmt.Fprintf(buffer, "lock, ") + } + if buffer.Len() >= 2 { + buffer.Truncate(buffer.Len() - 2) } return buffer.String() } -// ExplainNormalizedInfo returns normalized operator information to be explained. -func (p *BatchPointGetPlan) ExplainNormalizedInfo() string { - return p.explainInfo(true) -} - // GetChildReqProps gets the required property by child index. func (p *BatchPointGetPlan) GetChildReqProps(idx int) *property.PhysicalProperty { return nil @@ -290,7 +324,7 @@ func (p *BatchPointGetPlan) SetChild(i int, child PhysicalPlan) {} // ResolveIndices resolves the indices for columns. After doing this, the columns can evaluate the rows by their indices. func (p *BatchPointGetPlan) ResolveIndices() error { - return nil + return resolveIndicesForVirtualColumn(p.schema.Columns, p.schema) } // OutputNames returns the outputting names of each column. diff --git a/planner/core/point_get_plan_test.go b/planner/core/point_get_plan_test.go index 3ab482367a1da..e47046033748a 100644 --- a/planner/core/point_get_plan_test.go +++ b/planner/core/point_get_plan_test.go @@ -77,21 +77,21 @@ func (s *testPointGetSuite) TestPointGetPlanCache(c *C) { tk.MustExec("create table t(a bigint unsigned primary key, b int, c int, key idx_bc(b,c))") tk.MustExec("insert into t values(1, 1, 1), (2, 2, 2), (3, 3, 3)") tk.MustQuery("explain select * from t where a = 1").Check(testkit.Rows( - "Point_Get_1 1.00 root table:t, handle:1", + "Point_Get_1 1.00 root table:t handle:1", )) tk.MustQuery("explain select * from t where 1 = a").Check(testkit.Rows( - "Point_Get_1 1.00 root table:t, handle:1", + "Point_Get_1 1.00 root table:t handle:1", )) tk.MustQuery("explain update t set b=b+1, c=c+1 where a = 1").Check(testkit.Rows( - "Update_2 N/A root N/A", - "└─Point_Get_1 1.00 root table:t, handle:1", + "Update_2 N/A root N/A", + "└─Point_Get_1 1.00 root table:t handle:1", )) tk.MustQuery("explain delete from t where a = 1").Check(testkit.Rows( - "Delete_2 N/A root N/A", - "└─Point_Get_1 1.00 root table:t, handle:1", + "Delete_2 N/A root N/A", + "└─Point_Get_1 1.00 root table:t handle:1", )) tk.MustQuery("explain select a from t where a = -1").Check(testkit.Rows( - "TableDual_5 0.00 root rows:0", + "TableDual_5 0.00 root rows:0", )) tk.MustExec(`prepare stmt0 from "select a from t where a = ?"`) tk.MustExec("set @p0 = -1") @@ -197,7 +197,7 @@ func (s *testPointGetSuite) TestPointGetForUpdate(c *C) { func checkUseForUpdate(tk *testkit.TestKit, c *C, expectLock bool) { res := tk.MustQuery("explain select * from fu where id = 6 for update") // Point_Get_1 1.00 root table:fu, handle:6 - opInfo := res.Rows()[0][3] + opInfo := res.Rows()[0][4] selectLock := strings.Contains(fmt.Sprintf("%s", opInfo), "lock") c.Assert(selectLock, Equals, expectLock) @@ -217,34 +217,34 @@ func (s *testPointGetSuite) TestWhereIn2BatchPointGet(c *C) { "4 4 5", )) tk.MustQuery("explain select * from t where a = 1 and b = 1 and c = 1").Check(testkit.Rows( - "Point_Get_1 1.00 root table:t, index:a b c", + "Point_Get_1 1.00 root table:t, index:idx_abc(a, b, c) ", )) tk.MustQuery("explain select * from t where 1 = a and 1 = b and 1 = c").Check(testkit.Rows( - "Point_Get_1 1.00 root table:t, index:a b c", + "Point_Get_1 1.00 root table:t, index:idx_abc(a, b, c) ", )) tk.MustQuery("explain select * from t where 1 = a and b = 1 and 1 = c").Check(testkit.Rows( - "Point_Get_1 1.00 root table:t, index:a b c", + "Point_Get_1 1.00 root table:t, index:idx_abc(a, b, c) ", )) tk.MustQuery("explain select * from t where (a, b, c) in ((1, 1, 1), (2, 2, 2))").Check(testkit.Rows( - "Batch_Point_Get_1 2.00 root table:t, index:a b c, keep order:false, desc:false", + "Batch_Point_Get_1 2.00 root table:t, index:idx_abc(a, b, c) keep order:false, desc:false", )) tk.MustQuery("explain select * from t where a in (1, 2, 3, 4, 5)").Check(testkit.Rows( - "Batch_Point_Get_1 5.00 root table:t, handle:[1 2 3 4 5], keep order:false, desc:false", + "Batch_Point_Get_1 5.00 root table:t handle:[1 2 3 4 5], keep order:false, desc:false", )) tk.MustQuery("explain select * from t where a in (1, 2, 3, 1, 2)").Check(testkit.Rows( - "Batch_Point_Get_1 5.00 root table:t, handle:[1 2 3 1 2], keep order:false, desc:false", + "Batch_Point_Get_1 5.00 root table:t handle:[1 2 3 1 2], keep order:false, desc:false", )) tk.MustExec("begin") tk.MustQuery("explain select * from t where a in (1, 2, 3, 1, 2) FOR UPDATE").Check(testkit.Rows( - "Batch_Point_Get_1 5.00 root table:t, handle:[1 2 3 1 2], keep order:false, desc:false, lock", + "Batch_Point_Get_1 5.00 root table:t handle:[1 2 3 1 2], keep order:false, desc:false, lock", )) tk.MustExec("rollback") tk.MustQuery("explain select * from t where (a) in ((1), (2), (3), (1), (2))").Check(testkit.Rows( - "Batch_Point_Get_1 5.00 root table:t, handle:[1 2 3 1 2], keep order:false, desc:false", + "Batch_Point_Get_1 5.00 root table:t handle:[1 2 3 1 2], keep order:false, desc:false", )) tk.MustExec("use test") @@ -258,7 +258,7 @@ func (s *testPointGetSuite) TestWhereIn2BatchPointGet(c *C) { "4 5 6", )) tk.MustQuery("explain select * from t where (a, b) in ((1, 2), (2, 3))").Check(testkit.Rows( - "Batch_Point_Get_1 2.00 root table:t, index:a b, keep order:false, desc:false", + "Batch_Point_Get_1 2.00 root table:t, index:idx_ab(a, b) keep order:false, desc:false", )) tk.MustQuery("select * from t where (a, b) in ((1, 2), (2, 3))").Check(testkit.Rows( "1 2 3", @@ -282,7 +282,7 @@ func (s *testPointGetSuite) TestWhereIn2BatchPointGet(c *C) { tk.MustExec("begin pessimistic") tk.MustQuery("explain select * from t where (a, b) in ((1, 2), (2, 3)) FOR UPDATE").Check(testkit.Rows( - "Batch_Point_Get_1 2.00 root table:t, index:a b, keep order:false, desc:false, lock", + "Batch_Point_Get_1 2.00 root table:t, index:idx_ab(a, b) keep order:false, desc:false, lock", )) tk.MustExec("rollback") } @@ -357,7 +357,7 @@ func (s *testPointGetSuite) TestBatchPointGetPlanCache(c *C) { tk.MustExec("create table t(a int primary key, b int)") tk.MustExec("insert into t values(1, 1), (2, 2), (3, 3), (4, 4)") tk.MustQuery("explain select * from t where a in (1, 2)").Check(testkit.Rows( - "Batch_Point_Get_1 2.00 root table:t, handle:[1 2], keep order:false, desc:false", + "Batch_Point_Get_1 2.00 root table:t handle:[1 2], keep order:false, desc:false", )) tk.MustExec("prepare stmt from 'select * from t where a in (?,?)'") tk.MustExec("set @p1 = 1, @p2 = 2") @@ -391,18 +391,18 @@ func (s *testPointGetSuite) TestBatchPointGetPartition(c *C) { tk.MustExec("create table t(a int primary key, b int) PARTITION BY HASH(a) PARTITIONS 4") tk.MustExec("insert into t values (1, 1), (2, 2), (3, 3), (4, 4)") tk.MustQuery("explain select * from t where a in (1, 2, 3, 4)").Check(testkit.Rows( - "Batch_Point_Get_1 4.00 root table:t, handle:[1 2 3 4], keep order:false, desc:false", + "Batch_Point_Get_1 4.00 root table:t handle:[1 2 3 4], keep order:false, desc:false", )) tk.MustQuery("select * from t where a in (1, 2, 3, 4)").Check(testkit.Rows("1 1", "2 2", "3 3", "4 4")) tk.MustQuery("explain update t set b = b + 1 where a in (1, 2, 3, 4)").Check(testkit.Rows( - "Update_2 N/A root N/A]\n[└─Batch_Point_Get_1 4.00 root table:t, handle:[1 2 3 4], keep order:false, desc:false", + "Update_2 N/A root N/A]\n[└─Batch_Point_Get_1 4.00 root table:t handle:[1 2 3 4], keep order:false, desc:false", )) tk.MustExec("update t set b = b + 1 where a in (1, 2, 3, 4)") tk.MustQuery("select * from t where a in (1, 2, 3, 4)").Check(testkit.Rows("1 2", "2 3", "3 4", "4 5")) tk.MustQuery("explain delete from t where a in (1, 2, 3, 4)").Check(testkit.Rows( - "Delete_2 N/A root N/A]\n[└─Batch_Point_Get_1 4.00 root table:t, handle:[1 2 3 4], keep order:false, desc:false", + "Delete_2 N/A root N/A]\n[└─Batch_Point_Get_1 4.00 root table:t handle:[1 2 3 4], keep order:false, desc:false", )) tk.MustExec("delete from t where a in (1, 2, 3, 4)") tk.MustQuery("select * from t where a in (1, 2, 3, 4)").Check(testkit.Rows()) @@ -411,20 +411,20 @@ func (s *testPointGetSuite) TestBatchPointGetPartition(c *C) { tk.MustExec("create table t(a int, b int, c int, primary key (a, b)) PARTITION BY HASH(a) PARTITIONS 4") tk.MustExec("insert into t values (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4)") tk.MustQuery("explain select * from t where (a, b) in ((1, 1), (2, 2), (3, 3), (4, 4))").Check(testkit.Rows( - "Batch_Point_Get_1 4.00 root table:t, index:a b, keep order:false, desc:false", + "Batch_Point_Get_1 4.00 root table:t, index:PRIMARY(a, b) keep order:false, desc:false", )) tk.MustQuery("select * from t where (a, b) in ((1, 1), (2, 2), (3, 3), (4, 4))"). Check(testkit.Rows("1 1 1", "2 2 2", "3 3 3", "4 4 4")) tk.MustQuery("explain update t set c = c + 1 where (a,b) in ((1,1),(2,2),(3,3),(4,4))").Check(testkit.Rows( - "Update_2 N/A root N/A]\n[└─Batch_Point_Get_1 4.00 root table:t, index:a b, keep order:false, desc:false", + "Update_2 N/A root N/A]\n[└─Batch_Point_Get_1 4.00 root table:t, index:PRIMARY(a, b) keep order:false, desc:false", )) tk.MustExec("update t set c = c + 1 where (a,b) in ((1,1),(2,2),(3,3),(4,4))") tk.MustQuery("select * from t where (a, b) in ((1, 1), (2, 2), (3, 3), (4, 4))").Sort(). Check(testkit.Rows("1 1 2", "2 2 3", "3 3 4", "4 4 5")) tk.MustQuery("explain delete from t where (a,b) in ((1,1),(2,2),(3,3),(4,4))").Check(testkit.Rows( - "Delete_2 N/A root N/A]\n[└─Batch_Point_Get_1 4.00 root table:t, index:a b, keep order:false, desc:false", + "Delete_2 N/A root N/A]\n[└─Batch_Point_Get_1 4.00 root table:t, index:PRIMARY(a, b) keep order:false, desc:false", )) tk.MustExec("delete from t where (a,b) in ((1,1),(2,2),(3,3),(4,4))") tk.MustQuery("select * from t where (a, b) in ((1, 1), (2, 2), (3, 3), (4, 4))").Check(testkit.Rows()) diff --git a/planner/core/rule_partition_processor.go b/planner/core/rule_partition_processor.go index d14cd0c7f70e3..5d42630c6f326 100644 --- a/planner/core/rule_partition_processor.go +++ b/planner/core/rule_partition_processor.go @@ -21,6 +21,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/parser/ast" "github.com/pingcap/parser/model" + "github.com/pingcap/parser/mysql" "github.com/pingcap/tidb/expression" "github.com/pingcap/tidb/planner/util" "github.com/pingcap/tidb/sessionctx" @@ -175,16 +176,16 @@ func (*partitionProcessor) name() string { return "partition_processor" } -type lessThanData struct { +type lessThanDataInt struct { data []int64 maxvalue bool } -func (lt *lessThanData) length() int { +func (lt *lessThanDataInt) length() int { return len(lt.data) } -func (lt *lessThanData) compare(ith int, v int64) int { +func (lt *lessThanDataInt) compare(ith int, v int64) int { if ith == len(lt.data)-1 { if lt.maxvalue { return 1 @@ -313,34 +314,34 @@ func intersectionRange(start, end, newStart, newEnd int) (int, int) { } func (s *partitionProcessor) pruneRangePartition(ds *DataSource, pi *model.PartitionInfo) (LogicalPlan, error) { - var col *expression.Column - var fn *expression.ScalarFunction - var err error - // Partition by range. - if len(pi.Columns) == 0 { - col, fn, err = makePartitionByFnCol(ds.ctx, ds.TblCols, ds.names, pi.Expr) - } else if len(pi.Columns) == 1 { - // Convert partition by range columns to range. - col, fn, err = makePartitionByFnCol(ds.ctx, ds.TblCols, ds.names, pi.Columns[0].L) + // Partition by range columns. + if len(pi.Columns) > 0 { + return s.pruneRangeColumnsPartition(ds, pi) } + + // Partition by range. + col, fn, err := makePartitionByFnCol(ds.ctx, ds.TblCols, ds.names, pi.Expr) if err != nil { return nil, err } result := fullRange(len(pi.Definitions)) + // Extract the partition column, if the column is not null, it's possible to prune. if col != nil { + // TODO: Store LessThanData in the partitionExpr, avoid allocating here. lessThan, err := makeLessThanData(pi) if err != nil { return nil, err } - result = partitionRangeForCNFExpr(ds.ctx, ds.allConds, lessThan, col, fn, result) + pruner := rangePruner{lessThan, col, fn} + result = partitionRangeForCNFExpr(ds.ctx, ds.allConds, &pruner, result) } return s.makeUnionAllChildren(ds, pi, result) } // makeLessThanData extracts the less than parts from 'partition p0 less than xx ... partitoin p1 less than ...' -func makeLessThanData(pi *model.PartitionInfo) (lessThanData, error) { +func makeLessThanData(pi *model.PartitionInfo) (lessThanDataInt, error) { var maxValue bool lessThan := make([]int64, len(pi.Definitions)) for i := 0; i < len(pi.Definitions); i++ { @@ -351,11 +352,11 @@ func makeLessThanData(pi *model.PartitionInfo) (lessThanData, error) { var err error lessThan[i], err = strconv.ParseInt(pi.Definitions[i].LessThan[0], 10, 64) if err != nil { - return lessThanData{}, errors.WithStack(err) + return lessThanDataInt{}, errors.WithStack(err) } } } - return lessThanData{lessThan, maxValue}, nil + return lessThanDataInt{lessThan, maxValue}, nil } // makePartitionByFnCol extracts the column and function information in 'partition by ... fn(col)'. @@ -380,43 +381,69 @@ func makePartitionByFnCol(sctx sessionctx.Context, columns []*expression.Column, return col, fn, nil } -func partitionRangeForCNFExpr(sctx sessionctx.Context, exprs []expression.Expression, lessThan lessThanData, - col *expression.Column, partFn *expression.ScalarFunction, result partitionRangeOR) partitionRangeOR { +func partitionRangeForCNFExpr(sctx sessionctx.Context, exprs []expression.Expression, + pruner partitionRangePruner, result partitionRangeOR) partitionRangeOR { for i := 0; i < len(exprs); i++ { - result = partitionRangeForExpr(sctx, exprs[i], lessThan, col, partFn, result) + result = partitionRangeForExpr(sctx, exprs[i], pruner, result) } return result } // partitionRangeForExpr calculate the partitions for the expression. -func partitionRangeForExpr(sctx sessionctx.Context, expr expression.Expression, lessThan lessThanData, - col *expression.Column, partFn *expression.ScalarFunction, result partitionRangeOR) partitionRangeOR { +func partitionRangeForExpr(sctx sessionctx.Context, expr expression.Expression, + pruner partitionRangePruner, result partitionRangeOR) partitionRangeOR { // Handle AND, OR respectively. if op, ok := expr.(*expression.ScalarFunction); ok { if op.FuncName.L == ast.LogicAnd { - return partitionRangeForCNFExpr(sctx, op.GetArgs(), lessThan, col, partFn, result) + return partitionRangeForCNFExpr(sctx, op.GetArgs(), pruner, result) } else if op.FuncName.L == ast.LogicOr { args := op.GetArgs() - newRange := partitionRangeForOrExpr(sctx, args[0], args[1], lessThan, col, partFn) + newRange := partitionRangeForOrExpr(sctx, args[0], args[1], pruner) return result.intersection(newRange) } } // Handle a single expression. - dataForPrune, ok := extractDataForPrune(sctx, expr, col, partFn) + start, end, ok := pruner.partitionRangeForExpr(sctx, expr) if !ok { // Can't prune, return the whole range. return result } - start, end := pruneUseBinarySearch(lessThan, dataForPrune) return result.intersectionRange(start, end) } +type partitionRangePruner interface { + partitionRangeForExpr(sessionctx.Context, expression.Expression) (start, end int, succ bool) + fullRange() partitionRangeOR +} + +var _ partitionRangePruner = &rangePruner{} + +// rangePruner is used by 'partition by range'. +type rangePruner struct { + lessThan lessThanDataInt + col *expression.Column + partFn *expression.ScalarFunction +} + +func (p *rangePruner) partitionRangeForExpr(sctx sessionctx.Context, expr expression.Expression) (int, int, bool) { + dataForPrune, ok := p.extractDataForPrune(sctx, expr) + if !ok { + return 0, 0, false + } + start, end := pruneUseBinarySearch(p.lessThan, dataForPrune) + return start, end, true +} + +func (p *rangePruner) fullRange() partitionRangeOR { + return fullRange(p.lessThan.length()) +} + // partitionRangeForOrExpr calculate the partitions for or(expr1, expr2) -func partitionRangeForOrExpr(sctx sessionctx.Context, expr1, expr2 expression.Expression, lessThan lessThanData, - col *expression.Column, partFn *expression.ScalarFunction) partitionRangeOR { - tmp1 := partitionRangeForExpr(sctx, expr1, lessThan, col, partFn, fullRange(lessThan.length())) - tmp2 := partitionRangeForExpr(sctx, expr2, lessThan, col, partFn, fullRange(lessThan.length())) +func partitionRangeForOrExpr(sctx sessionctx.Context, expr1, expr2 expression.Expression, + pruner partitionRangePruner) partitionRangeOR { + tmp1 := partitionRangeForExpr(sctx, expr1, pruner, pruner.fullRange()) + tmp2 := partitionRangeForExpr(sctx, expr2, pruner, pruner.fullRange()) return tmp1.union(tmp2) } @@ -434,7 +461,7 @@ type dataForPrune struct { // extractDataForPrune extracts data from the expression for pruning. // The expression should have this form: 'f(x) op const', otherwise it can't be pruned. -func extractDataForPrune(sctx sessionctx.Context, expr expression.Expression, partCol *expression.Column, partFn *expression.ScalarFunction) (dataForPrune, bool) { +func (p *rangePruner) extractDataForPrune(sctx sessionctx.Context, expr expression.Expression) (dataForPrune, bool) { var ret dataForPrune op, ok := expr.(*expression.ScalarFunction) if !ok { @@ -445,7 +472,7 @@ func extractDataForPrune(sctx sessionctx.Context, expr expression.Expression, pa ret.op = op.FuncName.L case ast.IsNull: // isnull(col) - if arg0, ok := op.GetArgs()[0].(*expression.Column); ok && arg0.ID == partCol.ID { + if arg0, ok := op.GetArgs()[0].(*expression.Column); ok && arg0.ID == p.col.ID { ret.op = ast.IsNull return ret, true } @@ -456,11 +483,11 @@ func extractDataForPrune(sctx sessionctx.Context, expr expression.Expression, pa var col *expression.Column var con *expression.Constant - if arg0, ok := op.GetArgs()[0].(*expression.Column); ok && arg0.ID == partCol.ID { + if arg0, ok := op.GetArgs()[0].(*expression.Column); ok && arg0.ID == p.col.ID { if arg1, ok := op.GetArgs()[1].(*expression.Constant); ok { col, con = arg0, arg1 } - } else if arg0, ok := op.GetArgs()[1].(*expression.Column); ok && arg0.ID == partCol.ID { + } else if arg0, ok := op.GetArgs()[1].(*expression.Column); ok && arg0.ID == p.col.ID { if arg1, ok := op.GetArgs()[0].(*expression.Constant); ok { ret.op = opposite(ret.op) col, con = arg0, arg1 @@ -472,12 +499,12 @@ func extractDataForPrune(sctx sessionctx.Context, expr expression.Expression, pa // Current expression is 'col op const' var constExpr expression.Expression - if partFn != nil { + if p.partFn != nil { // If the partition expression is fn(col), change constExpr to fn(constExpr). // No 'copy on write' for the expression here, this is a dangerous operation. - args := partFn.GetArgs() + args := p.partFn.GetArgs() args[0] = con - constExpr = partFn + constExpr = p.partFn // Sometimes we need to relax the condition, < to <=, > to >=. // For example, the following case doesn't hold: // col < '2020-02-11 17:34:11' => to_days(col) < to_days(2020-02-11 17:34:11) @@ -529,7 +556,7 @@ func relaxOP(op string) string { return op } -func pruneUseBinarySearch(lessThan lessThanData, data dataForPrune) (start int, end int) { +func pruneUseBinarySearch(lessThan lessThanDataInt, data dataForPrune) (start int, end int) { length := lessThan.length() switch data.op { case ast.EQ: @@ -624,3 +651,139 @@ func (s *partitionProcessor) makeUnionAllChildren(ds *DataSource, pi *model.Part unionAll.SetSchema(ds.schema.Clone()) return unionAll, nil } + +func (s *partitionProcessor) pruneRangeColumnsPartition(ds *DataSource, pi *model.PartitionInfo) (LogicalPlan, error) { + result := fullRange(len(pi.Definitions)) + + if len(pi.Columns) != 1 { + // We only support single column. + return s.makeUnionAllChildren(ds, pi, result) + } + + pruner, err := makeRangeColumnPruner(ds, pi) + if err == nil { + result = partitionRangeForCNFExpr(ds.ctx, ds.allConds, pruner, result) + } + return s.makeUnionAllChildren(ds, pi, result) +} + +var _ partitionRangePruner = &rangeColumnPruner{} + +// rangeColumnPruner is used by 'partition by range columns'. +type rangeColumnPruner struct { + data []expression.Expression + partCol *expression.Column + maxvalue bool +} + +func makeRangeColumnPruner(ds *DataSource, pi *model.PartitionInfo) (*rangeColumnPruner, error) { + var maxValue bool + data := make([]expression.Expression, len(pi.Definitions)) + schema := expression.NewSchema(ds.TblCols...) + exprs, err := expression.ParseSimpleExprsWithNames(ds.ctx, pi.Columns[0].L, schema, ds.names) + if err != nil { + return nil, err + } + partCol := exprs[0].(*expression.Column) + for i := 0; i < len(pi.Definitions); i++ { + if strings.EqualFold(pi.Definitions[i].LessThan[0], "MAXVALUE") { + // Use a bool flag instead of math.MaxInt64 to avoid the corner cases. + maxValue = true + } else { + tmp, err := expression.ParseSimpleExprsWithNames(ds.ctx, pi.Definitions[i].LessThan[0], schema, ds.names) + if err != nil { + return nil, err + } + data[i] = tmp[0] + } + } + return &rangeColumnPruner{data, partCol, maxValue}, nil +} + +func (p *rangeColumnPruner) fullRange() partitionRangeOR { + return fullRange(len(p.data)) +} + +func (p *rangeColumnPruner) partitionRangeForExpr(sctx sessionctx.Context, expr expression.Expression) (int, int, bool) { + op, ok := expr.(*expression.ScalarFunction) + if !ok { + return 0, len(p.data), false + } + + switch op.FuncName.L { + case ast.EQ, ast.LT, ast.GT, ast.LE, ast.GE: + case ast.IsNull: + // isnull(col) + if arg0, ok := op.GetArgs()[0].(*expression.Column); ok && arg0.ID == p.partCol.ID { + return 0, 1, true + } + return 0, len(p.data), false + default: + return 0, len(p.data), false + } + opName := op.FuncName.L + + var col *expression.Column + var con *expression.Constant + if arg0, ok := op.GetArgs()[0].(*expression.Column); ok && arg0.ID == p.partCol.ID { + if arg1, ok := op.GetArgs()[1].(*expression.Constant); ok { + col, con = arg0, arg1 + } + } else if arg0, ok := op.GetArgs()[1].(*expression.Column); ok && arg0.ID == p.partCol.ID { + if arg1, ok := op.GetArgs()[0].(*expression.Constant); ok { + opName = opposite(opName) + col, con = arg0, arg1 + } + } + if col == nil || con == nil { + return 0, len(p.data), false + } + + start, end := p.pruneUseBinarySearch(sctx, opName, con) + return start, end, true +} + +func (p *rangeColumnPruner) pruneUseBinarySearch(sctx sessionctx.Context, op string, data *expression.Constant) (start int, end int) { + var err error + var isNull bool + compare := func(ith int, op string, v *expression.Constant) bool { + if ith == len(p.data)-1 { + if p.maxvalue { + return true + } + } + var expr expression.Expression + expr, err = expression.NewFunction(sctx, op, types.NewFieldType(mysql.TypeLonglong), p.data[ith], v) + var val int64 + val, isNull, err = expr.EvalInt(sctx, chunk.Row{}) + return val > 0 + } + + length := len(p.data) + switch op { + case ast.EQ: + pos := sort.Search(length, func(i int) bool { return compare(i, ast.GT, data) }) + start, end = pos, pos+1 + case ast.LT: + pos := sort.Search(length, func(i int) bool { return compare(i, ast.GE, data) }) + start, end = 0, pos+1 + case ast.GE, ast.GT: + pos := sort.Search(length, func(i int) bool { return compare(i, ast.GT, data) }) + start, end = pos, length + case ast.LE: + pos := sort.Search(length, func(i int) bool { return compare(i, ast.GT, data) }) + start, end = 0, pos+1 + default: + start, end = 0, length + } + + // Something goes wrong, abort this prunning. + if err != nil || isNull { + return 0, len(p.data) + } + + if end > length { + end = length + } + return start, end +} diff --git a/planner/core/task.go b/planner/core/task.go index 7f0f38ed6f5f9..006eeb57edf05 100644 --- a/planner/core/task.go +++ b/planner/core/task.go @@ -708,7 +708,7 @@ func finishCopTask(ctx sessionctx.Context, task task) task { StoreType: ts.StoreType, }.Init(ctx, t.tablePlan.SelectBlockOffset()) p.stats = t.tablePlan.statsInfo() - ts.ExpandVirtualColumn() + ts.Columns = ExpandVirtualColumn(ts.Columns, ts.schema, ts.Table.Columns) newTask.p = p } diff --git a/planner/core/testdata/analyze_suite_out.json b/planner/core/testdata/analyze_suite_out.json index 616502419c2f0..b50c8641a22fc 100644 --- a/planner/core/testdata/analyze_suite_out.json +++ b/planner/core/testdata/analyze_suite_out.json @@ -8,10 +8,10 @@ "EXPLAIN SELECT * FROM t WHERE b = 2 ORDER BY a limit 1;" ], "Plan": [ - "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", - "└─IndexReader_16 1.00 root index:TopN_15", - " └─TopN_15 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", - " └─IndexRangeScan_14 10.00 cop[tikv] table:t, index:b, c, range:[2,2], keep order:false, stats:pseudo" + "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", + "└─IndexReader_16 1.00 root index:TopN_15", + " └─TopN_15 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", + " └─IndexRangeScan_14 10.00 cop[tikv] table:t, index:idx_bc(b, c) range:[2,2], keep order:false, stats:pseudo" ] }, { @@ -21,10 +21,10 @@ "EXPLAIN SELECT * FROM t WHERE b = 2 ORDER BY a limit 1" ], "Plan": [ - "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", - "└─IndexReader_16 1.00 root index:TopN_15", - " └─TopN_15 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", - " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:b, c, range:[2,2], keep order:false" + "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", + "└─IndexReader_16 1.00 root index:TopN_15", + " └─TopN_15 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", + " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:idx_bc(b, c) range:[2,2], keep order:false" ] }, { @@ -35,10 +35,10 @@ "EXPLAIN SELECT * FROM t WHERE b <= 6 ORDER BY a limit 1" ], "Plan": [ - "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", - "└─IndexReader_16 1.00 root index:TopN_15", - " └─TopN_15 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", - " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:b, c, range:[-inf,6], keep order:false" + "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", + "└─IndexReader_16 1.00 root index:TopN_15", + " └─TopN_15 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", + " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:idx_bc(b, c) range:[-inf,6], keep order:false" ] }, { @@ -46,14 +46,14 @@ "EXPLAIN SELECT *, t1.a IN (SELECT t2.b FROM t t2) FROM t t1 WHERE t1.b <= 6 ORDER BY t1.a limit 1" ], "Plan": [ - "Limit_17 1.00 root offset:0, count:1", - "└─IndexMergeJoin_70 1.00 root left outer semi join, inner:IndexReader_68, outer key:test.t.a, inner key:test.t.b", - " ├─TopN_29(Build) 1.00 root test.t.a:asc, offset:0, count:1", - " │ └─IndexReader_37 1.00 root index:TopN_36", - " │ └─TopN_36 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", - " │ └─IndexRangeScan_35 6.00 cop[tikv] table:t1, index:b, c, range:[-inf,6], keep order:false", - " └─IndexReader_68(Probe) 1.04 root index:IndexRangeScan_67", - " └─IndexRangeScan_67 1.04 cop[tikv] table:t2, index:b, c, range: decided by [eq(test.t.b, test.t.a)], keep order:true" + "Limit_17 1.00 root offset:0, count:1", + "└─IndexMergeJoin_70 1.00 root left outer semi join, inner:IndexReader_68, outer key:test.t.a, inner key:test.t.b", + " ├─TopN_29(Build) 1.00 root test.t.a:asc, offset:0, count:1", + " │ └─IndexReader_37 1.00 root index:TopN_36", + " │ └─TopN_36 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", + " │ └─IndexRangeScan_35 6.00 cop[tikv] table:t1, index:idx_bc(b, c) range:[-inf,6], keep order:false", + " └─IndexReader_68(Probe) 1.04 root index:IndexRangeScan_67", + " └─IndexRangeScan_67 1.04 cop[tikv] table:t2, index:idx_bc(b, c) range: decided by [eq(test.t.b, test.t.a)], keep order:true" ] }, { @@ -64,10 +64,10 @@ "EXPLAIN SELECT * FROM t WHERE b = 1 ORDER BY a desc limit 1" ], "Plan": [ - "TopN_8 1.00 root test.t.a:desc, offset:0, count:1", - "└─IndexReader_16 1.00 root index:TopN_15", - " └─TopN_15 1.00 cop[tikv] test.t.a:desc, offset:0, count:1", - " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:b, c, range:[1,1], keep order:false" + "TopN_8 1.00 root test.t.a:desc, offset:0, count:1", + "└─IndexReader_16 1.00 root index:TopN_15", + " └─TopN_15 1.00 cop[tikv] test.t.a:desc, offset:0, count:1", + " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:idx_bc(b, c) range:[1,1], keep order:false" ] }, { @@ -78,11 +78,11 @@ "EXPLAIN SELECT * FROM t WHERE b = 2 ORDER BY a limit 1" ], "Plan": [ - "Limit_11 1.00 root offset:0, count:1", - "└─TableReader_22 1.00 root data:Limit_21", - " └─Limit_21 1.00 cop[tikv] offset:0, count:1", - " └─Selection_20 1.00 cop[tikv] eq(test.t.b, 2)", - " └─TableFullScan_19 4.17 cop[tikv] table:t, keep order:true" + "Limit_11 1.00 root offset:0, count:1", + "└─TableReader_22 1.00 root data:Limit_21", + " └─Limit_21 1.00 cop[tikv] offset:0, count:1", + " └─Selection_20 1.00 cop[tikv] eq(test.t.b, 2)", + " └─TableFullScan_19 4.17 cop[tikv] table:t keep order:true" ] }, { @@ -91,10 +91,10 @@ "EXPLAIN SELECT * FROM t WHERE b = 2 ORDER BY a limit 1" ], "Plan": [ - "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", - "└─IndexReader_16 1.00 root index:TopN_15", - " └─TopN_15 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", - " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:b, c, range:[2,2], keep order:false" + "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", + "└─IndexReader_16 1.00 root index:TopN_15", + " └─TopN_15 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", + " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:idx_bc(b, c) range:[2,2], keep order:false" ] }, { @@ -106,11 +106,11 @@ "EXPLAIN SELECT * FROM t WHERE b = 2 and a > 0 ORDER BY a limit 1" ], "Plan": [ - "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", - "└─IndexReader_19 1.00 root index:TopN_18", - " └─TopN_18 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", - " └─Selection_17 6.00 cop[tikv] gt(test.t.a, 0)", - " └─IndexRangeScan_16 6.00 cop[tikv] table:t, index:b, c, range:[2,2], keep order:false" + "TopN_8 1.00 root test.t.a:asc, offset:0, count:1", + "└─IndexReader_19 1.00 root index:TopN_18", + " └─TopN_18 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", + " └─Selection_17 6.00 cop[tikv] gt(test.t.a, 0)", + " └─IndexRangeScan_16 6.00 cop[tikv] table:t, index:idx_bc(b, c) range:[2,2], keep order:false" ] }, { @@ -122,12 +122,12 @@ "EXPLAIN SELECT a FROM t WHERE b = 2 and c > 0 ORDER BY a limit 1" ], "Plan": [ - "Projection_7 1.00 root test.t.a", - "└─TopN_8 1.00 root test.t.a:asc, offset:0, count:1", - " └─IndexReader_17 1.00 root index:TopN_16", - " └─TopN_16 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", - " └─Selection_15 6.00 cop[tikv] gt(test.t.c, 0)", - " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:b, d, a, c, range:[2,2], keep order:false" + "Projection_7 1.00 root test.t.a", + "└─TopN_8 1.00 root test.t.a:asc, offset:0, count:1", + " └─IndexReader_17 1.00 root index:TopN_16", + " └─TopN_16 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", + " └─Selection_15 6.00 cop[tikv] gt(test.t.c, 0)", + " └─IndexRangeScan_14 6.00 cop[tikv] table:t, index:idx(b, d, a, c) range:[2,2], keep order:false" ] } ] @@ -142,13 +142,13 @@ "explain select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t2.a=t1.a and t2.b>t1.b-1 and t2.bColumn#13", - " └─HashLeftJoin_23 1.00 root inner join, equal:[eq(test.t.a, test.t.a)]", - " ├─TableReader_33(Build) 1.00 root data:Selection_32", - " │ └─Selection_32 1.00 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a))", - " │ └─TableFullScan_31 10.00 cop[tikv] table:t1, keep order:false", - " └─TableReader_27(Probe) 1.00 root data:Selection_26", - " └─Selection_26 1.00 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a))", - " └─TableFullScan_25 10.00 cop[tikv] table:s, keep order:false" + "Projection_11 10.00 root Column#14", + "└─Apply_13 10.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#13)", + " ├─TableReader_15(Build) 10.00 root data:TableFullScan_14", + " │ └─TableFullScan_14 10.00 cop[tikv] table:t keep order:false", + " └─StreamAgg_22(Probe) 1.00 root funcs:count(1)->Column#13", + " └─HashJoin_23 1.00 root inner join, equal:[eq(test.t.a, test.t.a)]", + " ├─TableReader_33(Build) 1.00 root data:Selection_32", + " │ └─Selection_32 1.00 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a))", + " │ └─TableFullScan_31 10.00 cop[tikv] table:t1 keep order:false", + " └─TableReader_27(Probe) 1.00 root data:Selection_26", + " └─Selection_26 1.00 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a))", + " └─TableFullScan_25 10.00 cop[tikv] table:s keep order:false" ], [ - "Projection_8 10.00 root Column#9", - "└─Apply_10 10.00 root CARTESIAN left outer join", - " ├─TableReader_12(Build) 10.00 root data:TableFullScan_11", - " │ └─TableFullScan_11 10.00 cop[tikv] table:t, keep order:false", - " └─MaxOneRow_15(Probe) 1.00 root ", - " └─Projection_16 0.10 root concat(cast(test.t.a, var_string(20)), ,, cast(test.t.b, var_string(20)))->Column#9", - " └─IndexReader_19 0.10 root index:Selection_18", - " └─Selection_18 0.10 cop[tikv] eq(test.t.a, test.t.a)", - " └─IndexRangeScan_17 1.00 cop[tikv] table:t1, index:c, b, a, range: decided by [eq(test.t.c, test.t.c)], keep order:false" + "Projection_8 10.00 root Column#9", + "└─Apply_10 10.00 root CARTESIAN left outer join", + " ├─TableReader_12(Build) 10.00 root data:TableFullScan_11", + " │ └─TableFullScan_11 10.00 cop[tikv] table:t keep order:false", + " └─MaxOneRow_15(Probe) 1.00 root ", + " └─Projection_16 0.10 root concat(cast(test.t.a, var_string(20)), ,, cast(test.t.b, var_string(20)))->Column#9", + " └─IndexReader_19 0.10 root index:Selection_18", + " └─Selection_18 0.10 cop[tikv] eq(test.t.a, test.t.a)", + " └─IndexRangeScan_17 1.00 cop[tikv] table:t1, index:idx(c, b, a) range: decided by [eq(test.t.c, test.t.c)], keep order:false" ] ] }, diff --git a/planner/core/testdata/integration_suite_out.json b/planner/core/testdata/integration_suite_out.json index f6cbb2ca7e59f..3da8515fd669e 100644 --- a/planner/core/testdata/integration_suite_out.json +++ b/planner/core/testdata/integration_suite_out.json @@ -5,41 +5,41 @@ { "SQL": "explain select * from tbl use index(idx_b_c) where b > 1 limit 2,1", "Plan": [ - "IndexLookUp_14 1.00 root limit embedded(offset:2, count:1)", - "├─Limit_13(Build) 3.00 cop[tikv] offset:0, count:3", - "│ └─IndexRangeScan_11 3.00 cop[tikv] table:tbl, index:b, c, range:(1,+inf], keep order:false", - "└─TableRowIDScan_12(Probe) 1.00 cop[tikv] table:tbl, keep order:false, stats:pseudo" + "IndexLookUp_14 1.00 root limit embedded(offset:2, count:1)", + "├─Limit_13(Build) 3.00 cop[tikv] offset:0, count:3", + "│ └─IndexRangeScan_11 3.00 cop[tikv] table:tbl, index:idx_b_c(b, c) range:(1,+inf], keep order:false", + "└─TableRowIDScan_12(Probe) 1.00 cop[tikv] table:tbl keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from tbl use index(idx_b_c) where b > 1 order by b desc limit 2,1", "Plan": [ - "Projection_25 1.00 root test.tbl.a, test.tbl.b, test.tbl.c", - "└─IndexLookUp_24 1.00 root limit embedded(offset:2, count:1)", - " ├─Limit_23(Build) 3.00 cop[tikv] offset:0, count:3", - " │ └─IndexRangeScan_21 3.00 cop[tikv] table:tbl, index:b, c, range:(1,+inf], keep order:true, desc", - " └─TableRowIDScan_22(Probe) 1.00 cop[tikv] table:tbl, keep order:false, stats:pseudo" + "Projection_25 1.00 root test.tbl.a, test.tbl.b, test.tbl.c", + "└─IndexLookUp_24 1.00 root limit embedded(offset:2, count:1)", + " ├─Limit_23(Build) 3.00 cop[tikv] offset:0, count:3", + " │ └─IndexRangeScan_21 3.00 cop[tikv] table:tbl, index:idx_b_c(b, c) range:(1,+inf], keep order:true, desc", + " └─TableRowIDScan_22(Probe) 1.00 cop[tikv] table:tbl keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from tbl use index(idx_b_c) where b > 1 and c > 1 limit 2,1", "Plan": [ - "IndexLookUp_15 1.00 root limit embedded(offset:2, count:1)", - "├─Limit_14(Build) 3.00 cop[tikv] offset:0, count:3", - "│ └─Selection_13 3.00 cop[tikv] gt(test.tbl.c, 1)", - "│ └─IndexRangeScan_11 3.75 cop[tikv] table:tbl, index:b, c, range:(1,+inf], keep order:false", - "└─TableRowIDScan_12(Probe) 1.00 cop[tikv] table:tbl, keep order:false, stats:pseudo" + "IndexLookUp_15 1.00 root limit embedded(offset:2, count:1)", + "├─Limit_14(Build) 3.00 cop[tikv] offset:0, count:3", + "│ └─Selection_13 3.00 cop[tikv] gt(test.tbl.c, 1)", + "│ └─IndexRangeScan_11 3.75 cop[tikv] table:tbl, index:idx_b_c(b, c) range:(1,+inf], keep order:false", + "└─TableRowIDScan_12(Probe) 1.00 cop[tikv] table:tbl keep order:false, stats:pseudo" ] }, { "SQL": "explain select * from tbl use index(idx_b_c) where b > 1 and a > 1 limit 2,1", "Plan": [ - "Limit_9 1.00 root offset:2, count:1", - "└─IndexLookUp_15 3.00 root ", - " ├─IndexRangeScan_11(Build) 3.75 cop[tikv] table:tbl, index:b, c, range:(1,+inf], keep order:false", - " └─Limit_14(Probe) 3.00 cop[tikv] offset:0, count:3", - " └─Selection_13 3.00 cop[tikv] gt(test.tbl.a, 1)", - " └─TableRowIDScan_12 3.75 cop[tikv] table:tbl, keep order:false" + "Limit_9 1.00 root offset:2, count:1", + "└─IndexLookUp_15 3.00 root ", + " ├─IndexRangeScan_11(Build) 3.75 cop[tikv] table:tbl, index:idx_b_c(b, c) range:(1,+inf], keep order:false", + " └─Limit_14(Probe) 3.00 cop[tikv] offset:0, count:3", + " └─Selection_13 3.00 cop[tikv] gt(test.tbl.a, 1)", + " └─TableRowIDScan_12 3.75 cop[tikv] table:tbl keep order:false" ] } ] @@ -50,14 +50,14 @@ { "SQL": "explain select * from t t1 left join t t2 on t1.a=t2.a where from_unixtime(t2.b);", "Plan": [ - "HashLeftJoin_8 9990.00 root inner join, equal:[eq(test.t.a, test.t.a)]", - "├─Selection_13(Build) 7992.00 root from_unixtime(cast(test.t.b))", - "│ └─TableReader_16 9990.00 root data:Selection_15", - "│ └─Selection_15 9990.00 cop[tikv] not(isnull(test.t.a))", - "│ └─TableFullScan_14 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─TableReader_12(Probe) 9990.00 root data:Selection_11", - " └─Selection_11 9990.00 cop[tikv] not(isnull(test.t.a))", - " └─TableFullScan_10 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_8 9990.00 root inner join, equal:[eq(test.t.a, test.t.a)]", + "├─Selection_13(Build) 7992.00 root from_unixtime(cast(test.t.b))", + "│ └─TableReader_16 9990.00 root data:Selection_15", + "│ └─Selection_15 9990.00 cop[tikv] not(isnull(test.t.a))", + "│ └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader_12(Probe) 9990.00 root data:Selection_11", + " └─Selection_11 9990.00 cop[tikv] not(isnull(test.t.a))", + " └─TableFullScan_10 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] } ] @@ -68,12 +68,12 @@ { "SQL": "explain select * from t t1 left join t t2 on t1.a = t2.a where cast(t1.b as date) >= '2019-01-01'", "Plan": [ - "HashLeftJoin_8 10000.00 root left outer join, equal:[eq(test.t.a, test.t.a)]", - "├─TableReader_11(Build) 8000.00 root data:Selection_10", - "│ └─Selection_10 8000.00 cop[tikv] ge(cast(test.t.b), 2019-01-01 00:00:00.000000)", - "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_12", - " └─TableFullScan_12 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "HashJoin_8 10000.00 root left outer join, equal:[eq(test.t.a, test.t.a)]", + "├─TableReader_11(Build) 8000.00 root data:Selection_10", + "│ └─Selection_10 8000.00 cop[tikv] ge(cast(test.t.b), 2019-01-01 00:00:00.000000)", + "│ └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─TableReader_13(Probe) 10000.00 root data:TableFullScan_12", + " └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] } ] @@ -84,18 +84,18 @@ { "SQL": "explain (select max(a) from t) union (select min(a) from t)", "Plan": [ - "HashAgg_19 2.00 root group by:Column#5, funcs:firstrow(Column#5)->Column#5", - "└─Union_20 2.00 root ", - " ├─StreamAgg_26 1.00 root funcs:max(test.t.a)->Column#4", - " │ └─Limit_30 1.00 root offset:0, count:1", - " │ └─TableReader_40 1.00 root data:Limit_39", - " │ └─Limit_39 1.00 cop[tikv] offset:0, count:1", - " │ └─TableFullScan_38 1.00 cop[tikv] table:t, keep order:true, desc, stats:pseudo", - " └─StreamAgg_48 1.00 root funcs:min(test.t.a)->Column#2", - " └─Limit_52 1.00 root offset:0, count:1", - " └─TableReader_62 1.00 root data:Limit_61", - " └─Limit_61 1.00 cop[tikv] offset:0, count:1", - " └─TableFullScan_60 1.00 cop[tikv] table:t, keep order:true, stats:pseudo" + "HashAgg_19 2.00 root group by:Column#5, funcs:firstrow(Column#5)->Column#5", + "└─Union_20 2.00 root ", + " ├─StreamAgg_26 1.00 root funcs:max(test.t.a)->Column#4", + " │ └─Limit_30 1.00 root offset:0, count:1", + " │ └─TableReader_40 1.00 root data:Limit_39", + " │ └─Limit_39 1.00 cop[tikv] offset:0, count:1", + " │ └─TableFullScan_38 1.00 cop[tikv] table:t keep order:true, desc, stats:pseudo", + " └─StreamAgg_48 1.00 root funcs:min(test.t.a)->Column#2", + " └─Limit_52 1.00 root offset:0, count:1", + " └─TableReader_62 1.00 root data:Limit_61", + " └─Limit_61 1.00 cop[tikv] offset:0, count:1", + " └─TableFullScan_60 1.00 cop[tikv] table:t keep order:true, stats:pseudo" ] } ] @@ -106,34 +106,34 @@ { "SQL": "explain select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a and t1.c = t2.c", "Plan": [ - "IndexJoin_9 2.00 root inner join, inner:IndexLookUp_8, outer key:test.t1.a, inner key:test.t2.a, other cond:eq(test.t1.c, test.t2.c)", - "├─TableReader_19(Build) 1.00 root data:TableFullScan_18", - "│ └─TableFullScan_18 1.00 cop[tikv] table:t1, keep order:false", - "└─IndexLookUp_8(Probe) 2.00 root ", - " ├─IndexRangeScan_6(Build) 2.00 cop[tikv] table:t2, index:a, b, range: decided by [eq(test.t2.a, test.t1.a)], keep order:false", - " └─TableRowIDScan_7(Probe) 2.00 cop[tikv] table:t2, keep order:false" + "IndexJoin_9 2.00 root inner join, inner:IndexLookUp_8, outer key:test.t1.a, inner key:test.t2.a, other cond:eq(test.t1.c, test.t2.c)", + "├─TableReader_19(Build) 1.00 root data:TableFullScan_18", + "│ └─TableFullScan_18 1.00 cop[tikv] table:t1 keep order:false", + "└─IndexLookUp_8(Probe) 2.00 root ", + " ├─IndexRangeScan_6(Build) 2.00 cop[tikv] table:t2, index:PRIMARY(a, b) range: decided by [eq(test.t2.a, test.t1.a)], keep order:false", + " └─TableRowIDScan_7(Probe) 2.00 cop[tikv] table:t2 keep order:false" ] }, { "SQL": "explain select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a and t1.c <= t2.b", "Plan": [ - "IndexJoin_9 2.00 root inner join, inner:IndexLookUp_8, outer key:test.t1.a, inner key:test.t2.a, other cond:le(test.t1.c, test.t2.b)", - "├─TableReader_19(Build) 1.00 root data:TableFullScan_18", - "│ └─TableFullScan_18 1.00 cop[tikv] table:t1, keep order:false", - "└─IndexLookUp_8(Probe) 2.00 root ", - " ├─IndexRangeScan_6(Build) 2.00 cop[tikv] table:t2, index:a, b, range: decided by [eq(test.t2.a, test.t1.a) le(test.t1.c, test.t2.b)], keep order:false", - " └─TableRowIDScan_7(Probe) 2.00 cop[tikv] table:t2, keep order:false" + "IndexJoin_9 2.00 root inner join, inner:IndexLookUp_8, outer key:test.t1.a, inner key:test.t2.a, other cond:le(test.t1.c, test.t2.b)", + "├─TableReader_19(Build) 1.00 root data:TableFullScan_18", + "│ └─TableFullScan_18 1.00 cop[tikv] table:t1 keep order:false", + "└─IndexLookUp_8(Probe) 2.00 root ", + " ├─IndexRangeScan_6(Build) 2.00 cop[tikv] table:t2, index:PRIMARY(a, b) range: decided by [eq(test.t2.a, test.t1.a) le(test.t1.c, test.t2.b)], keep order:false", + " └─TableRowIDScan_7(Probe) 2.00 cop[tikv] table:t2 keep order:false" ] }, { "SQL": "explain select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a and t2.b = 1", "Plan": [ - "IndexJoin_9 1.00 root inner join, inner:IndexLookUp_8, outer key:test.t1.a, inner key:test.t2.a", - "├─TableReader_19(Build) 1.00 root data:TableFullScan_18", - "│ └─TableFullScan_18 1.00 cop[tikv] table:t1, keep order:false", - "└─IndexLookUp_8(Probe) 1.00 root ", - " ├─IndexRangeScan_6(Build) 1.00 cop[tikv] table:t2, index:a, b, range: decided by [eq(test.t2.a, test.t1.a) eq(test.t2.b, 1)], keep order:false", - " └─TableRowIDScan_7(Probe) 1.00 cop[tikv] table:t2, keep order:false" + "IndexJoin_9 1.00 root inner join, inner:IndexLookUp_8, outer key:test.t1.a, inner key:test.t2.a", + "├─TableReader_19(Build) 1.00 root data:TableFullScan_18", + "│ └─TableFullScan_18 1.00 cop[tikv] table:t1 keep order:false", + "└─IndexLookUp_8(Probe) 1.00 root ", + " ├─IndexRangeScan_6(Build) 1.00 cop[tikv] table:t2, index:PRIMARY(a, b) range: decided by [eq(test.t2.a, test.t1.a) eq(test.t2.b, 1)], keep order:false", + " └─TableRowIDScan_7(Probe) 1.00 cop[tikv] table:t2 keep order:false" ] } ] @@ -144,14 +144,14 @@ { "SQL": "explain select * from t order by a", "Result": [ - "Sort_8 10005.00 root test.t.a:asc", - "└─Union_11 10005.00 root ", - " ├─TableReader_13 10000.00 root data:TableFullScan_12", - " │ └─TableFullScan_12 10000.00 cop[tikv] table:t, partition:p0, keep order:false, stats:pseudo", - " ├─TableReader_15 1.00 root data:TableFullScan_14", - " │ └─TableFullScan_14 1.00 cop[tikv] table:t, partition:p1, keep order:false", - " └─TableReader_17 4.00 root data:TableFullScan_16", - " └─TableFullScan_16 4.00 cop[tikv] table:t, partition:p2, keep order:false" + "Sort_8 10005.00 root test.t.a:asc", + "└─Union_11 10005.00 root ", + " ├─TableReader_13 10000.00 root data:TableFullScan_12", + " │ └─TableFullScan_12 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo", + " ├─TableReader_15 1.00 root data:TableFullScan_14", + " │ └─TableFullScan_14 1.00 cop[tikv] table:t, partition:p1 keep order:false", + " └─TableReader_17 4.00 root data:TableFullScan_16", + " └─TableFullScan_16 4.00 cop[tikv] table:t, partition:p2 keep order:false" ] }, { @@ -167,19 +167,19 @@ { "SQL": "explain select * from t order by a limit 3", "Result": [ - "TopN_16 3.00 root test.t.a:asc, offset:0, count:3", - "└─Union_20 7.00 root ", - " ├─TopN_21 3.00 root test.t.a:asc, offset:0, count:3", - " │ └─TableReader_29 3.00 root data:TopN_28", - " │ └─TopN_28 3.00 cop[tikv] test.t.a:asc, offset:0, count:3", - " │ └─TableFullScan_27 10000.00 cop[tikv] table:t, partition:p0, keep order:false, stats:pseudo", - " ├─TopN_34 1.00 root test.t.a:asc, offset:0, count:3", - " │ └─TableReader_42 1.00 root data:TableFullScan_41", - " │ └─TableFullScan_41 1.00 cop[tikv] table:t, partition:p1, keep order:false", - " └─TopN_43 3.00 root test.t.a:asc, offset:0, count:3", - " └─TableReader_51 3.00 root data:TopN_50", - " └─TopN_50 3.00 cop[tikv] test.t.a:asc, offset:0, count:3", - " └─TableFullScan_49 4.00 cop[tikv] table:t, partition:p2, keep order:false" + "TopN_16 3.00 root test.t.a:asc, offset:0, count:3", + "└─Union_20 7.00 root ", + " ├─TopN_21 3.00 root test.t.a:asc, offset:0, count:3", + " │ └─TableReader_29 3.00 root data:TopN_28", + " │ └─TopN_28 3.00 cop[tikv] test.t.a:asc, offset:0, count:3", + " │ └─TableFullScan_27 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo", + " ├─TopN_34 1.00 root test.t.a:asc, offset:0, count:3", + " │ └─TableReader_42 1.00 root data:TableFullScan_41", + " │ └─TableFullScan_41 1.00 cop[tikv] table:t, partition:p1 keep order:false", + " └─TopN_43 3.00 root test.t.a:asc, offset:0, count:3", + " └─TableReader_51 3.00 root data:TopN_50", + " └─TopN_50 3.00 cop[tikv] test.t.a:asc, offset:0, count:3", + " └─TableFullScan_49 4.00 cop[tikv] table:t, partition:p2 keep order:false" ] }, { @@ -198,10 +198,10 @@ { "SQL": "explain select /*+ USE_INDEX_MERGE(t, a, b) */ * from t where a = 1 or b = 2", "Plan": [ - "IndexMerge_8 2.00 root ", - "├─IndexRangeScan_5 1.00 cop[tikv] table:t, index:a, range:[1,1], keep order:false, stats:pseudo", - "├─IndexRangeScan_6 1.00 cop[tikv] table:t, index:b, range:[2,2], keep order:false, stats:pseudo", - "└─TableRowIDScan_7 2.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "IndexMerge_8 2.00 root ", + "├─IndexRangeScan_5(Build) 1.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false, stats:pseudo", + "├─IndexRangeScan_6(Build) 1.00 cop[tikv] table:t, index:b(b) range:[2,2], keep order:false, stats:pseudo", + "└─TableRowIDScan_7(Probe) 2.00 cop[tikv] table:t keep order:false, stats:pseudo" ] } ] @@ -212,91 +212,91 @@ { "SQL": "desc select avg(a) from t", "Plan": [ - "StreamAgg_24 1.00 root funcs:avg(Column#7, Column#8)->Column#4", - "└─TableReader_25 1.00 root data:StreamAgg_8", - " └─StreamAgg_8 1.00 cop[tiflash] funcs:count(test.t.a)->Column#7, funcs:sum(test.t.a)->Column#8", - " └─TableFullScan_22 10000.00 cop[tiflash] table:t, keep order:false, stats:pseudo" + "StreamAgg_24 1.00 root funcs:avg(Column#7, Column#8)->Column#4", + "└─TableReader_25 1.00 root data:StreamAgg_8", + " └─StreamAgg_8 1.00 cop[tiflash] funcs:count(test.t.a)->Column#7, funcs:sum(test.t.a)->Column#8", + " └─TableFullScan_22 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "desc select /*+ read_from_storage(tiflash[t]) */ avg(a) from t", "Plan": [ - "StreamAgg_16 1.00 root funcs:avg(Column#7, Column#8)->Column#4", - "└─TableReader_17 1.00 root data:StreamAgg_8", - " └─StreamAgg_8 1.00 cop[tiflash] funcs:count(test.t.a)->Column#7, funcs:sum(test.t.a)->Column#8", - " └─TableFullScan_15 10000.00 cop[tiflash] table:t, keep order:false, stats:pseudo" + "StreamAgg_16 1.00 root funcs:avg(Column#7, Column#8)->Column#4", + "└─TableReader_17 1.00 root data:StreamAgg_8", + " └─StreamAgg_8 1.00 cop[tiflash] funcs:count(test.t.a)->Column#7, funcs:sum(test.t.a)->Column#8", + " └─TableFullScan_15 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "desc select /*+ read_from_storage(tiflash[t]) */ sum(a) from t", "Plan": [ - "StreamAgg_16 1.00 root funcs:sum(Column#6)->Column#4", - "└─TableReader_17 1.00 root data:StreamAgg_8", - " └─StreamAgg_8 1.00 cop[tiflash] funcs:sum(test.t.a)->Column#6", - " └─TableFullScan_15 10000.00 cop[tiflash] table:t, keep order:false, stats:pseudo" + "StreamAgg_16 1.00 root funcs:sum(Column#6)->Column#4", + "└─TableReader_17 1.00 root data:StreamAgg_8", + " └─StreamAgg_8 1.00 cop[tiflash] funcs:sum(test.t.a)->Column#6", + " └─TableFullScan_15 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "desc select /*+ read_from_storage(tiflash[t]) */ sum(a+1) from t", "Plan": [ - "StreamAgg_16 1.00 root funcs:sum(Column#6)->Column#4", - "└─TableReader_17 1.00 root data:StreamAgg_8", - " └─StreamAgg_8 1.00 cop[tiflash] funcs:sum(plus(test.t.a, 1))->Column#6", - " └─TableFullScan_15 10000.00 cop[tiflash] table:t, keep order:false, stats:pseudo" + "StreamAgg_16 1.00 root funcs:sum(Column#6)->Column#4", + "└─TableReader_17 1.00 root data:StreamAgg_8", + " └─StreamAgg_8 1.00 cop[tiflash] funcs:sum(plus(test.t.a, 1))->Column#6", + " └─TableFullScan_15 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "desc select /*+ read_from_storage(tiflash[t]) */ sum(isnull(a)) from t", "Plan": [ - "StreamAgg_16 1.00 root funcs:sum(Column#6)->Column#4", - "└─TableReader_17 1.00 root data:StreamAgg_8", - " └─StreamAgg_8 1.00 cop[tiflash] funcs:sum(isnull(test.t.a))->Column#6", - " └─TableFullScan_15 10000.00 cop[tiflash] table:t, keep order:false, stats:pseudo" + "StreamAgg_16 1.00 root funcs:sum(Column#6)->Column#4", + "└─TableReader_17 1.00 root data:StreamAgg_8", + " └─StreamAgg_8 1.00 cop[tiflash] funcs:sum(isnull(test.t.a))->Column#6", + " └─TableFullScan_15 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "desc select * from tt where (tt.a > 1 and tt.a < 20) or (tt.a >= 30 and tt.a < 55)", "Plan": [ - "TableReader_8 44.00 root data:TableRangeScan_7", - "└─TableRangeScan_7 44.00 cop[tiflash] table:tt, range:(1,20), [30,55), keep order:false, stats:pseudo" + "TableReader_8 44.00 root data:TableRangeScan_7", + "└─TableRangeScan_7 44.00 cop[tiflash] table:tt range:(1,20), [30,55), keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "desc select /*+ read_from_storage(tiflash[tt]) */ * from tt where (tt.a > 1 and tt.a < 20) or (tt.a >= 30 and tt.a < 55)", "Plan": [ - "TableReader_6 44.00 root data:TableRangeScan_5", - "└─TableRangeScan_5 44.00 cop[tiflash] table:tt, range:(1,20), [30,55), keep order:false, stats:pseudo" + "TableReader_6 44.00 root data:TableRangeScan_5", + "└─TableRangeScan_5 44.00 cop[tiflash] table:tt range:(1,20), [30,55), keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "desc select * from ttt order by ttt.a desc", "Plan": [ - "TableReader_13 10000.00 root data:TableFullScan_12", - "└─TableFullScan_12 10000.00 cop[tikv] table:ttt, keep order:true, desc, stats:pseudo" + "TableReader_13 10000.00 root data:TableFullScan_12", + "└─TableFullScan_12 10000.00 cop[tikv] table:ttt keep order:true, desc, stats:pseudo" ], "Warn": null }, { "SQL": "desc select /*+ read_from_storage(tiflash[ttt]) */ * from ttt order by ttt.a desc", "Plan": [ - "Sort_4 10000.00 root test.ttt.a:desc", - "└─TableReader_8 10000.00 root data:TableFullScan_7", - " └─TableFullScan_7 10000.00 cop[tiflash] table:ttt, keep order:false, stats:pseudo" + "Sort_4 10000.00 root test.ttt.a:desc", + "└─TableReader_8 10000.00 root data:TableFullScan_7", + " └─TableFullScan_7 10000.00 cop[tiflash] table:ttt keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "desc select /*+ read_from_storage(tiflash[ttt]) */ * from ttt order by ttt.a", "Plan": [ - "TableReader_11 10000.00 root data:TableFullScan_10", - "└─TableFullScan_10 10000.00 cop[tiflash] table:ttt, keep order:true, stats:pseudo" + "TableReader_11 10000.00 root data:TableFullScan_10", + "└─TableFullScan_10 10000.00 cop[tiflash] table:ttt keep order:true, stats:pseudo" ], "Warn": null } @@ -308,10 +308,10 @@ { "SQL": "desc select /*+ read_from_storage(tikv[t], tiflash[t]) */ avg(a) from t", "Plan": [ - "StreamAgg_20 1.00 root funcs:avg(Column#7, Column#8)->Column#4", - "└─IndexReader_21 1.00 root index:StreamAgg_8", - " └─StreamAgg_8 1.00 cop[tikv] funcs:avg(test.t.a)->Column#7", - " └─IndexFullScan_19 10000.00 cop[tikv] table:t, index:a, keep order:false, stats:pseudo" + "StreamAgg_20 1.00 root funcs:avg(Column#7, Column#8)->Column#4", + "└─IndexReader_21 1.00 root index:StreamAgg_8", + " └─StreamAgg_8 1.00 cop[tikv] funcs:avg(test.t.a)->Column#7", + " └─IndexFullScan_19 10000.00 cop[tikv] table:t, index:ia(a) keep order:false, stats:pseudo" ], "Warn": [ "[planner:1815]Storage hints are conflict, you can only specify one storage type of table test.t" @@ -320,20 +320,20 @@ { "SQL": "desc select /*+ read_from_storage(tikv[t]) */ avg(a) from t", "Plan": [ - "StreamAgg_20 1.00 root funcs:avg(Column#7, Column#8)->Column#4", - "└─IndexReader_21 1.00 root index:StreamAgg_8", - " └─StreamAgg_8 1.00 cop[tikv] funcs:avg(test.t.a)->Column#7", - " └─IndexFullScan_19 10000.00 cop[tikv] table:t, index:a, keep order:false, stats:pseudo" + "StreamAgg_20 1.00 root funcs:avg(Column#7, Column#8)->Column#4", + "└─IndexReader_21 1.00 root index:StreamAgg_8", + " └─StreamAgg_8 1.00 cop[tikv] funcs:avg(test.t.a)->Column#7", + " └─IndexFullScan_19 10000.00 cop[tikv] table:t, index:ia(a) keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "desc select /*+ read_from_storage(tiflash[t]) */ avg(a) from t", "Plan": [ - "StreamAgg_20 1.00 root funcs:avg(Column#7, Column#8)->Column#4", - "└─IndexReader_21 1.00 root index:StreamAgg_8", - " └─StreamAgg_8 1.00 cop[tikv] funcs:avg(test.t.a)->Column#7", - " └─IndexFullScan_19 10000.00 cop[tikv] table:t, index:a, keep order:false, stats:pseudo" + "StreamAgg_20 1.00 root funcs:avg(Column#7, Column#8)->Column#4", + "└─IndexReader_21 1.00 root index:StreamAgg_8", + " └─StreamAgg_8 1.00 cop[tikv] funcs:avg(test.t.a)->Column#7", + " └─IndexFullScan_19 10000.00 cop[tikv] table:t, index:ia(a) keep order:false, stats:pseudo" ], "Warn": [ "[planner:1815]No available path for table test.t with the store type tiflash of the hint /*+ read_from_storage */, please check the status of the table replica and variable value of tidb_isolation_read_engines(map[0:{}])" @@ -347,18 +347,18 @@ { "SQL": "desc select t1.b from t t1 where t1.b in (select t2.a from t t2 order by t1.a+t2.a limit 1)", "Plan": [ - "Projection_11 9990.00 root test.t.b", - "└─Apply_13 9990.00 root semi join, equal:[eq(test.t.b, test.t.a)]", - " ├─TableReader_16(Build) 9990.00 root data:Selection_15", - " │ └─Selection_15 9990.00 cop[tikv] not(isnull(test.t.b))", - " │ └─TableFullScan_14 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - " └─Selection_17(Probe) 0.80 root not(isnull(test.t.a))", - " └─Projection_26 1.00 root test.t.a", - " └─TopN_18 1.00 root Column#7:asc, offset:0, count:1", - " └─Projection_27 1.00 root test.t.a, plus(test.t.a, test.t.a)->Column#7", - " └─TableReader_23 1.00 root data:TopN_22", - " └─TopN_22 1.00 cop[tikv] plus(test.t.a, test.t.a):asc, offset:0, count:1", - " └─TableFullScan_21 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo" + "Projection_11 9990.00 root test.t.b", + "└─Apply_13 9990.00 root semi join, equal:[eq(test.t.b, test.t.a)]", + " ├─TableReader_16(Build) 9990.00 root data:Selection_15", + " │ └─Selection_15 9990.00 cop[tikv] not(isnull(test.t.b))", + " │ └─TableFullScan_14 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + " └─Selection_17(Probe) 0.80 root not(isnull(test.t.a))", + " └─Projection_26 1.00 root test.t.a", + " └─TopN_18 1.00 root Column#7:asc, offset:0, count:1", + " └─Projection_27 1.00 root test.t.a, plus(test.t.a, test.t.a)->Column#7", + " └─TableReader_23 1.00 root data:TopN_22", + " └─TopN_22 1.00 cop[tikv] plus(test.t.a, test.t.a):asc, offset:0, count:1", + " └─TableFullScan_21 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] } ] @@ -369,23 +369,23 @@ { "SQL": "desc select /*+ TIDB_INLJ(t2)*/ * from t1, t2 where t1.a = t2.a and t1.b = t2.b", "Plan": [ - "IndexJoin_12 12487.50 root inner join, inner:TableReader_11, outer key:test.t1.a, inner key:test.t2.a, other cond:eq(test.t1.b, test.t2.b)", - "├─IndexReader_21(Build) 9990.00 root index:IndexFullScan_20", - "│ └─IndexFullScan_20 9990.00 cop[tikv] table:t1, index:b, keep order:false, stats:pseudo", - "└─TableReader_11(Probe) 1.00 root data:Selection_10", - " └─Selection_10 1.00 cop[tikv] not(isnull(test.t2.b))", - " └─TableRangeScan_9 1.00 cop[tikv] table:t2, range: decided by [test.t1.a], keep order:false, stats:pseudo" + "IndexJoin_12 12487.50 root inner join, inner:TableReader_11, outer key:test.t1.a, inner key:test.t2.a, other cond:eq(test.t1.b, test.t2.b)", + "├─IndexReader_21(Build) 9990.00 root index:IndexFullScan_20", + "│ └─IndexFullScan_20 9990.00 cop[tikv] table:t1, index:idx_t1_b(b) keep order:false, stats:pseudo", + "└─TableReader_11(Probe) 1.00 root data:Selection_10", + " └─Selection_10 1.00 cop[tikv] not(isnull(test.t2.b))", + " └─TableRangeScan_9 1.00 cop[tikv] table:t2 range: decided by [test.t1.a], keep order:false, stats:pseudo" ] }, { "SQL": "desc select /*+ TIDB_INLJ(t2)*/ * from t1, t2 where t1.a = t2.a and t1.b = t2.a and t1.b = t2.b", "Plan": [ - "IndexJoin_12 12487.50 root inner join, inner:TableReader_11, outer key:test.t1.a, test.t1.b, inner key:test.t2.a, test.t2.a, other cond:eq(test.t1.b, test.t2.b)", - "├─IndexReader_21(Build) 9990.00 root index:IndexFullScan_20", - "│ └─IndexFullScan_20 9990.00 cop[tikv] table:t1, index:b, keep order:false, stats:pseudo", - "└─TableReader_11(Probe) 1.00 root data:Selection_10", - " └─Selection_10 1.00 cop[tikv] not(isnull(test.t2.b))", - " └─TableRangeScan_9 1.00 cop[tikv] table:t2, range: decided by [test.t1.a test.t1.b], keep order:false, stats:pseudo" + "IndexJoin_12 12487.50 root inner join, inner:TableReader_11, outer key:test.t1.a, test.t1.b, inner key:test.t2.a, test.t2.a, other cond:eq(test.t1.b, test.t2.b)", + "├─IndexReader_21(Build) 9990.00 root index:IndexFullScan_20", + "│ └─IndexFullScan_20 9990.00 cop[tikv] table:t1, index:idx_t1_b(b) keep order:false, stats:pseudo", + "└─TableReader_11(Probe) 1.00 root data:Selection_10", + " └─Selection_10 1.00 cop[tikv] not(isnull(test.t2.b))", + " └─TableRangeScan_9 1.00 cop[tikv] table:t2 range: decided by [test.t1.a test.t1.b], keep order:false, stats:pseudo" ] } ] diff --git a/planner/core/testdata/plan_normalized_suite_out.json b/planner/core/testdata/plan_normalized_suite_out.json index 9bd8458ca8d1b..99ea8dc798086 100644 --- a/planner/core/testdata/plan_normalized_suite_out.json +++ b/planner/core/testdata/plan_normalized_suite_out.json @@ -39,7 +39,7 @@ "SQL": "select * from t1 where b=1", "Plan": [ " IndexLookUp_10 root ", - " ├─IndexScan_8 cop table:t1, index:b, range:[?,?], keep order:false", + " ├─IndexScan_8 cop table:t1, index:b(b), range:[?,?], keep order:false", " └─TableScan_9 cop table:t1, keep order:false" ] }, @@ -48,7 +48,7 @@ "Plan": [ " Projection_4 root plus(test.t1.a, ?), plus(test.t1.b, ?)", " └─IndexReader_6 root index:IndexRangeScan_5", - " └─IndexScan_5 cop table:t1, index:b, range:[?,?], keep order:false" + " └─IndexScan_5 cop table:t1, index:b(b), range:[?,?], keep order:false" ] }, { @@ -101,7 +101,7 @@ { "SQL": "SELECT /*+ TIDB_HJ(t1, t2) */ * from t1, t2 where t1.a = t2.a and t1.c>1;", "Plan": [ - " HashRightJoin_29 root inner join, equal:eq(test.t1.a, test.t2.a)", + " HashJoin_29 root inner join, equal:eq(test.t1.a, test.t2.a)", " ├─TableReader_32 root data:Selection_31", " │ └─Selection_31 cop gt(test.t1.c, ?)", " │ └─TableScan_30 cop table:t1, range:[?,?], keep order:false", @@ -112,7 +112,7 @@ { "SQL": "SELECT /*+ TIDB_HJ(t1, t2) */ * from t1, t2 where t1.a = t2.a and t1.c>1;", "Plan": [ - " HashRightJoin_29 root inner join, equal:eq(test.t1.a, test.t2.a)", + " HashJoin_29 root inner join, equal:eq(test.t1.a, test.t2.a)", " ├─TableReader_32 root data:Selection_31", " │ └─Selection_31 cop gt(test.t1.c, ?)", " │ └─TableScan_30 cop table:t1, range:[?,?], keep order:false", @@ -170,7 +170,7 @@ "SQL": "delete from t1 where a>0 and b=1 and c!=2", "Plan": [ " IndexLookUp_12 root ", - " ├─IndexScan_9 cop table:t1, index:b, range:[?,?], keep order:false", + " ├─IndexScan_9 cop table:t1, index:b(b), range:[?,?], keep order:false", " └─Selection_11 cop ne(test.t1.c, ?)", " └─TableScan_10 cop table:t1, keep order:false" ] diff --git a/planner/core/testdata/plan_suite_in.json b/planner/core/testdata/plan_suite_in.json index c4a4acc6f37fd..6647be56a14e8 100644 --- a/planner/core/testdata/plan_suite_in.json +++ b/planner/core/testdata/plan_suite_in.json @@ -516,7 +516,10 @@ "cases": [ "select /*+ INL_JOIN(t1) */ * from t1 join t2 on t1.a = t2.a;", "select /*+ INL_HASH_JOIN(t1) */ * from t1 join t2 on t1.a = t2.a;", - "select /*+ INL_MERGE_JOIN(t1) */ * from t1 join t2 on t1.a = t2.a;" + "select /*+ INL_MERGE_JOIN(t1) */ * from t1 join t2 on t1.a = t2.a;", + // Issue 15484 + "select /*+ inl_merge_join(t2) */ t1.a, t2.a from t t1 left join t t2 use index(g_2) on t1.g=t2.g", + "select /*+inl_merge_join(t2)*/ t1.a, t2.a from t t1 left join t t2 use index(g_2) on t1.g=t2.g order by t1.a" ] }, { diff --git a/planner/core/testdata/plan_suite_out.json b/planner/core/testdata/plan_suite_out.json index 6ba675d4faf10..fdb4cfeacfcdd 100644 --- a/planner/core/testdata/plan_suite_out.json +++ b/planner/core/testdata/plan_suite_out.json @@ -1289,13 +1289,13 @@ "explain select /*+ TIDB_INLJ(t2) */ * from t t1, t t2 where t1.a = t2.a" ], "Plan": [ - "IndexJoin_12 12500.00 root inner join, inner:UnionScan_11, outer key:test.t.a, inner key:test.t.a", - "├─UnionScan_15(Build) 10000.00 root ", - "│ └─TableReader_17 10000.00 root data:TableFullScan_16", - "│ └─TableFullScan_16 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo", - "└─UnionScan_11(Probe) 1.00 root ", - " └─TableReader_10 1.00 root data:TableRangeScan_9", - " └─TableRangeScan_9 1.00 cop[tikv] table:t2, range: decided by [test.t.a], keep order:false, stats:pseudo" + "IndexJoin_12 12500.00 root inner join, inner:UnionScan_11, outer key:test.t.a, inner key:test.t.a", + "├─UnionScan_15(Build) 10000.00 root ", + "│ └─TableReader_17 10000.00 root data:TableFullScan_16", + "│ └─TableFullScan_16 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + "└─UnionScan_11(Probe) 1.00 root ", + " └─TableReader_10 1.00 root data:TableRangeScan_9", + " └─TableRangeScan_9 1.00 cop[tikv] table:t2 range: decided by [test.t.a], keep order:false, stats:pseudo" ] }, { @@ -1304,14 +1304,14 @@ "explain select /*+ TIDB_INLJ(t2) */ * from t t1, t t2 where t1.a = t2.b" ], "Plan": [ - "HashLeftJoin_15 12487.50 root inner join, equal:[eq(test.t.a, test.t.b)]", - "├─UnionScan_17(Build) 9990.00 root not(isnull(test.t.b))", - "│ └─TableReader_20 9990.00 root data:Selection_19", - "│ └─Selection_19 9990.00 cop[tikv] not(isnull(test.t.b))", - "│ └─TableFullScan_18 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─UnionScan_21(Probe) 10000.00 root ", - " └─TableReader_23 10000.00 root data:TableFullScan_22", - " └─TableFullScan_22 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_15 12487.50 root inner join, equal:[eq(test.t.a, test.t.b)]", + "├─UnionScan_17(Build) 9990.00 root not(isnull(test.t.b))", + "│ └─TableReader_20 9990.00 root data:Selection_19", + "│ └─Selection_19 9990.00 cop[tikv] not(isnull(test.t.b))", + "│ └─TableFullScan_18 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─UnionScan_21(Probe) 10000.00 root ", + " └─TableReader_23 10000.00 root data:TableFullScan_22", + " └─TableFullScan_22 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { @@ -1320,14 +1320,14 @@ "explain select /*+ TIDB_INLJ(t2) */ t1.a , t2.b from t t1, t t2 where t1.a = t2.b" ], "Plan": [ - "HashLeftJoin_15 12487.50 root inner join, equal:[eq(test.t.a, test.t.b)]", - "├─UnionScan_17(Build) 9990.00 root not(isnull(test.t.b))", - "│ └─TableReader_20 9990.00 root data:Selection_19", - "│ └─Selection_19 9990.00 cop[tikv] not(isnull(test.t.b))", - "│ └─TableFullScan_18 10000.00 cop[tikv] table:t2, keep order:false, stats:pseudo", - "└─UnionScan_21(Probe) 10000.00 root ", - " └─TableReader_23 10000.00 root data:TableFullScan_22", - " └─TableFullScan_22 10000.00 cop[tikv] table:t1, keep order:false, stats:pseudo" + "HashJoin_15 12487.50 root inner join, equal:[eq(test.t.a, test.t.b)]", + "├─UnionScan_17(Build) 9990.00 root not(isnull(test.t.b))", + "│ └─TableReader_20 9990.00 root data:Selection_19", + "│ └─Selection_19 9990.00 cop[tikv] not(isnull(test.t.b))", + "│ └─TableFullScan_18 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─UnionScan_21(Probe) 10000.00 root ", + " └─TableReader_23 10000.00 root data:TableFullScan_22", + " └─TableFullScan_22 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { @@ -1336,21 +1336,21 @@ "explain select /*+ TIDB_INLJ(t2) */ * from tt t1, tt t2 where t1.a = t2.a" ], "Plan": [ - "HashLeftJoin_19 25000.00 root inner join, equal:[eq(test.tt.a, test.tt.a)]", - "├─Union_28(Build) 20000.00 root ", - "│ ├─UnionScan_29 10000.00 root ", - "│ │ └─TableReader_31 10000.00 root data:TableFullScan_30", - "│ │ └─TableFullScan_30 10000.00 cop[tikv] table:t2, partition:p0, keep order:false, stats:pseudo", - "│ └─UnionScan_32 10000.00 root ", - "│ └─TableReader_34 10000.00 root data:TableFullScan_33", - "│ └─TableFullScan_33 10000.00 cop[tikv] table:t2, partition:p1, keep order:false, stats:pseudo", - "└─Union_21(Probe) 20000.00 root ", - " ├─UnionScan_22 10000.00 root ", - " │ └─TableReader_24 10000.00 root data:TableFullScan_23", - " │ └─TableFullScan_23 10000.00 cop[tikv] table:t1, partition:p0, keep order:false, stats:pseudo", - " └─UnionScan_25 10000.00 root ", - " └─TableReader_27 10000.00 root data:TableFullScan_26", - " └─TableFullScan_26 10000.00 cop[tikv] table:t1, partition:p1, keep order:false, stats:pseudo" + "HashJoin_19 25000.00 root inner join, equal:[eq(test.tt.a, test.tt.a)]", + "├─Union_28(Build) 20000.00 root ", + "│ ├─UnionScan_29 10000.00 root ", + "│ │ └─TableReader_31 10000.00 root data:TableFullScan_30", + "│ │ └─TableFullScan_30 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo", + "│ └─UnionScan_32 10000.00 root ", + "│ └─TableReader_34 10000.00 root data:TableFullScan_33", + "│ └─TableFullScan_33 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo", + "└─Union_21(Probe) 20000.00 root ", + " ├─UnionScan_22 10000.00 root ", + " │ └─TableReader_24 10000.00 root data:TableFullScan_23", + " │ └─TableFullScan_23 10000.00 cop[tikv] table:t1, partition:p0 keep order:false, stats:pseudo", + " └─UnionScan_25 10000.00 root ", + " └─TableReader_27 10000.00 root data:TableFullScan_26", + " └─TableFullScan_26 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo" ] } ] @@ -1378,6 +1378,14 @@ { "SQL": "select /*+ INL_MERGE_JOIN(t1) */ * from t1 join t2 on t1.a = t2.a;", "Plan": "IndexMergeJoin{IndexLookUp(Index(t1.idx_a)[[NULL,+inf]]->Sel([not(isnull(test.t1.a))]), Table(t1))->Projection->TableReader(Table(t2)->Sel([not(isnull(test.t2.a))]))}(test.t2.a,test.t1.a)" + }, + { + "SQL": "select /*+ inl_merge_join(t2) */ t1.a, t2.a from t t1 left join t t2 use index(g_2) on t1.g=t2.g", + "Plan": "IndexMergeJoin{IndexReader(Index(t.g_3)[[NULL,+inf]])->IndexReader(Index(t.g_2)[[NULL,+inf]]->Sel([not(isnull(test.t.g))]))}(test.t.g,test.t.g)" + }, + { + "SQL": "select /*+inl_merge_join(t2)*/ t1.a, t2.a from t t1 left join t t2 use index(g_2) on t1.g=t2.g order by t1.a", + "Plan": "IndexMergeJoin{IndexReader(Index(t.g_3)[[NULL,+inf]])->IndexReader(Index(t.g_2)[[NULL,+inf]]->Sel([not(isnull(test.t.g))]))}(test.t.g,test.t.g)->Sort" } ] }, @@ -1434,12 +1442,12 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by t1.a", "Plan": [ - "Projection_20 12487.50 root test.t.a", - "└─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", - " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:b, keep order:true, stats:pseudo", - " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", - " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:a, keep order:true, stats:pseudo" + "Projection_20 12487.50 root test.t.a", + "└─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", + " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo", + " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", + " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo" ], "Result": [ "1", @@ -1450,14 +1458,14 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by t1.a+1", "Plan": [ - "Projection_24 12487.50 root test.t.a", - "└─Projection_23 12487.50 root test.t.a, plus(test.t.a, 1)->Column#7", - " └─Projection_20 12487.50 root test.t.a", - " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", - " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:b, keep order:true, stats:pseudo", - " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", - " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:a, keep order:true, stats:pseudo" + "Projection_24 12487.50 root test.t.a", + "└─Projection_23 12487.50 root test.t.a, plus(test.t.a, 1)->Column#7", + " └─Projection_20 12487.50 root test.t.a", + " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", + " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo", + " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", + " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo" ], "Result": [ "1", @@ -1468,14 +1476,14 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by t1.a-1", "Plan": [ - "Projection_24 12487.50 root test.t.a", - "└─Projection_23 12487.50 root test.t.a, minus(test.t.a, 1)->Column#7", - " └─Projection_20 12487.50 root test.t.a", - " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", - " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:b, keep order:true, stats:pseudo", - " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", - " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:a, keep order:true, stats:pseudo" + "Projection_24 12487.50 root test.t.a", + "└─Projection_23 12487.50 root test.t.a, minus(test.t.a, 1)->Column#7", + " └─Projection_20 12487.50 root test.t.a", + " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", + " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo", + " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", + " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo" ], "Result": [ "1", @@ -1486,14 +1494,14 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by -t1.a", "Plan": [ - "Projection_32 12487.50 root test.t.a", - "└─Projection_31 12487.50 root test.t.a, unaryminus(test.t.a)->Column#7", - " └─Projection_20 12487.50 root test.t.a", - " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_26(Build) 9990.00 root index:IndexFullScan_25", - " │ └─IndexFullScan_25 9990.00 cop[tikv] table:t2, index:b, keep order:true, desc, stats:pseudo", - " └─IndexReader_24(Probe) 9990.00 root index:IndexFullScan_23", - " └─IndexFullScan_23 9990.00 cop[tikv] table:t1, index:a, keep order:true, desc, stats:pseudo" + "Projection_32 12487.50 root test.t.a", + "└─Projection_31 12487.50 root test.t.a, unaryminus(test.t.a)->Column#7", + " └─Projection_20 12487.50 root test.t.a", + " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_26(Build) 9990.00 root index:IndexFullScan_25", + " │ └─IndexFullScan_25 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, desc, stats:pseudo", + " └─IndexReader_24(Probe) 9990.00 root index:IndexFullScan_23", + " └─IndexFullScan_23 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, desc, stats:pseudo" ], "Result": [ "2", @@ -1504,14 +1512,14 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by -t1.a+3", "Plan": [ - "Projection_32 12487.50 root test.t.a", - "└─Projection_31 12487.50 root test.t.a, plus(unaryminus(test.t.a), 3)->Column#7", - " └─Projection_20 12487.50 root test.t.a", - " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_26(Build) 9990.00 root index:IndexFullScan_25", - " │ └─IndexFullScan_25 9990.00 cop[tikv] table:t2, index:b, keep order:true, desc, stats:pseudo", - " └─IndexReader_24(Probe) 9990.00 root index:IndexFullScan_23", - " └─IndexFullScan_23 9990.00 cop[tikv] table:t1, index:a, keep order:true, desc, stats:pseudo" + "Projection_32 12487.50 root test.t.a", + "└─Projection_31 12487.50 root test.t.a, plus(unaryminus(test.t.a), 3)->Column#7", + " └─Projection_20 12487.50 root test.t.a", + " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_26(Build) 9990.00 root index:IndexFullScan_25", + " │ └─IndexFullScan_25 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, desc, stats:pseudo", + " └─IndexReader_24(Probe) 9990.00 root index:IndexFullScan_23", + " └─IndexFullScan_23 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, desc, stats:pseudo" ], "Result": [ "2", @@ -1522,14 +1530,14 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1+t1.a", "Plan": [ - "Projection_24 12487.50 root test.t.a", - "└─Projection_23 12487.50 root test.t.a, plus(1, test.t.a)->Column#7", - " └─Projection_20 12487.50 root test.t.a", - " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", - " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:b, keep order:true, stats:pseudo", - " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", - " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:a, keep order:true, stats:pseudo" + "Projection_24 12487.50 root test.t.a", + "└─Projection_23 12487.50 root test.t.a, plus(1, test.t.a)->Column#7", + " └─Projection_20 12487.50 root test.t.a", + " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", + " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo", + " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", + " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo" ], "Result": [ "1", @@ -1540,14 +1548,14 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1-t1.a", "Plan": [ - "Projection_32 12487.50 root test.t.a", - "└─Projection_31 12487.50 root test.t.a, minus(1, test.t.a)->Column#7", - " └─Projection_20 12487.50 root test.t.a", - " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_26(Build) 9990.00 root index:IndexFullScan_25", - " │ └─IndexFullScan_25 9990.00 cop[tikv] table:t2, index:b, keep order:true, desc, stats:pseudo", - " └─IndexReader_24(Probe) 9990.00 root index:IndexFullScan_23", - " └─IndexFullScan_23 9990.00 cop[tikv] table:t1, index:a, keep order:true, desc, stats:pseudo" + "Projection_32 12487.50 root test.t.a", + "└─Projection_31 12487.50 root test.t.a, minus(1, test.t.a)->Column#7", + " └─Projection_20 12487.50 root test.t.a", + " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_26(Build) 9990.00 root index:IndexFullScan_25", + " │ └─IndexFullScan_25 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, desc, stats:pseudo", + " └─IndexReader_24(Probe) 9990.00 root index:IndexFullScan_23", + " └─IndexFullScan_23 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, desc, stats:pseudo" ], "Result": [ "2", @@ -1558,14 +1566,14 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1-t1.a+3", "Plan": [ - "Projection_32 12487.50 root test.t.a", - "└─Projection_31 12487.50 root test.t.a, plus(minus(1, test.t.a), 3)->Column#7", - " └─Projection_20 12487.50 root test.t.a", - " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_26(Build) 9990.00 root index:IndexFullScan_25", - " │ └─IndexFullScan_25 9990.00 cop[tikv] table:t2, index:b, keep order:true, desc, stats:pseudo", - " └─IndexReader_24(Probe) 9990.00 root index:IndexFullScan_23", - " └─IndexFullScan_23 9990.00 cop[tikv] table:t1, index:a, keep order:true, desc, stats:pseudo" + "Projection_32 12487.50 root test.t.a", + "└─Projection_31 12487.50 root test.t.a, plus(minus(1, test.t.a), 3)->Column#7", + " └─Projection_20 12487.50 root test.t.a", + " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_26(Build) 9990.00 root index:IndexFullScan_25", + " │ └─IndexFullScan_25 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, desc, stats:pseudo", + " └─IndexReader_24(Probe) 9990.00 root index:IndexFullScan_23", + " └─IndexFullScan_23 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, desc, stats:pseudo" ], "Result": [ "2", @@ -1576,14 +1584,14 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1+t1.a+3", "Plan": [ - "Projection_24 12487.50 root test.t.a", - "└─Projection_23 12487.50 root test.t.a, plus(plus(1, test.t.a), 3)->Column#7", - " └─Projection_20 12487.50 root test.t.a", - " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", - " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:b, keep order:true, stats:pseudo", - " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", - " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:a, keep order:true, stats:pseudo" + "Projection_24 12487.50 root test.t.a", + "└─Projection_23 12487.50 root test.t.a, plus(plus(1, test.t.a), 3)->Column#7", + " └─Projection_20 12487.50 root test.t.a", + " └─MergeJoin_21 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_15(Build) 9990.00 root index:IndexFullScan_14", + " │ └─IndexFullScan_14 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo", + " └─IndexReader_13(Probe) 9990.00 root index:IndexFullScan_12", + " └─IndexFullScan_12 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo" ], "Result": [ "1", @@ -1594,15 +1602,15 @@ { "SQL": "select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 3*t1.a", "Plan": [ - "Projection_19 12487.50 root test.t.a", - "└─Sort_7 12487.50 root Column#7:asc", - " └─Projection_20 12487.50 root test.t.a, mul(3, test.t.a)->Column#7", - " └─Projection_8 12487.50 root test.t.a", - " └─MergeJoin_9 12487.50 root inner join, left key:test.t.a, right key:test.t.b", - " ├─IndexReader_14(Build) 9990.00 root index:IndexFullScan_13", - " │ └─IndexFullScan_13 9990.00 cop[tikv] table:t2, index:b, keep order:true, stats:pseudo", - " └─IndexReader_12(Probe) 9990.00 root index:IndexFullScan_11", - " └─IndexFullScan_11 9990.00 cop[tikv] table:t1, index:a, keep order:true, stats:pseudo" + "Projection_19 12487.50 root test.t.a", + "└─Sort_7 12487.50 root Column#7:asc", + " └─Projection_20 12487.50 root test.t.a, mul(3, test.t.a)->Column#7", + " └─Projection_8 12487.50 root test.t.a", + " └─MergeJoin_9 12487.50 root inner join, left key:test.t.a, right key:test.t.b", + " ├─IndexReader_14(Build) 9990.00 root index:IndexFullScan_13", + " │ └─IndexFullScan_13 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo", + " └─IndexReader_12(Probe) 9990.00 root index:IndexFullScan_11", + " └─IndexFullScan_11 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo" ], "Result": [ "1", diff --git a/planner/core/testdata/point_get_plan_out.json b/planner/core/testdata/point_get_plan_out.json index e389c7601307a..0dbb22d749104 100644 --- a/planner/core/testdata/point_get_plan_out.json +++ b/planner/core/testdata/point_get_plan_out.json @@ -5,8 +5,8 @@ { "SQL": "select * from t where t.a in ('1','2','4') and t.a+1=2 order by t.a desc", "Plan": [ - "Selection_12 2.40 root eq(plus(cast(test.t.a), 1), 2)", - "└─Batch_Point_Get_11 2.40 root table:t, index:a, keep order:true, desc:true" + "Selection_12 2.40 root eq(plus(cast(test.t.a), 1), 2)", + "└─Batch_Point_Get_11 2.40 root table:t, index:PRIMARY(a) keep order:true, desc:true" ], "Res": [ "1 4 4 1" @@ -15,8 +15,8 @@ { "SQL": "select b, c from t where t.b = 2 and t.c = 2 and t.b+1=3", "Plan": [ - "Selection_6 0.80 root eq(plus(test.t.b, 1), 3)", - "└─Point_Get_5 1.00 root table:t, index:b c" + "Selection_6 0.80 root eq(plus(test.t.b, 1), 3)", + "└─Point_Get_5 1.00 root table:t, index:b(b, c) " ], "Res": [ "2 2" @@ -25,8 +25,8 @@ { "SQL": "select * from t where t.a = '1' and t.b = 4", "Plan": [ - "Selection_6 0.00 root eq(test.t.b, 4)", - "└─Point_Get_5 1.00 root table:t, index:a" + "Selection_6 0.00 root eq(test.t.b, 4)", + "└─Point_Get_5 1.00 root table:t, index:PRIMARY(a) " ], "Res": [ "1 4 4 1" @@ -35,8 +35,8 @@ { "SQL": "select * from t where t.a in ('1','3') and t.d = 3", "Plan": [ - "Selection_6 0.00 root eq(test.t.d, 3)", - "└─Batch_Point_Get_5 0.00 root table:t, index:a, keep order:false, desc:false" + "Selection_6 0.00 root eq(test.t.d, 3)", + "└─Batch_Point_Get_5 0.00 root table:t, index:PRIMARY(a) keep order:false, desc:false" ], "Res": [ "3 2 2 3" @@ -45,11 +45,11 @@ { "SQL": "select * from t t1 join t t2 on t1.a = t2.a where t1.a = '4' and (t2.b, t2.c) in ((1,1),(2,2))", "Plan": [ - "Projection_7 0.80 root test.t.a, test.t.b, test.t.c, test.t.d, test.t.a, test.t.b, test.t.c, test.t.d", - "└─HashRightJoin_9 0.80 root CARTESIAN inner join", - " ├─Selection_11(Build) 0.80 root or(and(eq(test.t.b, 1), eq(test.t.c, 1)), and(eq(test.t.b, 2), eq(test.t.c, 2)))", - " │ └─Point_Get_10 1.00 root table:t, index:a", - " └─Point_Get_12(Probe) 1.00 root table:t, index:a" + "Projection_7 0.80 root test.t.a, test.t.b, test.t.c, test.t.d, test.t.a, test.t.b, test.t.c, test.t.d", + "└─HashJoin_9 0.80 root CARTESIAN inner join", + " ├─Selection_11(Build) 0.80 root or(and(eq(test.t.b, 1), eq(test.t.c, 1)), and(eq(test.t.b, 2), eq(test.t.c, 2)))", + " │ └─Point_Get_10 1.00 root table:t, index:PRIMARY(a) ", + " └─Point_Get_12(Probe) 1.00 root table:t, index:PRIMARY(a) " ], "Res": [ "4 1 1 4 4 1 1 4" @@ -58,7 +58,7 @@ { "SQL": "select * from t where (t.b, t.c) in ((2,2), (3,3), (4,4)) order by t.b, t.c", "Plan": [ - "Batch_Point_Get_10 3.00 root table:t, index:b c, keep order:true, desc:false" + "Batch_Point_Get_10 3.00 root table:t, index:b(b, c) keep order:true, desc:false" ], "Res": [ "3 2 2 3", diff --git a/planner/core/util.go b/planner/core/util.go index b058dac927e28..926cea495522e 100644 --- a/planner/core/util.go +++ b/planner/core/util.go @@ -14,9 +14,14 @@ package core import ( + "fmt" + "sort" + "strings" + "github.com/pingcap/parser/ast" "github.com/pingcap/tidb/expression" "github.com/pingcap/tidb/types" + "github.com/pingcap/tidb/util/set" ) // AggregateFuncExtractor visits Expr tree. @@ -231,3 +236,16 @@ func GetStatsInfo(i interface{}) map[string]uint64 { statsInfos = CollectPlanStatsVersion(physicalPlan, statsInfos) return statsInfos } + +// extractStringFromStringSet helps extract string info from set.StringSet +func extractStringFromStringSet(set set.StringSet) string { + if len(set) < 1 { + return "" + } + l := make([]string, 0, len(set)) + for k := range set { + l = append(l, fmt.Sprintf(`"%s"`, k)) + } + sort.Strings(l) + return fmt.Sprintf("%s", strings.Join(l, ",")) +} diff --git a/planner/optimize.go b/planner/optimize.go index 9bd8fdc06ae8e..fa8898513d8a9 100644 --- a/planner/optimize.go +++ b/planner/optimize.go @@ -240,10 +240,21 @@ func handleEvolveTasks(ctx context.Context, sctx sessionctx.Context, br *bindinf if bindSQL == "" { return } - globalHandle := domain.GetDomain(sctx).BindHandle() charset, collation := sctx.GetSessionVars().GetCharsetInfo() - binding := bindinfo.Binding{BindSQL: bindSQL, Status: bindinfo.PendingVerify, Charset: charset, Collation: collation} - globalHandle.AddEvolvePlanTask(br.OriginalSQL, br.Db, binding, planHint) + hintsSet, err := bindinfo.ParseHintsSet(parser.New(), bindSQL, charset, collation) + if err != nil { + return + } + binding := bindinfo.Binding{ + BindSQL: bindSQL, + Status: bindinfo.PendingVerify, + Charset: charset, + Collation: collation, + Hint: hintsSet, + ID: planHint, + } + globalHandle := domain.GetDomain(sctx).BindHandle() + globalHandle.AddEvolvePlanTask(br.OriginalSQL, br.Db, binding) } // useMaxTS returns true when meets following conditions: diff --git a/privilege/privileges/cache.go b/privilege/privileges/cache.go index f1110edfc5490..0d3af938f9e4a 100644 --- a/privilege/privileges/cache.go +++ b/privilege/privileges/cache.go @@ -1253,11 +1253,10 @@ func (p *MySQLPrivilege) getAllRoles(user, host string) []*auth.RoleIdentity { key := user + "@" + host edgeTable, ok := p.RoleGraph[key] ret := make([]*auth.RoleIdentity, 0, len(edgeTable.roleList)) - if !ok { - return nil - } - for _, r := range edgeTable.roleList { - ret = append(ret, r) + if ok { + for _, r := range edgeTable.roleList { + ret = append(ret, r) + } } return ret } diff --git a/server/conn_test.go b/server/conn_test.go index c4e7aad36fdc1..4997020c7b21f 100644 --- a/server/conn_test.go +++ b/server/conn_test.go @@ -448,6 +448,10 @@ func (c *mockTiDBCtx) Execute(ctx context.Context, sql string) ([]ResultSet, err return c.rs, c.err } +func (c *mockTiDBCtx) ExecuteInternal(ctx context.Context, sql string) ([]ResultSet, error) { + return c.rs, c.err +} + func (c *mockTiDBCtx) GetSessionVars() *variable.SessionVars { return &variable.SessionVars{} } diff --git a/server/driver.go b/server/driver.go index d2c6c5ecb17f3..f336db8f1356b 100644 --- a/server/driver.go +++ b/server/driver.go @@ -69,6 +69,9 @@ type QueryCtx interface { // Execute executes a SQL statement. Execute(ctx context.Context, sql string) ([]ResultSet, error) + // ExecuteInternal executes a internal SQL statement. + ExecuteInternal(ctx context.Context, sql string) ([]ResultSet, error) + // SetClientCapability sets client capability flags SetClientCapability(uint32) diff --git a/server/driver_tidb.go b/server/driver_tidb.go index a596e34f93b08..8413b850dbb26 100644 --- a/server/driver_tidb.go +++ b/server/driver_tidb.go @@ -261,6 +261,24 @@ func (tc *TiDBContext) Execute(ctx context.Context, sql string) (rs []ResultSet, return } +// ExecuteInternal implements QueryCtx ExecuteInternal method. +func (tc *TiDBContext) ExecuteInternal(ctx context.Context, sql string) (rs []ResultSet, err error) { + rsList, err := tc.session.ExecuteInternal(ctx, sql) + if err != nil { + return + } + if len(rsList) == 0 { // result ok + return + } + rs = make([]ResultSet, len(rsList)) + for i := 0; i < len(rsList); i++ { + rs[i] = &tidbResultSet{ + recordSet: rsList[i], + } + } + return +} + // SetSessionManager implements the QueryCtx interface. func (tc *TiDBContext) SetSessionManager(sm util.SessionManager) { tc.session.SetSessionManager(sm) diff --git a/server/http_handler_test.go b/server/http_handler_test.go index 7e66adc1c232a..423c756f913d1 100644 --- a/server/http_handler_test.go +++ b/server/http_handler_test.go @@ -1134,7 +1134,7 @@ func (ts *HTTPHandlerTestSuite) TestFailpointHandler(c *C) { // start server without enabling failpoint integration ts.startServer(c) - resp, err := ts.fetchStatus("/failpoints/") + resp, err := ts.fetchStatus("/fail/") c.Assert(err, IsNil) c.Assert(resp.StatusCode, Equals, http.StatusNotFound) ts.stopServer(c) @@ -1142,7 +1142,7 @@ func (ts *HTTPHandlerTestSuite) TestFailpointHandler(c *C) { // enable failpoint integration and start server c.Assert(failpoint.Enable("github.com/pingcap/tidb/server/integrateFailpoint", "return"), IsNil) ts.startServer(c) - resp, err = ts.fetchStatus("/failpoints/") + resp, err = ts.fetchStatus("/fail/") c.Assert(err, IsNil) c.Assert(resp.StatusCode, Equals, http.StatusOK) b, err := ioutil.ReadAll(resp.Body) diff --git a/server/http_status.go b/server/http_status.go index b0928c190109f..2326ecbc681f4 100644 --- a/server/http_status.go +++ b/server/http_status.go @@ -71,6 +71,33 @@ func sleepWithCtx(ctx context.Context, d time.Duration) { } } +func (s *Server) listenStatusHTTPServer() error { + s.statusAddr = fmt.Sprintf("%s:%d", s.cfg.Status.StatusHost, s.cfg.Status.StatusPort) + if s.cfg.Status.StatusPort == 0 { + s.statusAddr = fmt.Sprintf("%s:%d", s.cfg.Status.StatusHost, defaultStatusPort) + } + + logutil.BgLogger().Info("for status and metrics report", zap.String("listening on addr", s.statusAddr)) + tlsConfig, err := s.cfg.Security.ToTLSConfig() + if err != nil { + logutil.BgLogger().Error("invalid TLS config", zap.Error(err)) + return errors.Trace(err) + } + tlsConfig = s.setCNChecker(tlsConfig) + + if tlsConfig != nil { + // we need to manage TLS here for cmux to distinguish between HTTP and gRPC. + s.statusListener, err = tls.Listen("tcp", s.statusAddr, tlsConfig) + } else { + s.statusListener, err = net.Listen("tcp", s.statusAddr) + } + if err != nil { + logutil.BgLogger().Info("listen failed", zap.Error(err)) + return errors.Trace(err) + } + return nil +} + func (s *Server) startHTTPServer() { router := mux.NewRouter() @@ -123,13 +150,8 @@ func (s *Server) startHTTPServer() { router.Handle("/mvcc/hex/{hexKey}", mvccTxnHandler{tikvHandlerTool, opMvccGetByHex}) router.Handle("/mvcc/index/{db}/{table}/{index}/{handle}", mvccTxnHandler{tikvHandlerTool, opMvccGetByIdx}) - addr := fmt.Sprintf("%s:%d", s.cfg.Status.StatusHost, s.cfg.Status.StatusPort) - if s.cfg.Status.StatusPort == 0 { - addr = fmt.Sprintf("%s:%d", s.cfg.Status.StatusHost, defaultStatusPort) - } - // HTTP path for web UI. - if host, port, err := net.SplitHostPort(addr); err == nil { + if host, port, err := net.SplitHostPort(s.statusAddr); err == nil { if host == "" { host = "localhost" } @@ -235,8 +257,8 @@ func (s *Server) startHTTPServer() { serverMux.HandleFunc("/debug/sub-optimal-plan", fetcher.zipInfoForSQL) failpoint.Inject("integrateFailpoint", func() { - serverMux.HandleFunc("/failpoints/", func(w http.ResponseWriter, r *http.Request) { - r.URL.Path = strings.TrimPrefix(r.URL.Path, "/failpoints") + serverMux.HandleFunc("/fail/", func(w http.ResponseWriter, r *http.Request) { + r.URL.Path = strings.TrimPrefix(r.URL.Path, "/fail") new(failpoint.HttpHandler).ServeHTTP(w, r) }) }) @@ -271,40 +293,17 @@ func (s *Server) startHTTPServer() { logutil.BgLogger().Error("write HTTP index page failed", zap.Error(err)) } }) - - logutil.BgLogger().Info("for status and metrics report", zap.String("listening on addr", addr)) - s.setupStatusServerAndRPCServer(addr, serverMux) + s.startStatusServerAndRPCServer(serverMux) } -func (s *Server) setupStatusServerAndRPCServer(addr string, serverMux *http.ServeMux) { - tlsConfig, err := s.cfg.Security.ToTLSConfig() - if err != nil { - logutil.BgLogger().Error("invalid TLS config", zap.Error(err)) - return - } - tlsConfig = s.setCNChecker(tlsConfig) - - var l net.Listener - if tlsConfig != nil { - // we need to manage TLS here for cmux to distinguish between HTTP and gRPC. - l, err = tls.Listen("tcp", addr, tlsConfig) - } else { - l, err = net.Listen("tcp", addr) - } - if err != nil { - logutil.BgLogger().Info("listen failed", zap.Error(err)) - return - } - if tlsConfig != nil { - logutil.BgLogger().Info("HTTP/gRPC status server secure connection is enabled", zap.Bool("CN verification enabled", tlsConfig.VerifyPeerCertificate != nil)) - } - m := cmux.New(l) +func (s *Server) startStatusServerAndRPCServer(serverMux *http.ServeMux) { + m := cmux.New(s.statusListener) // Match connections in order: // First HTTP, and otherwise grpc. httpL := m.Match(cmux.HTTP1Fast()) grpcL := m.Match(cmux.Any()) - s.statusServer = &http.Server{Addr: addr, Handler: CorsHandler{handler: serverMux, cfg: s.cfg}} + s.statusServer = &http.Server{Addr: s.statusAddr, Handler: CorsHandler{handler: serverMux, cfg: s.cfg}} s.grpcServer = NewRPCServer(s.cfg, s.dom, s) go util.WithRecovery(func() { @@ -317,7 +316,7 @@ func (s *Server) setupStatusServerAndRPCServer(addr string, serverMux *http.Serv logutil.BgLogger().Error("http server error", zap.Error(err)) }, nil) - err = m.Serve() + err := m.Serve() if err != nil { logutil.BgLogger().Error("start status/rpc server error", zap.Error(err)) } diff --git a/server/server.go b/server/server.go index 12458775584ac..f4685303864b4 100644 --- a/server/server.go +++ b/server/server.go @@ -116,8 +116,11 @@ type Server struct { clients map[uint32]*clientConn capability uint32 dom *domain.Domain - statusServer *http.Server - grpcServer *grpc.Server + + statusAddr string + statusListener net.Listener + statusServer *http.Server + grpcServer *grpc.Server } // ConnectionCount gets current connection count. @@ -256,6 +259,9 @@ func NewServer(cfg *config.Config, driver IDriver) (*Server, error) { s.listener = pplistener } + if s.cfg.Status.ReportStatus && err == nil { + err = s.listenStatusHTTPServer() + } if err != nil { return nil, errors.Trace(err) } diff --git a/server/tidb_test.go b/server/tidb_test.go index 961946e411147..bd83e123273ec 100644 --- a/server/tidb_test.go +++ b/server/tidb_test.go @@ -22,6 +22,7 @@ import ( "crypto/x509" "crypto/x509/pkix" "encoding/pem" + "fmt" "io/ioutil" "math/big" "net/http" @@ -180,6 +181,27 @@ func (ts *tidbTestSuite) TestStatusAPI(c *C) { ts.runTestStatusAPI(c) } +func (ts *tidbTestSuite) TestStatusPort(c *C) { + var err error + ts.store, err = mockstore.NewMockTikvStore() + session.DisableStats4Test() + c.Assert(err, IsNil) + ts.domain, err = session.BootstrapSession(ts.store) + c.Assert(err, IsNil) + ts.tidbdrv = NewTiDBDriver(ts.store) + cfg := config.NewConfig() + cfg.Port = genPort() + cfg.Status.ReportStatus = true + cfg.Status.StatusPort = ts.statusPort + cfg.Performance.TCPKeepAlive = true + + server, err := NewServer(cfg, ts.tidbdrv) + c.Assert(err, NotNil) + c.Assert(err.Error(), Equals, + fmt.Sprintf("listen tcp 0.0.0.0:%d: bind: address already in use", ts.statusPort)) + c.Assert(server, IsNil) +} + func (ts *tidbTestSuite) TestStatusAPIWithTLS(c *C) { caCert, caKey, err := generateCert(0, "TiDB CA 2", nil, nil, "/tmp/ca-key-2.pem", "/tmp/ca-cert-2.pem") c.Assert(err, IsNil) diff --git a/session/pessimistic_test.go b/session/pessimistic_test.go index 46280d48b99fa..9cdfd3ec32e51 100644 --- a/session/pessimistic_test.go +++ b/session/pessimistic_test.go @@ -27,6 +27,7 @@ import ( "github.com/pingcap/parser/terror" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/session" + "github.com/pingcap/tidb/sessionctx/variable" "github.com/pingcap/tidb/store/tikv" "github.com/pingcap/tidb/tablecodec" "github.com/pingcap/tidb/util/codec" @@ -1144,3 +1145,62 @@ func (s *testPessimisticSuite) TestRollbackWakeupBlockedTxn(c *C) { c.Assert(failpoint.Disable("github.com/pingcap/tidb/store/tikv/txnExpireRetTTL"), IsNil) c.Assert(failpoint.Disable("github.com/pingcap/tidb/store/tikv/getTxnStatusDelay"), IsNil) } + +func (s *testPessimisticSuite) TestRCSubQuery(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) + tk.MustExec("drop table if exists t, t1") + tk.MustExec("create table `t` ( `c1` int(11) not null, `c2` int(11) default null, primary key (`c1`) )") + tk.MustExec("insert into t values(1, 3)") + tk.MustExec("create table `t1` ( `c1` int(11) not null, `c2` int(11) default null, primary key (`c1`) )") + tk.MustExec("insert into t1 values(1, 3)") + tk.MustExec("set transaction isolation level read committed") + tk.MustExec("begin pessimistic") + + tk2 := testkit.NewTestKitWithInit(c, s.store) + tk2.MustExec("update t1 set c2 = c2 + 1") + + tk.MustQuery("select * from t1 where c1 = (select 1) and 1=1;").Check(testkit.Rows("1 4")) + tk.MustQuery("select * from t1 where c1 = (select c1 from t where c1 = 1) and 1=1;").Check(testkit.Rows("1 4")) + tk.MustExec("rollback") +} + +func (s *testPessimisticSuite) TestGenerateColPointGet(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) + defer func() { + tk.MustExec(fmt.Sprintf("set global tidb_row_format_version = %d", variable.DefTiDBRowFormatV2)) + }() + tests2 := []int{variable.DefTiDBRowFormatV1, variable.DefTiDBRowFormatV2} + for _, rowFormat := range tests2 { + tk.MustExec(fmt.Sprintf("set global tidb_row_format_version = %d", rowFormat)) + tk.MustExec("drop table if exists tu") + tk.MustExec("CREATE TABLE `tu`(`x` int, `y` int, `z` int GENERATED ALWAYS AS (x + y) VIRTUAL, PRIMARY KEY (`x`), UNIQUE KEY `idz` (`z`))") + tk.MustExec("insert into tu(x, y) values(1, 2);") + + // test point get lock + tk.MustExec("begin pessimistic") + tk.MustQuery("select * from tu where z = 3 for update").Check(testkit.Rows("1 2 3")) + tk2 := testkit.NewTestKitWithInit(c, s.store) + tk2.MustExec("begin pessimistic") + err := tk2.ExecToErr("select * from tu where z = 3 for update nowait") + c.Assert(terror.ErrorEqual(err, tikv.ErrLockAcquireFailAndNoWaitSet), IsTrue) + tk.MustExec("begin pessimistic") + tk.MustExec("insert into tu(x, y) values(2, 2);") + err = tk2.ExecToErr("select * from tu where z = 4 for update nowait") + c.Assert(terror.ErrorEqual(err, tikv.ErrLockAcquireFailAndNoWaitSet), IsTrue) + + // test batch point get lock + tk.MustExec("begin pessimistic") + tk2.MustExec("begin pessimistic") + tk.MustQuery("select * from tu where z in (1, 3, 5) for update").Check(testkit.Rows("1 2 3")) + tk2.MustExec("begin pessimistic") + err = tk2.ExecToErr("select x from tu where z in (3, 7, 9) for update nowait") + c.Assert(terror.ErrorEqual(err, tikv.ErrLockAcquireFailAndNoWaitSet), IsTrue) + tk.MustExec("begin pessimistic") + tk.MustExec("insert into tu(x, y) values(5, 6);") + err = tk2.ExecToErr("select * from tu where z = 11 for update nowait") + c.Assert(terror.ErrorEqual(err, tikv.ErrLockAcquireFailAndNoWaitSet), IsTrue) + + tk.MustExec("commit") + tk2.MustExec("commit") + } +} diff --git a/session/session.go b/session/session.go index a194a7d616ec8..e887c3a757032 100644 --- a/session/session.go +++ b/session/session.go @@ -95,12 +95,13 @@ var ( // Session context, it is consistent with the lifecycle of a client connection. type Session interface { sessionctx.Context - Status() uint16 // Flag of current status, such as autocommit. - LastInsertID() uint64 // LastInsertID is the last inserted auto_increment ID. - LastMessage() string // LastMessage is the info message that may be generated by last command - AffectedRows() uint64 // Affected rows by latest executed stmt. - Execute(context.Context, string) ([]sqlexec.RecordSet, error) // Execute a sql statement. - String() string // String is used to debug. + Status() uint16 // Flag of current status, such as autocommit. + LastInsertID() uint64 // LastInsertID is the last inserted auto_increment ID. + LastMessage() string // LastMessage is the info message that may be generated by last command + AffectedRows() uint64 // Affected rows by latest executed stmt. + Execute(context.Context, string) ([]sqlexec.RecordSet, error) // Execute a sql statement. + ExecuteInternal(context.Context, string) ([]sqlexec.RecordSet, error) // Execute a internal sql statement. + String() string // String is used to debug. CommitTxn(context.Context) error RollbackTxn(context.Context) // PrepareStmt executes prepare statement in binary protocol. @@ -1030,12 +1031,6 @@ func (s *session) SetProcessInfo(sql string, t time.Time, command byte, maxExecu } func (s *session) executeStatement(ctx context.Context, connID uint64, stmtNode ast.StmtNode, stmt sqlexec.Statement, recordSets []sqlexec.RecordSet, inMulitQuery bool) ([]sqlexec.RecordSet, error) { - s.SetValue(sessionctx.QueryString, stmt.OriginText()) - if _, ok := stmtNode.(ast.DDLNode); ok { - s.SetValue(sessionctx.LastExecuteDDL, true) - } else { - s.ClearValue(sessionctx.LastExecuteDDL) - } logStmt(stmtNode, s.sessionVars) startTime := time.Now() recordSet, err := runStmt(ctx, s, stmt) @@ -1070,6 +1065,15 @@ func (s *session) executeStatement(ctx context.Context, connID uint64, stmtNode return recordSets, nil } +func (s *session) ExecuteInternal(ctx context.Context, sql string) (recordSets []sqlexec.RecordSet, err error) { + origin := s.sessionVars.InRestrictedSQL + s.sessionVars.InRestrictedSQL = true + defer func() { + s.sessionVars.InRestrictedSQL = origin + }() + return s.Execute(ctx, sql) +} + func (s *session) Execute(ctx context.Context, sql string) (recordSets []sqlexec.RecordSet, err error) { if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil { span1 := span.Tracer().StartSpan("session.Execute", opentracing.ChildOf(span.Context())) @@ -1218,6 +1222,8 @@ func (s *session) CachedPlanExec(ctx context.Context, if err != nil { return nil, err } + + stmtCtx := s.GetSessionVars().StmtCtx stmt := &executor.ExecStmt{ InfoSchema: is, Plan: execPlan, @@ -1228,7 +1234,9 @@ func (s *session) CachedPlanExec(ctx context.Context, } s.GetSessionVars().DurationCompile = time.Since(s.sessionVars.StartTime) stmt.Text = prepared.Stmt.Text() - s.GetSessionVars().StmtCtx.OriginalSQL = stmt.Text + stmtCtx.OriginalSQL = stmt.Text + stmtCtx.InitSQLDigest(prepareStmt.NormalizedSQL, prepareStmt.SQLDigest) + stmtCtx.SetPlanDigest(prepareStmt.NormalizedPlan, prepareStmt.PlanDigest) logQuery(stmt.OriginText(), s.sessionVars) // run ExecStmt @@ -1239,7 +1247,7 @@ func (s *session) CachedPlanExec(ctx context.Context, s.txn.changeToInvalid() case *plannercore.Update: s.PrepareTSFuture(ctx) - s.GetSessionVars().StmtCtx.Priority = kv.PriorityHigh + stmtCtx.Priority = kv.PriorityHigh resultSet, err = runStmt(ctx, s, stmt) default: prepared.CachedPlan = nil @@ -1884,6 +1892,7 @@ var builtinGlobalVariable = []string{ variable.NetWriteTimeout, variable.MaxExecutionTime, variable.InnodbLockWaitTimeout, + variable.WindowingUseHighPrecision, /* TiDB specific global variables: */ variable.TiDBSkipUTF8Check, @@ -1930,6 +1939,7 @@ var builtinGlobalVariable = []string{ variable.TiDBTxnMode, variable.TiDBRowFormatVersion, variable.TiDBEnableStmtSummary, + variable.TiDBStmtSummaryInternalQuery, variable.TiDBStmtSummaryRefreshInterval, variable.TiDBStmtSummaryHistorySize, variable.TiDBMaxDeltaSchemaCount, diff --git a/session/session_fail_test.go b/session/session_fail_test.go index 104e130bf21ea..8c0b18ca9ffff 100644 --- a/session/session_fail_test.go +++ b/session/session_fail_test.go @@ -133,3 +133,12 @@ func (s *testSessionSerialSuite) TestKillFlagInBackoff(c *C) { tk.MustQuery("select * from kill_backoff") c.Assert(killValue, Equals, uint32(3)) } + +func (s *testSessionSerialSuite) TestClusterTableSendError(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) + c.Assert(failpoint.Enable("github.com/pingcap/tidb/store/tikv/tikvStoreSendReqResult", `return("requestTiDBStoreError")`), IsNil) + defer failpoint.Disable("github.com/pingcap/tidb/store/tikv/tikvStoreSendReqResult") + tk.MustQuery("select * from information_schema.cluster_slow_query") + c.Assert(tk.Se.GetSessionVars().StmtCtx.WarningCount(), Equals, uint16(1)) + c.Assert(tk.Se.GetSessionVars().StmtCtx.GetWarnings()[0].Err, ErrorMatches, ".*TiDB server timeout, address is.*") +} diff --git a/session/session_test.go b/session/session_test.go index 658304f01f4cd..16adcc9979ba5 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -299,6 +299,21 @@ func (s *testSessionSuite) TestQueryString(c *C) { tk.MustExec("create table mutil1 (a int);create table multi2 (a int)") queryStr := tk.Se.Value(sessionctx.QueryString) c.Assert(queryStr, Equals, "create table multi2 (a int)") + + // Test execution of DDL through the "ExecutePreparedStmt" interface. + _, err := tk.Se.Execute(context.Background(), "use test;") + c.Assert(err, IsNil) + _, err = tk.Se.Execute(context.Background(), "CREATE TABLE t (id bigint PRIMARY KEY, age int)") + c.Assert(err, IsNil) + _, err = tk.Se.Execute(context.Background(), "show create table t") + c.Assert(err, IsNil) + id, _, _, err := tk.Se.PrepareStmt("CREATE TABLE t2(id bigint PRIMARY KEY, age int)") + c.Assert(err, IsNil) + params := []types.Datum{} + _, err = tk.Se.ExecutePreparedStmt(context.Background(), id, params) + c.Assert(err, IsNil) + qs := tk.Se.Value(sessionctx.QueryString) + c.Assert(qs.(string), Equals, "CREATE TABLE t2(id bigint PRIMARY KEY, age int)") } func (s *testSessionSuite) TestAffectedRows(c *C) { @@ -2077,6 +2092,19 @@ func (s *testSchemaSuite) TestCommitWhenSchemaChanged(c *C) { c.Assert(terror.ErrorEqual(err, plannercore.ErrWrongValueCountOnRow), IsTrue, Commentf("err %v", err)) } +func (s *testSchemaSuite) TestRetrySchemaChangeForEmptyChange(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) + tk1 := testkit.NewTestKitWithInit(c, s.store) + tk.MustExec("create table t (i int)") + tk.MustExec("create table t1 (i int)") + tk.MustExec("begin") + tk1.MustExec("alter table t add j int") + tk.MustExec("update t set i = -i") + tk.MustExec("delete from t") + tk.MustExec("insert into t1 values (1)") + tk.MustExec("commit") +} + func (s *testSchemaSuite) TestRetrySchemaChange(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk1 := testkit.NewTestKitWithInit(c, s.store) diff --git a/session/tidb.go b/session/tidb.go index 34515fa182d3b..36760c0ee96a6 100644 --- a/session/tidb.go +++ b/session/tidb.go @@ -251,6 +251,13 @@ func runStmt(ctx context.Context, sctx sessionctx.Context, s sqlexec.Statement) defer span1.Finish() ctx = opentracing.ContextWithSpan(ctx, span1) } + sctx.SetValue(sessionctx.QueryString, s.OriginText()) + if _, ok := s.(*executor.ExecStmt).StmtNode.(ast.DDLNode); ok { + sctx.SetValue(sessionctx.LastExecuteDDL, true) + } else { + sctx.ClearValue(sessionctx.LastExecuteDDL) + } + se := sctx.(*session) sessVars := se.GetSessionVars() // Save origTxnCtx here to avoid it reset in the transaction retry. diff --git a/sessionctx/stmtctx/stmtctx.go b/sessionctx/stmtctx/stmtctx.go index 96cf03140e9ba..50fb139fb659e 100644 --- a/sessionctx/stmtctx/stmtctx.go +++ b/sessionctx/stmtctx/stmtctx.go @@ -188,6 +188,13 @@ func (sc *StatementContext) SQLDigest() (normalized, sqlDigest string) { return sc.digestMemo.normalized, sc.digestMemo.digest } +// InitSQLDigest sets the normalized and digest for sql. +func (sc *StatementContext) InitSQLDigest(normalized, digest string) { + sc.digestMemo.Do(func() { + sc.digestMemo.normalized, sc.digestMemo.digest = normalized, digest + }) +} + // GetPlanDigest gets the normalized plan and plan digest. func (sc *StatementContext) GetPlanDigest() (normalized, planDigest string) { return sc.planNormalized, sc.planDigest diff --git a/sessionctx/variable/session.go b/sessionctx/variable/session.go index 6ec9474889836..06818247db64f 100644 --- a/sessionctx/variable/session.go +++ b/sessionctx/variable/session.go @@ -40,6 +40,7 @@ import ( "github.com/pingcap/tidb/store/tikv/oracle" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util/chunk" + "github.com/pingcap/tidb/util/collate" "github.com/pingcap/tidb/util/execdetails" "github.com/pingcap/tidb/util/rowcodec" "github.com/pingcap/tidb/util/storeutil" @@ -583,6 +584,10 @@ type SessionVars struct { // SequenceState cache all sequence's latest value accessed by lastval() builtins. It's a session scoped // variable, and all public methods of SequenceState are currently-safe. SequenceState *SequenceState + + // WindowingUseHighPrecision determines whether to compute window operations without loss of precision. + // see https://dev.mysql.com/doc/refman/8.0/en/window-function-optimization.html for more details. + WindowingUseHighPrecision bool } // PreparedParams contains the parameters of the current prepared statement when executing it. @@ -667,6 +672,7 @@ func NewSessionVars() *SessionVars { MetricSchemaStep: DefTiDBMetricSchemaStep, MetricSchemaRangeDuration: DefTiDBMetricSchemaRangeDuration, SequenceState: NewSequenceState(), + WindowingUseHighPrecision: true, } vars.KVVars = kv.NewVariables(&vars.Killed) vars.Concurrency = Concurrency{ @@ -1018,6 +1024,8 @@ func (s *SessionVars) SetSystemVar(name string, val string) error { case InnodbLockWaitTimeout: lockWaitSec := tidbOptInt64(val, DefInnodbLockWaitTimeout) s.LockWaitTimeout = int64(lockWaitSec * 1000) + case WindowingUseHighPrecision: + s.WindowingUseHighPrecision = TiDBOptOn(val) case TiDBSkipUTF8Check: s.SkipUTF8Check = TiDBOptOn(val) case TiDBOptAggPushDown: @@ -1203,6 +1211,10 @@ func (s *SessionVars) SetSystemVar(name string, val string) error { s.MetricSchemaStep = tidbOptInt64(val, DefTiDBMetricSchemaStep) case TiDBMetricSchemaRangeDuration: s.MetricSchemaRangeDuration = tidbOptInt64(val, DefTiDBMetricSchemaRangeDuration) + case CollationConnection, CollationDatabase, CollationServer: + if _, err := collate.GetCollationByName(val); err != nil { + return errors.Trace(err) + } } s.systems[name] = val return nil diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 5d17a9daa5715..eca19504522bf 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -605,6 +605,7 @@ var defaultSysVars = []*SysVar{ {ScopeSession, ErrorCount, "0"}, {ScopeGlobal | ScopeSession, "information_schema_stats_expiry", "86400"}, {ScopeGlobal, "thread_pool_size", "16"}, + {ScopeGlobal | ScopeSession, WindowingUseHighPrecision, "ON"}, /* TiDB specific variables */ {ScopeSession, TiDBSnapshot, ""}, {ScopeSession, TiDBOptAggPushDown, BoolToIntStr(DefOptAggPushDown)}, @@ -694,6 +695,7 @@ var defaultSysVars = []*SysVar{ {ScopeSession, TiDBReplicaRead, "leader"}, {ScopeSession, TiDBAllowRemoveAutoInc, BoolToIntStr(DefTiDBAllowRemoveAutoInc)}, {ScopeGlobal | ScopeSession, TiDBEnableStmtSummary, BoolToIntStr(config.GetGlobalConfig().StmtSummary.Enable)}, + {ScopeGlobal | ScopeSession, TiDBStmtSummaryInternalQuery, BoolToIntStr(config.GetGlobalConfig().StmtSummary.EnableInternalQuery)}, {ScopeGlobal | ScopeSession, TiDBStmtSummaryRefreshInterval, strconv.Itoa(config.GetGlobalConfig().StmtSummary.RefreshInterval)}, {ScopeGlobal | ScopeSession, TiDBStmtSummaryHistorySize, strconv.Itoa(config.GetGlobalConfig().StmtSummary.HistorySize)}, {ScopeGlobal | ScopeSession, TiDBCapturePlanBaseline, "off"}, @@ -965,6 +967,8 @@ const ( NetWriteTimeout = "net_write_timeout" // ThreadPoolSize is the name of 'thread_pool_size' variable. ThreadPoolSize = "thread_pool_size" + // WindowingUseHighPrecision is the name of 'windowing_use_high_precision' system variable. + WindowingUseHighPrecision = "windowing_use_high_precision" ) // GlobalVarAccessor is the interface for accessing global scope system and status variables. diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go index 4f8e24d31f7b0..99bf42269406a 100644 --- a/sessionctx/variable/tidb_vars.go +++ b/sessionctx/variable/tidb_vars.go @@ -329,6 +329,9 @@ const ( // TiDBEnableStmtSummary indicates whether the statement summary is enabled. TiDBEnableStmtSummary = "tidb_enable_stmt_summary" + // TiDBStmtSummaryInternalQuery indicates whether the statement summary contain internal query. + TiDBStmtSummaryInternalQuery = "tidb_stmt_summary_internal_query" + // TiDBStmtSummaryRefreshInterval indicates the refresh interval in seconds for each statement summary. TiDBStmtSummaryRefreshInterval = "tidb_stmt_summary_refresh_interval" diff --git a/sessionctx/variable/varsutil.go b/sessionctx/variable/varsutil.go index f841da222e35a..4595119dc5602 100644 --- a/sessionctx/variable/varsutil.go +++ b/sessionctx/variable/varsutil.go @@ -29,6 +29,7 @@ import ( "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/types" + "github.com/pingcap/tidb/util/collate" "github.com/pingcap/tidb/util/timeutil" ) @@ -391,6 +392,13 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string, return "1", nil } return value, ErrWrongValueForVar.GenWithStackByArgs(name, value) + case WindowingUseHighPrecision: + if strings.EqualFold(value, "OFF") || value == "0" { + return "OFF", nil + } else if strings.EqualFold(value, "ON") || value == "1" { + return "ON", nil + } + return value, ErrWrongValueForVar.GenWithStackByArgs(name, value) case TiDBSkipUTF8Check, TiDBOptAggPushDown, TiDBOptInSubqToJoinAndAgg, TiDBEnableFastAnalyze, TiDBBatchInsert, TiDBDisableTxnAutoRetry, TiDBEnableStreaming, TiDBEnableChunkRPC, @@ -643,7 +651,7 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string, return "", nil } return value, ErrWrongValueForVar.GenWithStackByArgs(name, value) - case TiDBEnableStmtSummary: + case TiDBEnableStmtSummary, TiDBStmtSummaryInternalQuery: switch { case strings.EqualFold(value, "ON") || value == "1": return "1", nil @@ -692,6 +700,10 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string, return value, errors.Errorf("%v(%d) cannot be smaller than %v or larger than %v", name, v, 10, 60*60*60) } return value, nil + case CollationConnection, CollationDatabase, CollationServer: + if _, err := collate.GetCollationByName(value); err != nil { + return value, errors.Trace(err) + } } return value, nil } diff --git a/statistics/analyze_jobs.go b/statistics/analyze_jobs.go index ff1fedfcf6464..ded4b7d66225d 100644 --- a/statistics/analyze_jobs.go +++ b/statistics/analyze_jobs.go @@ -49,9 +49,9 @@ const ( // AddNewAnalyzeJob adds new analyze job. func AddNewAnalyzeJob(job *AnalyzeJob) { + analyzeStatus.Lock() job.updateTime = time.Now() job.State = pending - analyzeStatus.Lock() analyzeStatus.jobs[job] = struct{}{} analyzeStatus.Unlock() } @@ -86,15 +86,15 @@ func GetAllAnalyzeJobs() []*AnalyzeJob { } jobs = append(jobs, analyzeStatus.history...) analyzeStatus.Unlock() - sort.Slice(jobs, func(i int, j int) bool { return jobs[i].updateTime.Before(jobs[j].updateTime) }) + sort.Slice(jobs, func(i int, j int) bool { return jobs[i].getUpdateTime().Before(jobs[j].getUpdateTime()) }) return jobs } // Start marks status of the analyze job as running and update the start time. func (job *AnalyzeJob) Start() { - now := time.Now() job.Mutex.Lock() job.State = running + now := time.Now() job.StartTime = now job.updateTime = now job.Mutex.Unlock() @@ -102,22 +102,26 @@ func (job *AnalyzeJob) Start() { // Update updates the row count of analyze job. func (job *AnalyzeJob) Update(rowCount int64) { - now := time.Now() job.Mutex.Lock() job.RowCount += rowCount - job.updateTime = now + job.updateTime = time.Now() job.Mutex.Unlock() } // Finish update the status of analyze job to finished or failed according to `meetError`. func (job *AnalyzeJob) Finish(meetError bool) { - now := time.Now() job.Mutex.Lock() if meetError { job.State = failed } else { job.State = finished } - job.updateTime = now + job.updateTime = time.Now() job.Mutex.Unlock() } + +func (job *AnalyzeJob) getUpdateTime() time.Time { + job.Mutex.Lock() + defer job.Mutex.Unlock() + return job.updateTime +} diff --git a/statistics/testdata/stats_suite_out.json b/statistics/testdata/stats_suite_out.json index beff161c0a96d..642ab6c157a29 100644 --- a/statistics/testdata/stats_suite_out.json +++ b/statistics/testdata/stats_suite_out.json @@ -3,7 +3,7 @@ "Name": "TestUniqCompEqualEst", "Cases": [ [ - "Point_Get_5 1.00 root table:t, index:a b" + "Point_Get_5 1.00 root table:t, index:PRIMARY(a, b) " ] ] }, @@ -11,48 +11,48 @@ "Name": "TestColumnIndexNullEstimation", "Cases": [ [ - "IndexReader_6 4.00 root index:IndexFullScan_5", - "└─IndexFullScan_5 4.00 cop[tikv] table:t, index:b, keep order:false" + "IndexReader_6 4.00 root index:IndexFullScan_5", + "└─IndexFullScan_5 4.00 cop[tikv] table:t, index:idx_b(b) keep order:false" ], [ - "IndexReader_6 1.00 root index:IndexFullScan_5", - "└─IndexFullScan_5 1.00 cop[tikv] table:t, index:b, keep order:false" + "IndexReader_6 1.00 root index:IndexFullScan_5", + "└─IndexFullScan_5 1.00 cop[tikv] table:t, index:idx_b(b) keep order:false" ], [ - "IndexReader_6 4.00 root index:IndexRangeScan_5", - "└─IndexRangeScan_5 4.00 cop[tikv] table:t, index:b, range:[NULL,NULL], (3,+inf], keep order:false" + "IndexReader_6 4.00 root index:IndexRangeScan_5", + "└─IndexRangeScan_5 4.00 cop[tikv] table:t, index:idx_b(b) range:[NULL,NULL], (3,+inf], keep order:false" ], [ - "IndexReader_5 5.00 root index:IndexFullScan_4", - "└─IndexFullScan_4 5.00 cop[tikv] table:t, index:b, keep order:false" + "IndexReader_5 5.00 root index:IndexFullScan_4", + "└─IndexFullScan_4 5.00 cop[tikv] table:t, index:idx_b(b) keep order:false" ], [ - "IndexReader_6 1.00 root index:IndexRangeScan_5", - "└─IndexRangeScan_5 1.00 cop[tikv] table:t, index:b, range:[-inf,4), keep order:false" + "IndexReader_6 1.00 root index:IndexRangeScan_5", + "└─IndexRangeScan_5 1.00 cop[tikv] table:t, index:idx_b(b) range:[-inf,4), keep order:false" ], [ - "TableReader_7 1.00 root data:Selection_6", - "└─Selection_6 1.00 cop[tikv] isnull(test.t.a)", - " └─TableFullScan_5 5.00 cop[tikv] table:t, keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] isnull(test.t.a)", + " └─TableFullScan_5 5.00 cop[tikv] table:t keep order:false" ], [ - "TableReader_7 4.00 root data:Selection_6", - "└─Selection_6 4.00 cop[tikv] not(isnull(test.t.a))", - " └─TableFullScan_5 5.00 cop[tikv] table:t, keep order:false" + "TableReader_7 4.00 root data:Selection_6", + "└─Selection_6 4.00 cop[tikv] not(isnull(test.t.a))", + " └─TableFullScan_5 5.00 cop[tikv] table:t keep order:false" ], [ - "TableReader_7 2.00 root data:Selection_6", - "└─Selection_6 2.00 cop[tikv] or(isnull(test.t.a), gt(test.t.a, 3))", - " └─TableFullScan_5 5.00 cop[tikv] table:t, keep order:false" + "TableReader_7 2.00 root data:Selection_6", + "└─Selection_6 2.00 cop[tikv] or(isnull(test.t.a), gt(test.t.a, 3))", + " └─TableFullScan_5 5.00 cop[tikv] table:t keep order:false" ], [ - "TableReader_5 5.00 root data:TableFullScan_4", - "└─TableFullScan_4 5.00 cop[tikv] table:t, keep order:false" + "TableReader_5 5.00 root data:TableFullScan_4", + "└─TableFullScan_4 5.00 cop[tikv] table:t keep order:false" ], [ - "TableReader_7 3.00 root data:Selection_6", - "└─Selection_6 3.00 cop[tikv] lt(test.t.a, 4)", - " └─TableFullScan_5 5.00 cop[tikv] table:t, keep order:false" + "TableReader_7 3.00 root data:Selection_6", + "└─Selection_6 3.00 cop[tikv] lt(test.t.a, 4)", + " └─TableFullScan_5 5.00 cop[tikv] table:t keep order:false" ] ] }, @@ -60,8 +60,8 @@ "Name": "TestDiscreteDistribution", "Cases": [ [ - "IndexReader_6 0.00 root index:IndexRangeScan_5", - "└─IndexRangeScan_5 0.00 cop[tikv] table:t, index:a, b, range:[\"tw\" -inf,\"tw\" 0), keep order:false" + "IndexReader_6 0.00 root index:IndexRangeScan_5", + "└─IndexRangeScan_5 0.00 cop[tikv] table:t, index:idx(a, b) range:[\"tw\" -inf,\"tw\" 0), keep order:false" ] ] }, @@ -69,13 +69,13 @@ "Name": "TestPrimaryKeySelectivity", "Cases": [ [ - "TableReader_7 3333.33 root data:Selection_6", - "└─Selection_6 3333.33 cop[tikv] gt(test.t.a, \"t\")", - " └─TableFullScan_5 10000.00 cop[tikv] table:t, keep order:false, stats:pseudo" + "TableReader_7 3333.33 root data:Selection_6", + "└─Selection_6 3333.33 cop[tikv] gt(test.t.a, \"t\")", + " └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], [ - "TableReader_6 3333.33 root data:TableRangeScan_5", - "└─TableRangeScan_5 3333.33 cop[tikv] table:t, range:(1,+inf], keep order:false, stats:pseudo" + "TableReader_6 3333.33 root data:TableRangeScan_5", + "└─TableRangeScan_5 3333.33 cop[tikv] table:t range:(1,+inf], keep order:false, stats:pseudo" ] ] }, @@ -83,8 +83,8 @@ "Name": "TestSelectCombinedLowBound", "Cases": [ [ - "IndexReader_6 7.00 root index:IndexRangeScan_5", - "└─IndexRangeScan_5 7.00 cop[tikv] table:t, index:kid, pid, range:[1,1], keep order:false" + "IndexReader_6 7.00 root index:IndexRangeScan_5", + "└─IndexRangeScan_5 7.00 cop[tikv] table:t, index:kid(kid, pid) range:[1,1], keep order:false" ] ] } diff --git a/store/mockstore/mocktikv/rpc.go b/store/mockstore/mocktikv/rpc.go index 75a8e873b5a29..324e838d6b574 100644 --- a/store/mockstore/mocktikv/rpc.go +++ b/store/mockstore/mocktikv/rpc.go @@ -971,13 +971,13 @@ func (c *RPCClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.R case tikvrpc.CmdUnsafeDestroyRange: panic("unimplemented") case tikvrpc.CmdRegisterLockObserver: - panic("unimplemented") + return nil, errors.New("unimplemented") case tikvrpc.CmdCheckLockObserver: - panic("unimplemented") + return nil, errors.New("unimplemented") case tikvrpc.CmdRemoveLockObserver: - panic("unimplemented") + return nil, errors.New("unimplemented") case tikvrpc.CmdPhysicalScanLock: - panic("unimplemented") + return nil, errors.New("unimplemented") case tikvrpc.CmdCop: r := req.Cop() if err := handler.checkRequestContext(reqCtx); err != nil { diff --git a/store/tikv/coprocessor.go b/store/tikv/coprocessor.go index 1f6fc177bc83f..4abd38f0f3e99 100644 --- a/store/tikv/coprocessor.go +++ b/store/tikv/coprocessor.go @@ -27,17 +27,21 @@ import ( "unsafe" "github.com/cznic/mathutil" + "github.com/gogo/protobuf/proto" "github.com/pingcap/errors" "github.com/pingcap/failpoint" "github.com/pingcap/kvproto/pkg/coprocessor" "github.com/pingcap/kvproto/pkg/kvrpcpb" + "github.com/pingcap/parser/terror" "github.com/pingcap/tidb/domain/infosync" + "github.com/pingcap/tidb/errno" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/metrics" "github.com/pingcap/tidb/store/tikv/tikvrpc" "github.com/pingcap/tidb/util/execdetails" "github.com/pingcap/tidb/util/logutil" "github.com/pingcap/tidb/util/memory" + "github.com/pingcap/tipb/go-tipb" "go.uber.org/zap" ) @@ -724,6 +728,10 @@ func (worker *copIteratorWorker) handleTaskOnce(bo *Backoffer, task *copTask, ch startTime := time.Now() resp, rpcCtx, storeAddr, err := worker.SendReqCtx(bo, req, task.region, ReadTimeoutMedium, task.storeType, task.storeAddr) if err != nil { + if task.storeType == kv.TiDB { + err = worker.handleTiDBSendReqErr(err, task, ch) + return nil, err + } return nil, errors.Trace(err) } // Set task.storeAddr field so its task.String() method have the store address information. @@ -1005,6 +1013,35 @@ func (worker *copIteratorWorker) handleCopResponse(bo *Backoffer, rpcCtx *RPCCon return nil, nil } +func (worker *copIteratorWorker) handleTiDBSendReqErr(err error, task *copTask, ch chan<- *copResponse) error { + errCode := errno.ErrUnknown + errMsg := err.Error() + if terror.ErrorEqual(err, ErrTiKVServerTimeout) { + errCode = errno.ErrTiKVServerTimeout + errMsg = "TiDB server timeout, address is " + task.storeAddr + } + selResp := tipb.SelectResponse{ + Warnings: []*tipb.Error{ + { + Code: int32(errCode), + Msg: errMsg, + }, + }, + } + data, err := proto.Marshal(&selResp) + if err != nil { + return errors.Trace(err) + } + resp := &copResponse{ + pbResp: &coprocessor.Response{ + Data: data, + }, + detail: &execdetails.ExecDetails{}, + } + worker.sendToRespCh(resp, ch, true) + return nil +} + func (worker *copIteratorWorker) buildCopTasksFromRemain(bo *Backoffer, lastRange *coprocessor.KeyRange, task *copTask) ([]*copTask, error) { remainedRanges := task.ranges if worker.req.Streaming && lastRange != nil { diff --git a/store/tikv/gcworker/gc_worker.go b/store/tikv/gcworker/gc_worker.go index b3b3b3ab1a710..6a659a72d5904 100644 --- a/store/tikv/gcworker/gc_worker.go +++ b/store/tikv/gcworker/gc_worker.go @@ -134,7 +134,7 @@ const ( gcScanLockModeKey = "tikv_gc_scan_lock_mode" gcScanLockModeLegacy = "legacy" gcScanLockModePhysical = "physical" - gcScanLockModeDefault = gcScanLockModeLegacy + gcScanLockModeDefault = gcScanLockModePhysical gcAutoConcurrencyKey = "tikv_gc_auto_concurrency" gcDefaultAutoConcurrency = true @@ -401,7 +401,7 @@ func (w *GCWorker) getGCConcurrency(ctx context.Context) (int, error) { return w.loadGCConcurrencyWithDefault() } - stores, err := w.getUpStores(ctx) + stores, err := w.getUpStoresForGC(ctx) concurrency := len(stores) if err != nil { logutil.Logger(ctx).Error("[gc worker] failed to get up stores to calculate concurrency. use config.", @@ -669,7 +669,7 @@ func (w *GCWorker) redoDeleteRanges(ctx context.Context, safePoint uint64, concu func (w *GCWorker) doUnsafeDestroyRangeRequest(ctx context.Context, startKey []byte, endKey []byte, concurrency int) error { // Get all stores every time deleting a region. So the store list is less probably to be stale. - stores, err := w.getUpStores(ctx) + stores, err := w.getUpStoresForGC(ctx) if err != nil { logutil.Logger(ctx).Error("[gc worker] delete ranges: got an error while trying to get store list from PD", zap.String("uuid", w.uuid), @@ -736,7 +736,47 @@ func (w *GCWorker) doUnsafeDestroyRangeRequest(ctx context.Context, startKey []b return nil } -func (w *GCWorker) getUpStores(ctx context.Context) ([]*metapb.Store, error) { +const ( + engineLabelKey = "engine" + engineLabelTiFlash = "tiflash" + engineLabelTiKV = "tikv" +) + +// needsGCOperationForStore checks if the store-level requests related to GC needs to be sent to the store. The store-level +// requests includes UnsafeDestroyRange, PhysicalScanLock, etc. +func needsGCOperationForStore(store *metapb.Store) (bool, error) { + engineLabel := "" + + for _, label := range store.GetLabels() { + if label.GetKey() == engineLabelKey { + engineLabel = label.GetValue() + break + } + } + + switch engineLabel { + case engineLabelTiFlash: + // For a TiFlash node, it uses other approach to delete dropped tables, so it's safe to skip sending + // UnsafeDestroyRange requests; it has only learner peers and their data must exist in TiKV, so it's safe to + // skip physical resolve locks for it. + return false, nil + + case "": + // If no engine label is set, it should be a TiKV node. + fallthrough + case engineLabelTiKV: + return true, nil + + default: + return true, errors.Errorf("unsupported store engine \"%v\" with storeID %v, addr %v", + engineLabel, + store.GetId(), + store.GetAddress()) + } +} + +// getUpStoresForGC gets the list of stores that needs to be processed during GC. +func (w *GCWorker) getUpStoresForGC(ctx context.Context) ([]*metapb.Store, error) { stores, err := w.pdClient.GetAllStores(ctx) if err != nil { return nil, errors.Trace(err) @@ -744,15 +784,22 @@ func (w *GCWorker) getUpStores(ctx context.Context) ([]*metapb.Store, error) { upStores := make([]*metapb.Store, 0, len(stores)) for _, store := range stores { - if store.State == metapb.StoreState_Up { + if store.State != metapb.StoreState_Up { + continue + } + needsGCOp, err := needsGCOperationForStore(store) + if err != nil { + return nil, errors.Trace(err) + } + if needsGCOp { upStores = append(upStores, store) } } return upStores, nil } -func (w *GCWorker) getUpStoresMap(ctx context.Context) (map[uint64]*metapb.Store, error) { - stores, err := w.getUpStores(ctx) +func (w *GCWorker) getUpStoresMapForGC(ctx context.Context) (map[uint64]*metapb.Store, error) { + stores, err := w.getUpStoresForGC(ctx) if err != nil { return nil, err } @@ -990,12 +1037,14 @@ func (w *GCWorker) resolveLocksPhysical(ctx context.Context, safePoint uint64) e zap.Uint64("safePoint", safePoint)) startTime := time.Now() - stores, err := w.getUpStoresMap(ctx) + stores, err := w.getUpStoresMapForGC(ctx) if err != nil { return errors.Trace(err) } - // TODO: If failed anywhere, should we try to cleanup the observers? + defer func() { + w.removeLockObservers(ctx, safePoint, stores) + }() err = w.registerLockObservers(ctx, safePoint, stores) if err != nil { @@ -1008,7 +1057,7 @@ func (w *GCWorker) resolveLocksPhysical(ctx context.Context, safePoint uint64) e return errors.Trace(err) } - stores, err = w.getUpStoresMap(ctx) + stores, err = w.getUpStoresMapForGC(ctx) if err != nil { return errors.Trace(err) } @@ -1034,8 +1083,6 @@ func (w *GCWorker) resolveLocksPhysical(ctx context.Context, safePoint uint64) e } } - w.removeLockObservers(ctx, safePoint, stores) - logutil.Logger(ctx).Info("[gc worker] finish resolve locks with physical scan locks", zap.String("uuid", w.uuid), zap.Uint64("safePoint", safePoint), diff --git a/store/tikv/gcworker/gc_worker_test.go b/store/tikv/gcworker/gc_worker_test.go index 50e812b76e288..cad8656345437 100644 --- a/store/tikv/gcworker/gc_worker_test.go +++ b/store/tikv/gcworker/gc_worker_test.go @@ -440,7 +440,7 @@ func (s *testGCWorkerSuite) TestCheckGCMode(c *C) { func (s *testGCWorkerSuite) TestCheckScanLockMode(c *C) { usePhysical, err := s.gcWorker.checkUsePhysicalScanLock() c.Assert(err, IsNil) - c.Assert(usePhysical, Equals, false) + c.Assert(usePhysical, Equals, true) // This is a hidden config, so default value will not be inserted to table. str, err := s.gcWorker.loadValueFromSysTable(gcScanLockModeKey) c.Assert(err, IsNil) @@ -465,6 +465,36 @@ func (s *testGCWorkerSuite) TestCheckScanLockMode(c *C) { c.Assert(usePhysical, Equals, false) } +func (s *testGCWorkerSuite) TestNeedsGCOperationForStore(c *C) { + newStore := func(hasEngineLabel bool, engineLabel string) *metapb.Store { + store := &metapb.Store{} + if hasEngineLabel { + store.Labels = []*metapb.StoreLabel{{Key: engineLabelKey, Value: engineLabel}} + } + return store + } + + // TiKV needs to do the store-level GC operations. + res, err := needsGCOperationForStore(newStore(false, "")) + c.Assert(err, IsNil) + c.Assert(res, IsTrue) + res, err = needsGCOperationForStore(newStore(true, "")) + c.Assert(err, IsNil) + c.Assert(res, IsTrue) + res, err = needsGCOperationForStore(newStore(true, engineLabelTiKV)) + c.Assert(err, IsNil) + c.Assert(res, IsTrue) + + // TiFlash does not need these operations. + res, err = needsGCOperationForStore(newStore(true, engineLabelTiFlash)) + c.Assert(err, IsNil) + c.Assert(res, IsFalse) + + // Throw an error for unknown store types. + _, err = needsGCOperationForStore(newStore(true, "invalid")) + c.Assert(err, NotNil) +} + const ( failRPCErr = 0 failNilResp = 1 @@ -508,7 +538,7 @@ func (s *testGCWorkerSuite) testDeleteRangesFailureImpl(c *C, failType int) { c.Assert(err, IsNil) c.Assert(preparedRanges, DeepEquals, ranges) - stores, err := s.gcWorker.getUpStores(context.Background()) + stores, err := s.gcWorker.getUpStoresForGC(context.Background()) c.Assert(err, IsNil) c.Assert(len(stores), Equals, 3) @@ -869,7 +899,7 @@ func (s *testGCWorkerSuite) makeMergedMockClient(c *C, count int) (*mergeLockSca const scanLockLimit = 3 - storesMap, err := s.gcWorker.getUpStoresMap(context.Background()) + storesMap, err := s.gcWorker.getUpStoresMapForGC(context.Background()) c.Assert(err, IsNil) scanner := newMergeLockScanner(100000, s.client, storesMap) scanner.scanLockLimit = scanLockLimit diff --git a/store/tikv/region_request.go b/store/tikv/region_request.go index 5b55b49b05cd5..1e20e09c6e229 100644 --- a/store/tikv/region_request.go +++ b/store/tikv/region_request.go @@ -108,6 +108,10 @@ func (s *RegionRequestSender) SendReqCtx( if bo.vars != nil && bo.vars.Hook != nil { bo.vars.Hook("callBackofferHook", bo.vars) } + case "requestTiDBStoreError": + if sType == kv.TiDB { + failpoint.Return(nil, nil, ErrTiKVServerTimeout) + } } }) diff --git a/table/column.go b/table/column.go index 4dedd7eb2fa51..60c4b4f974f65 100644 --- a/table/column.go +++ b/table/column.go @@ -47,6 +47,8 @@ type Column struct { *model.ColumnInfo // If this column is a generated column, the expression will be stored here. GeneratedExpr ast.ExprNode + // If this column has default expr value, this expression will be stored here. + DefaultExpr ast.ExprNode } // String implements fmt.Stringer interface. @@ -82,6 +84,7 @@ func ToColumn(col *model.ColumnInfo) *Column { return &Column{ col, nil, + nil, } } @@ -379,6 +382,20 @@ func GetColDefaultValue(ctx sessionctx.Context, col *model.ColumnInfo) (types.Da return getColDefaultExprValue(ctx, col, defaultValue.(string)) } +// EvalColDefaultExpr eval default expr node to explicit default value. +func EvalColDefaultExpr(ctx sessionctx.Context, col *model.ColumnInfo, defaultExpr ast.ExprNode) (types.Datum, error) { + d, err := expression.EvalAstExpr(ctx, defaultExpr) + if err != nil { + return types.Datum{}, err + } + // Check the evaluated data type by cast. + value, err := CastValue(ctx, d, col) + if err != nil { + return types.Datum{}, err + } + return value, nil +} + func getColDefaultExprValue(ctx sessionctx.Context, col *model.ColumnInfo, defaultValue string) (types.Datum, error) { var defaultExpr ast.ExprNode expr := fmt.Sprintf("select %s", defaultValue) diff --git a/table/tables/tables.go b/table/tables/tables.go index db293c1c415c8..18601493b2e59 100644 --- a/table/tables/tables.go +++ b/table/tables/tables.go @@ -122,6 +122,14 @@ func TableFromMeta(allocs autoid.Allocators, tblInfo *model.TableInfo) (table.Ta } col.GeneratedExpr = expr } + // default value is expr. + if col.DefaultIsExpr { + expr, err := parseExpression(colInfo.DefaultValue.(string)) + if err != nil { + return nil, err + } + col.DefaultExpr = expr + } columns = append(columns, col) } diff --git a/tools/check/check-tidy.sh b/tools/check/check-tidy.sh index 5850a402fd3f0..bb4e789db82c4 100755 --- a/tools/check/check-tidy.sh +++ b/tools/check/check-tidy.sh @@ -22,4 +22,6 @@ set -euo pipefail # go mod tidy do not support symlink cd -P . +cp go.sum /tmp/go.sum.before GO111MODULE=on go mod tidy +diff -q go.sum /tmp/go.sum.before diff --git a/types/compare.go b/types/compare.go index ba5b26a347c60..fc519b3d780d5 100644 --- a/types/compare.go +++ b/types/compare.go @@ -115,7 +115,7 @@ func CompareFloat64(x, y float64) int { // CompareString returns an integer comparing the string x to y with the specified collation and length. func CompareString(x, y, collation string) int { - return collate.GetCollator(collation).Compare(x, y, collate.NewCollatorOption(0)) + return collate.GetCollator(collation).Compare(x, y) } // CompareDuration returns an integer comparing the duration x to y. diff --git a/types/errors.go b/types/errors.go index 20af1424e941e..e55eb32208015 100644 --- a/types/errors.go +++ b/types/errors.go @@ -74,5 +74,5 @@ var ( // ErrInvalidWeekModeFormat is returned when the week mode is wrong. ErrInvalidWeekModeFormat = terror.ClassTypes.New(mysql.ErrInvalidWeekModeFormat, mysql.MySQLErrName[mysql.ErrInvalidWeekModeFormat]) // ErrWrongValue is returned when the input value is in wrong format. - ErrWrongValue = terror.ClassTypes.New(mysql.ErrWrongValue, mysql.MySQLErrName[mysql.ErrWrongValue]) + ErrWrongValue = terror.ClassTypes.New(mysql.ErrTruncatedWrongValue, mysql.MySQLErrName[mysql.ErrWrongValue]) ) diff --git a/util/chunk/chunk_util.go b/util/chunk/chunk_util.go index 01bd5fa3f46a1..2a72d6770eaeb 100644 --- a/util/chunk/chunk_util.go +++ b/util/chunk/chunk_util.go @@ -75,7 +75,7 @@ func CopySelectedJoinRowsDirect(src *Chunk, selected []bool, dst *Chunk) (bool, // Return true if at least one joined row was selected. // // NOTE: All the outer rows in the source Chunk should be the same. -func CopySelectedJoinRowsWithSameOuterRows(src *Chunk, innerColOffset, outerColOffset int, selected []bool, dst *Chunk) (bool, error) { +func CopySelectedJoinRowsWithSameOuterRows(src *Chunk, innerColOffset, innerColLen, outerColOffset, outerColLen int, selected []bool, dst *Chunk) (bool, error) { if src.NumRows() == 0 { return false, nil } @@ -83,8 +83,8 @@ func CopySelectedJoinRowsWithSameOuterRows(src *Chunk, innerColOffset, outerColO return false, errors.New(msgErrSelNotNil) } - numSelected := copySelectedInnerRows(innerColOffset, outerColOffset, src, selected, dst) - copyOuterRows(innerColOffset, outerColOffset, src, numSelected, dst) + numSelected := copySelectedInnerRows(innerColOffset, innerColLen, src, selected, dst) + copySameOuterRows(outerColOffset, outerColLen, src, numSelected, dst) dst.numVirtualRows += numSelected return numSelected > 0, nil } @@ -92,13 +92,8 @@ func CopySelectedJoinRowsWithSameOuterRows(src *Chunk, innerColOffset, outerColO // copySelectedInnerRows copies the selected inner rows from the source Chunk // to the destination Chunk. // return the number of rows which is selected. -func copySelectedInnerRows(innerColOffset, outerColOffset int, src *Chunk, selected []bool, dst *Chunk) int { - var srcCols []*Column - if innerColOffset == 0 { - srcCols = src.columns[:outerColOffset] - } else { - srcCols = src.columns[innerColOffset:] - } +func copySelectedInnerRows(innerColOffset, innerColLen int, src *Chunk, selected []bool, dst *Chunk) int { + srcCols := src.columns[innerColOffset : innerColOffset+innerColLen] if len(srcCols) == 0 { numSelected := 0 for _, s := range selected { @@ -140,19 +135,14 @@ func copySelectedInnerRows(innerColOffset, outerColOffset int, src *Chunk, selec return dst.columns[innerColOffset].length - oldLen } -// copyOuterRows copies the continuous 'numRows' outer rows in the source Chunk +// copySameOuterRows copies the continuous 'numRows' outer rows in the source Chunk // to the destination Chunk. -func copyOuterRows(innerColOffset, outerColOffset int, src *Chunk, numRows int, dst *Chunk) { - if numRows <= 0 { +func copySameOuterRows(outerColOffset, outerColLen int, src *Chunk, numRows int, dst *Chunk) { + if numRows <= 0 || outerColLen <= 0 { return } row := src.GetRow(0) - var srcCols []*Column - if innerColOffset == 0 { - srcCols = src.columns[outerColOffset:] - } else { - srcCols = src.columns[:innerColOffset] - } + srcCols := src.columns[outerColOffset : outerColOffset+outerColLen] for i, srcCol := range srcCols { dstCol := dst.columns[outerColOffset+i] dstCol.appendMultiSameNullBitmap(!srcCol.IsNull(row.idx), numRows) diff --git a/util/chunk/chunk_util_test.go b/util/chunk/chunk_util_test.go index 86a72017c3bc6..b8ca3f0b69b12 100644 --- a/util/chunk/chunk_util_test.go +++ b/util/chunk/chunk_util_test.go @@ -21,7 +21,7 @@ import ( "github.com/pingcap/tidb/types" ) -// getChk generate a chunk of data, isFirst3ColTheSame means the first three columns are the same. +// getChk generate a chunk of data, isLast3ColTheSame means the last three columns are the same. func getChk(isLast3ColTheSame bool) (*Chunk, *Chunk, []bool) { numRows := 1024 srcChk := newChunkWithInitCap(numRows, 0, 0, 8, 8, sizeTime, 0) @@ -61,7 +61,34 @@ func TestCopySelectedJoinRows(t *testing.T) { } // batch copy dstChk2 := newChunkWithInitCap(numRows, 0, 0, 8, 8, sizeTime, 0) - CopySelectedJoinRowsWithSameOuterRows(srcChk, 0, 3, selected, dstChk2) + CopySelectedJoinRowsWithSameOuterRows(srcChk, 0, 3, 3, 3, selected, dstChk2) + + if !reflect.DeepEqual(dstChk, dstChk2) { + t.Fatal() + } + numSelected := 0 + for i := range selected { + if selected[i] { + numSelected++ + } + } + if dstChk2.numVirtualRows != numSelected || dstChk2.NumRows() != numSelected { + t.Fatal(dstChk2.numVirtualRows, dstChk2.NumRows(), numSelected) + } +} + +func TestCopySelectedJoinRowsWithoutSameOuters(t *testing.T) { + srcChk, dstChk, selected := getChk(false) + numRows := srcChk.NumRows() + for i := 0; i < numRows; i++ { + if !selected[i] { + continue + } + dstChk.AppendRow(srcChk.GetRow(i)) + } + // batch copy + dstChk2 := newChunkWithInitCap(numRows, 0, 0, 8, 8, sizeTime, 0) + CopySelectedJoinRowsWithSameOuterRows(srcChk, 0, 6, 0, 0, selected, dstChk2) if !reflect.DeepEqual(dstChk, dstChk2) { t.Fatal() @@ -105,6 +132,7 @@ func TestCopySelectedJoinRowsDirect(t *testing.T) { } func TestCopySelectedVirtualNum(t *testing.T) { + // srcChk does not contain columns srcChk := newChunk() srcChk.TruncateTo(3) dstChk := newChunk() @@ -118,7 +146,7 @@ func TestCopySelectedVirtualNum(t *testing.T) { } dstChk = newChunk() - ok, err = CopySelectedJoinRowsWithSameOuterRows(srcChk, 0, 0, selected, dstChk) + ok, err = CopySelectedJoinRowsWithSameOuterRows(srcChk, 0, 0, 0, 0, selected, dstChk) if err != nil || !ok { t.Fatal(ok, err) } @@ -132,7 +160,7 @@ func TestCopySelectedVirtualNum(t *testing.T) { srcChk.AppendInt64(0, 1) srcChk.AppendInt64(0, 2) dstChk = newChunkWithInitCap(0, 8) - ok, err = CopySelectedJoinRowsWithSameOuterRows(srcChk, 0, 1, selected, dstChk) + ok, err = CopySelectedJoinRowsWithSameOuterRows(srcChk, 0, 1, 1, 0, selected, dstChk) if err != nil || !ok { t.Fatal(ok, err) } @@ -149,7 +177,7 @@ func TestCopySelectedVirtualNum(t *testing.T) { srcChk.AppendInt64(0, 3) srcChk.AppendInt64(0, 3) dstChk = newChunkWithInitCap(0, 8) - ok, err = CopySelectedJoinRowsWithSameOuterRows(srcChk, 1, 0, selected, dstChk) + ok, err = CopySelectedJoinRowsWithSameOuterRows(srcChk, 1, 0, 0, 1, selected, dstChk) if err != nil || !ok { t.Fatal(ok, err) } @@ -167,7 +195,7 @@ func BenchmarkCopySelectedJoinRows(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { dstChk.Reset() - CopySelectedJoinRowsWithSameOuterRows(srcChk, 0, 3, selected, dstChk) + CopySelectedJoinRowsWithSameOuterRows(srcChk, 0, 3, 3, 3, selected, dstChk) } } func BenchmarkCopySelectedJoinRowsDirect(b *testing.B) { diff --git a/util/chunk/row_container.go b/util/chunk/row_container.go index 7cd2076c49189..5272a2045f4ca 100644 --- a/util/chunk/row_container.go +++ b/util/chunk/row_container.go @@ -226,7 +226,8 @@ func (a *SpillDiskAction) Action(t *memory.Tracker) { } a.once.Do(func() { atomic.StoreUint32(&a.c.exceeded, 1) - logutil.BgLogger().Info("memory exceeds quota, spill to disk now.", zap.String("memory", t.String())) + logutil.BgLogger().Info("memory exceeds quota, spill to disk now.", + zap.Int64("consumed", t.BytesConsumed()), zap.Int64("quota", t.GetBytesLimit())) }) } diff --git a/util/codec/codec.go b/util/codec/codec.go index 525032a00432e..75fd3195be164 100644 --- a/util/codec/codec.go +++ b/util/codec/codec.go @@ -197,7 +197,7 @@ func EncodeMySQLTime(sc *stmtctx.StatementContext, t types.Time, tp byte, b []by func encodeString(b []byte, val types.Datum, comparable bool) []byte { if collate.NewCollationEnabled() && comparable { - return encodeBytes(b, collate.GetCollator(val.Collation()).Key(val.GetString(), collate.CollatorOption{PadLen: val.Length()}), true) + return encodeBytes(b, collate.GetCollator(val.Collation()).Key(val.GetString()), true) } return encodeBytes(b, val.GetBytes(), comparable) } @@ -1187,11 +1187,11 @@ func HashGroupKey(sc *stmtctx.StatementContext, n int, col *chunk.Column, buf [] // ConvertByCollation converts these bytes according to its collation. func ConvertByCollation(raw []byte, tp *types.FieldType) []byte { collator := collate.GetCollator(tp.Collate) - return collator.Key(string(hack.String(raw)), collate.NewCollatorOption(tp.Flen)) + return collator.Key(string(hack.String(raw))) } // ConvertByCollationStr converts this string according to its collation. func ConvertByCollationStr(str string, tp *types.FieldType) string { collator := collate.GetCollator(tp.Collate) - return string(hack.String(collator.Key(str, collate.NewCollatorOption(tp.Flen)))) + return string(hack.String(collator.Key(str))) } diff --git a/util/collate/bin.go b/util/collate/bin.go new file mode 100644 index 0000000000000..3761c683530e5 --- /dev/null +++ b/util/collate/bin.go @@ -0,0 +1,70 @@ +// Copyright 2020 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +package collate + +import ( + "strings" + + "github.com/pingcap/tidb/util/stringutil" +) + +type binCollator struct { +} + +// Compare implement Collator interface. +func (bc *binCollator) Compare(a, b string) int { + return strings.Compare(a, b) +} + +// Key implement Collator interface. +func (bc *binCollator) Key(str string) []byte { + return []byte(str) +} + +// Pattern implements Collator interface. +func (bc *binCollator) Pattern() WildcardPattern { + return &binPattern{} +} + +type binPaddingCollator struct { +} + +func (bpc *binPaddingCollator) Compare(a, b string) int { + return strings.Compare(truncateTailingSpace(a), truncateTailingSpace(b)) +} + +func (bpc *binPaddingCollator) Key(str string) []byte { + return []byte(truncateTailingSpace(str)) +} + +// Pattern implements Collator interface. +// Notice that trailing spaces are significant. +func (bpc *binPaddingCollator) Pattern() WildcardPattern { + return &binPattern{} +} + +type binPattern struct { + patChars []byte + patTypes []byte +} + +// Compile implements WildcardPattern interface. +func (p *binPattern) Compile(patternStr string, escape byte) { + p.patChars, p.patTypes = stringutil.CompilePattern(patternStr, escape) +} + +// Compile implements WildcardPattern interface. +func (p *binPattern) DoMatch(str string) bool { + return stringutil.DoMatch(str, p.patChars, p.patTypes) +} diff --git a/util/collate/collate.go b/util/collate/collate.go index 759e65a8fbdfc..1ff42a5321ad2 100644 --- a/util/collate/collate.go +++ b/util/collate/collate.go @@ -14,21 +14,27 @@ package collate import ( - "strings" + "sort" "sync/atomic" + "github.com/pingcap/errors" + "github.com/pingcap/parser/charset" "github.com/pingcap/parser/mysql" + "github.com/pingcap/parser/terror" "github.com/pingcap/tidb/util/logutil" - "github.com/pingcap/tidb/util/stringutil" "go.uber.org/zap" ) var ( - collatorMap map[string]Collator - collatorIDMap map[int]Collator newCollatorMap map[string]Collator newCollatorIDMap map[int]Collator newCollationEnabled int32 + + // binCollatorInstance is a singleton used for all collations when newCollationEnabled is false. + binCollatorInstance = &binCollator{} + + // ErrUnsupportedCollation is returned when an unsupported collation is specified. + ErrUnsupportedCollation = terror.ClassDDL.New(mysql.ErrUnknownCollation, "Unsupported collation when new collation is enabled: '%-.64s'") ) // DefaultLen is set for datum if the string datum don't know its length. @@ -36,38 +42,25 @@ const ( DefaultLen = 0 ) -// CompatibleCollate checks whether the two collate are the same. -func CompatibleCollate(collate1, collate2 string) bool { - if (collate1 == "utf8mb4_general_ci" || collate1 == "utf8_general_ci") && (collate2 == "utf8mb4_general_ci" || collate2 == "utf8_general_ci") { - return true - } else if (collate1 == "utf8mb4_bin" || collate1 == "utf8_bin") && (collate2 == "utf8mb4_bin" || collate2 == "utf8_bin") { - return true - } else { - return collate1 == collate2 - } -} - -// CollatorOption is the option of collator. -type CollatorOption struct { - PadLen int -} - -// NewCollatorOption creates a new CollatorOption with the specified arguments. -func NewCollatorOption(padLen int) CollatorOption { - return CollatorOption{padLen} -} - // Collator provides functionality for comparing strings for a given // collation order. type Collator interface { // Compare returns an integer comparing the two strings. The result will be 0 if a == b, -1 if a < b, and +1 if a > b. - Compare(a, b string, opt CollatorOption) int + Compare(a, b string) int // Key returns the collate key for str. If the collation is padding, make sure the PadLen >= len(rune[]str) in opt. - Key(str string, opt CollatorOption) []byte + Key(str string) []byte // Pattern get a collation-aware WildcardPattern. Pattern() WildcardPattern } +// WildcardPattern is the interface used for wildcard pattern match. +type WildcardPattern interface { + // Compile compiles the patternStr with specified escape character. + Compile(patternStr string, escape byte) + // DoMatch tries to match the str with compiled pattern, `Compile()` must be called before calling it. + DoMatch(str string) bool +} + // EnableNewCollations enables the new collation. func EnableNewCollations() { SetNewCollationEnabledForTest(true) @@ -88,6 +81,17 @@ func NewCollationEnabled() bool { return atomic.LoadInt32(&newCollationEnabled) == 1 } +// CompatibleCollate checks whether the two collate are the same. +func CompatibleCollate(collate1, collate2 string) bool { + if (collate1 == "utf8mb4_general_ci" || collate1 == "utf8_general_ci") && (collate2 == "utf8mb4_general_ci" || collate2 == "utf8_general_ci") { + return true + } else if (collate1 == "utf8mb4_bin" || collate1 == "utf8_bin") && (collate2 == "utf8mb4_bin" || collate2 == "utf8_bin") { + return true + } else { + return collate1 == collate2 + } +} + // RewriteNewCollationIDIfNeeded rewrites a collation id if the new collations are enabled. // When new collations are enabled, we turn the collation id to negative so that other the // components of the cluster(for example, TiKV) is able to aware of it without any change to @@ -121,15 +125,15 @@ func GetCollator(collate string) Collator { if atomic.LoadInt32(&newCollationEnabled) == 1 { ctor, ok := newCollatorMap[collate] if !ok { + logutil.BgLogger().Warn( + "Unable to get collator by name, use binCollator instead.", + zap.String("name", collate), + zap.Stack("stack")) return newCollatorMap["utf8mb4_bin"] } return ctor } - ctor, ok := collatorMap[collate] - if !ok { - return collatorMap["utf8mb4_bin"] - } - return ctor + return binCollatorInstance } // GetCollatorByID get the collator according to id, it will return the binary collator if the corresponding collator doesn't exist. @@ -137,33 +141,15 @@ func GetCollatorByID(id int) Collator { if atomic.LoadInt32(&newCollationEnabled) == 1 { ctor, ok := newCollatorIDMap[id] if !ok { + logutil.BgLogger().Warn( + "Unable to get collator by ID, use binCollator instead.", + zap.Int("ID", id), + zap.Stack("stack")) return newCollatorMap["utf8mb4_bin"] } return ctor } - ctor, ok := collatorIDMap[id] - if !ok { - return collatorMap["utf8mb4_bin"] - } - return ctor -} - -type binCollator struct { -} - -// Compare implement Collator interface. -func (bc *binCollator) Compare(a, b string, opt CollatorOption) int { - return strings.Compare(a, b) -} - -// Key implement Collator interface. -func (bc *binCollator) Key(str string, opt CollatorOption) []byte { - return []byte(str) -} - -// Pattern implements Collator interface. -func (bc *binCollator) Pattern() WildcardPattern { - return &binPattern{} + return binCollatorInstance } // CollationID2Name return the collation name by the given id. @@ -171,12 +157,47 @@ func (bc *binCollator) Pattern() WildcardPattern { func CollationID2Name(id int32) string { name, ok := mysql.Collations[uint8(id)] if !ok { + // TODO(bb7133): fix repeating logs when the following code is uncommented. + //logutil.BgLogger().Warn( + // "Unable to get collation name from ID, use default collation instead.", + // zap.Int32("ID", id), + // zap.Stack("stack")) return mysql.DefaultCollationName } return name } -type binPaddingCollator struct { +// GetCollationByName wraps charset.GetCollationByName, it checks the collation. +func GetCollationByName(name string) (coll *charset.Collation, err error) { + if coll, err = charset.GetCollationByName(name); err != nil { + return nil, errors.Trace(err) + } + if atomic.LoadInt32(&newCollationEnabled) == 1 { + if _, ok := newCollatorIDMap[coll.ID]; !ok { + return nil, ErrUnsupportedCollation.GenWithStackByArgs(name) + } + } + return +} + +// GetSupportedCollations gets information for all collations supported so far. +func GetSupportedCollations() []*charset.Collation { + if atomic.LoadInt32(&newCollationEnabled) == 1 { + newSupportedCollations := make([]*charset.Collation, 0, len(newCollatorMap)) + for name := range newCollatorMap { + if coll, err := charset.GetCollationByName(name); err != nil { + // Should never happens. + terror.Log(err) + } else { + newSupportedCollations = append(newSupportedCollations, coll) + } + } + sort.Slice(newSupportedCollations, func(i int, j int) bool { + return newSupportedCollations[i].Name < newSupportedCollations[j].Name + }) + return newSupportedCollations + } + return charset.GetSupportedCollations() } func truncateTailingSpace(str string) string { @@ -191,71 +212,22 @@ func truncateTailingSpace(str string) string { return str } -func (bpc *binPaddingCollator) Compare(a, b string, opt CollatorOption) int { - return strings.Compare(truncateTailingSpace(a), truncateTailingSpace(b)) -} - -func (bpc *binPaddingCollator) Key(str string, opt CollatorOption) []byte { - return []byte(truncateTailingSpace(str)) -} - -// Pattern implements Collator interface. -// Notice that trailing spaces are significant. -func (bpc *binPaddingCollator) Pattern() WildcardPattern { - return &binPattern{} -} - -// WildcardPattern is the interface used for wildcard pattern match. -type WildcardPattern interface { - // Compile compiles the patternStr with specified escape character. - Compile(patternStr string, escape byte) - // DoMatch tries to match the str with compiled pattern, `Compile()` must be called before calling it. - DoMatch(str string) bool -} - -type binPattern struct { - patChars []byte - patTypes []byte -} - -// Compile implements WildcardPattern interface. -func (p *binPattern) Compile(patternStr string, escape byte) { - p.patChars, p.patTypes = stringutil.CompilePattern(patternStr, escape) -} - -// Compile implements WildcardPattern interface. -func (p *binPattern) DoMatch(str string) bool { - return stringutil.DoMatch(str, p.patChars, p.patTypes) -} - func init() { - collatorMap = make(map[string]Collator) - collatorIDMap = make(map[int]Collator) newCollatorMap = make(map[string]Collator) newCollatorIDMap = make(map[int]Collator) - collatorMap["binary"] = &binCollator{} - collatorMap["utf8mb4_bin"] = &binCollator{} - collatorMap["utf8_bin"] = &binCollator{} - collatorMap["utf8mb4_general_ci"] = &binCollator{} - collatorMap["utf8_general_ci"] = &binCollator{} - - // See https://github.com/pingcap/parser/blob/master/charset/charset.go for more information about the IDs. - collatorIDMap[63] = &binCollator{} - collatorIDMap[46] = &binCollator{} - collatorIDMap[83] = &binCollator{} - collatorIDMap[45] = &binCollator{} - collatorIDMap[33] = &binCollator{} - newCollatorMap["binary"] = &binCollator{} + newCollatorIDMap[int(mysql.CollationNames["binary"])] = &binCollator{} + newCollatorMap["ascii_bin"] = &binPaddingCollator{} + newCollatorIDMap[int(mysql.CollationNames["ascii_bin"])] = &binPaddingCollator{} + newCollatorMap["latin1_bin"] = &binPaddingCollator{} + newCollatorIDMap[int(mysql.CollationNames["latin1_bin"])] = &binPaddingCollator{} newCollatorMap["utf8mb4_bin"] = &binPaddingCollator{} + newCollatorIDMap[int(mysql.CollationNames["utf8mb4_bin"])] = &binPaddingCollator{} newCollatorMap["utf8_bin"] = &binPaddingCollator{} + newCollatorIDMap[int(mysql.CollationNames["utf8_bin"])] = &binPaddingCollator{} newCollatorMap["utf8mb4_general_ci"] = &generalCICollator{} + newCollatorIDMap[int(mysql.CollationNames["utf8mb4_general_ci"])] = &generalCICollator{} newCollatorMap["utf8_general_ci"] = &generalCICollator{} - - newCollatorIDMap[63] = &binCollator{} - newCollatorIDMap[46] = &binPaddingCollator{} - newCollatorIDMap[83] = &binPaddingCollator{} - newCollatorIDMap[45] = &generalCICollator{} - newCollatorIDMap[33] = &generalCICollator{} + newCollatorIDMap[int(mysql.CollationNames["utf8_general_ci"])] = &generalCICollator{} } diff --git a/util/collate/collate_test.go b/util/collate/collate_test.go index ca5fc2b706c41..358807a60a5c6 100644 --- a/util/collate/collate_test.go +++ b/util/collate/collate_test.go @@ -45,14 +45,14 @@ type keyTable struct { func testCompareTable(table []compareTable, collate string, c *C) { for i, t := range table { comment := Commentf("%d %v %v", i, t.Left, t.Right) - c.Assert(GetCollator(collate).Compare(t.Left, t.Right, CollatorOption{}), Equals, t.Expect, comment) + c.Assert(GetCollator(collate).Compare(t.Left, t.Right), Equals, t.Expect, comment) } } func testKeyTable(table []keyTable, collate string, c *C) { for i, t := range table { comment := Commentf("%d %s", i, t.Str) - c.Assert(GetCollator(collate).Key(t.Str, CollatorOption{}), DeepEquals, t.Expect, comment) + c.Assert(GetCollator(collate).Key(t.Str), DeepEquals, t.Expect, comment) } } diff --git a/util/collate/general_ci.go b/util/collate/general_ci.go index 9c89a9c30b567..122030b1a46fe 100644 --- a/util/collate/general_ci.go +++ b/util/collate/general_ci.go @@ -135,7 +135,7 @@ func doMatchGeneralCI(str string, patWeights []uint16, patTypes []byte) bool { } // Compare implements Collator interface. -func (gc *generalCICollator) Compare(a, b string, opt CollatorOption) int { +func (gc *generalCICollator) Compare(a, b string) int { a = truncateTailingSpace(a) b = truncateTailingSpace(b) for len(a) > 0 && len(b) > 0 { @@ -153,7 +153,7 @@ func (gc *generalCICollator) Compare(a, b string, opt CollatorOption) int { } // Key implements Collator interface. -func (gc *generalCICollator) Key(str string, opt CollatorOption) []byte { +func (gc *generalCICollator) Key(str string) []byte { str = truncateTailingSpace(str) buf := make([]byte, 0, len(str)) i := 0 diff --git a/util/execdetails/execdetails.go b/util/execdetails/execdetails.go index 9d300b511347f..c1f4ad98fc205 100644 --- a/util/execdetails/execdetails.go +++ b/util/execdetails/execdetails.go @@ -279,26 +279,25 @@ func (crs *CopRuntimeStats) String() string { return "" } - var totalRows, totalTasks int64 + var totalTasks int64 var totalIters int32 procTimes := make([]time.Duration, 0, 32) for _, instanceStats := range crs.stats { for _, stat := range instanceStats { procTimes = append(procTimes, time.Duration(stat.consume)*time.Nanosecond) - totalRows += stat.rows totalIters += stat.loop totalTasks++ } } if totalTasks == 1 { - return fmt.Sprintf("time:%v, loops:%d, rows:%d", procTimes[0], totalIters, totalRows) + return fmt.Sprintf("time:%v, loops:%d", procTimes[0], totalIters) } n := len(procTimes) sort.Slice(procTimes, func(i, j int) bool { return procTimes[i] < procTimes[j] }) - return fmt.Sprintf("proc max:%v, min:%v, p80:%v, p95:%v, rows:%v, iters:%v, tasks:%v", - procTimes[n-1], procTimes[0], procTimes[n*4/5], procTimes[n*19/20], totalRows, totalIters, totalTasks) + return fmt.Sprintf("proc max:%v, min:%v, p80:%v, p95:%v, iters:%v, tasks:%v", + procTimes[n-1], procTimes[0], procTimes[n*4/5], procTimes[n*19/20], totalIters, totalTasks) } // ReaderRuntimeStats collects stats for TableReader, IndexReader and IndexLookupReader @@ -479,7 +478,7 @@ func (e *RuntimeStats) GetActRows() int64 { } func (e *RuntimeStats) String() string { - result := fmt.Sprintf("time:%v, loops:%d, rows:%d", time.Duration(e.consume), e.loop, e.rows) + result := fmt.Sprintf("time:%v, loops:%d", time.Duration(e.consume), e.loop) if len(e.concurrency) > 0 { for _, concurrency := range e.concurrency { if concurrency.concurrencyNum > 0 { diff --git a/util/execdetails/execdetails_test.go b/util/execdetails/execdetails_test.go index 0a72e58d03e98..eff1b61784b7e 100644 --- a/util/execdetails/execdetails_test.go +++ b/util/execdetails/execdetails_test.go @@ -86,7 +86,7 @@ func TestCopRuntimeStats(t *testing.T) { t.Fatal("exist") } cop := stats.GetCopStats("table_scan") - if cop.String() != "proc max:2ns, min:1ns, p80:2ns, p95:2ns, rows:3, iters:3, tasks:2" { + if cop.String() != "proc max:2ns, min:1ns, p80:2ns, p95:2ns, iters:3, tasks:2" { t.Fatal("table_scan") } copStats := cop.stats["8.8.8.8"] @@ -95,11 +95,11 @@ func TestCopRuntimeStats(t *testing.T) { } copStats[0].SetRowNum(10) copStats[0].Record(time.Second, 10) - if copStats[0].String() != "time:1.000000001s, loops:2, rows:20" { + if copStats[0].String() != "time:1.000000001s, loops:2" { t.Fatalf("cop stats string is not expect, got: %v", copStats[0].String()) } - if stats.GetCopStats("agg").String() != "proc max:4ns, min:3ns, p80:4ns, p95:4ns, rows:7, iters:7, tasks:2" { + if stats.GetCopStats("agg").String() != "proc max:4ns, min:3ns, p80:4ns, p95:4ns, iters:7, tasks:2" { t.Fatal("agg") } rootStats := stats.GetRootStats("table_reader") diff --git a/util/kvcache/simple_lru.go b/util/kvcache/simple_lru.go index f89cae3fad481..a9e74e511c84a 100644 --- a/util/kvcache/simple_lru.go +++ b/util/kvcache/simple_lru.go @@ -159,3 +159,13 @@ func (l *SimpleLRUCache) Values() []Value { } return values } + +// Keys return all keys in cache. +func (l *SimpleLRUCache) Keys() []Key { + keys := make([]Key, 0, l.cache.Len()) + for ele := l.cache.Front(); ele != nil; ele = ele.Next() { + key := ele.Value.(*cacheEntry).key + keys = append(keys, key) + } + return keys +} diff --git a/util/mock/context.go b/util/mock/context.go index 577565e3bd604..e39aa0a50038b 100644 --- a/util/mock/context.go +++ b/util/mock/context.go @@ -62,6 +62,11 @@ func (c *Context) Execute(ctx context.Context, sql string) ([]sqlexec.RecordSet, return nil, errors.Errorf("Not Support.") } +// ExecuteInternal implements sqlexec.SQLExecutor ExecuteInternal interface. +func (c *Context) ExecuteInternal(ctx context.Context, sql string) ([]sqlexec.RecordSet, error) { + return nil, errors.Errorf("Not Support.") +} + type mockDDLOwnerChecker struct{} func (c *mockDDLOwnerChecker) IsOwner() bool { return true } diff --git a/util/plancodec/id.go b/util/plancodec/id.go index eea1fe12c7567..d4fb2828703a5 100644 --- a/util/plancodec/id.go +++ b/util/plancodec/id.go @@ -48,10 +48,8 @@ const ( TypeTopN = "TopN" // TypeLimit is the type of Limit. TypeLimit = "Limit" - // TypeHashLeftJoin is the type of left hash join. - TypeHashLeftJoin = "HashLeftJoin" - // TypeHashRightJoin is the type of right hash join. - TypeHashRightJoin = "HashRightJoin" + // TypeHashJoin is the type of hash join. + TypeHashJoin = "HashJoin" // TypeMergeJoin is the type of merge join. TypeMergeJoin = "MergeJoin" // TypeIndexJoin is the type of index look up join. @@ -122,8 +120,7 @@ const ( typeSortID typeTopNID typeLimitID - typeHashLeftJoinID - typeHashRightJoinID + typeHashJoinID typeMergeJoinID typeIndexJoinID typeIndexMergeJoinID @@ -184,10 +181,8 @@ func TypeStringToPhysicalID(tp string) int { return typeTopNID case TypeLimit: return typeLimitID - case TypeHashLeftJoin: - return typeHashLeftJoinID - case TypeHashRightJoin: - return typeHashRightJoinID + case TypeHashJoin: + return typeHashJoinID case TypeMergeJoin: return typeMergeJoinID case TypeIndexJoin: @@ -274,10 +269,8 @@ func PhysicalIDToTypeString(id int) string { return TypeTopN case typeLimitID: return TypeLimit - case typeHashLeftJoinID: - return TypeHashLeftJoin - case typeHashRightJoinID: - return TypeHashRightJoin + case typeHashJoinID: + return TypeHashJoin case typeMergeJoinID: return TypeMergeJoin case typeIndexJoinID: diff --git a/util/ranger/ranger_test.go b/util/ranger/ranger_test.go index 534c382ced0bd..d9e620f3aea93 100644 --- a/util/ranger/ranger_test.go +++ b/util/ranger/ranger_test.go @@ -1120,11 +1120,11 @@ func (s *testRangerSuite) TestIndexRangeElimininatedProjection(c *C) { testKit.MustExec("insert into t values(1,2)") testKit.MustExec("analyze table t") testKit.MustQuery("explain select * from (select * from t union all select ifnull(a,b), b from t) sub where a > 0").Check(testkit.Rows( - "Union_11 2.00 root ", - "├─IndexReader_14 1.00 root index:IndexRangeScan_13", - "│ └─IndexRangeScan_13 1.00 cop[tikv] table:t, index:a, b, range:(0,+inf], keep order:false", - "└─IndexReader_17 1.00 root index:IndexRangeScan_16", - " └─IndexRangeScan_16 1.00 cop[tikv] table:t, index:a, b, range:(0,+inf], keep order:false", + "Union_11 2.00 root ", + "├─IndexReader_14 1.00 root index:IndexRangeScan_13", + "│ └─IndexRangeScan_13 1.00 cop[tikv] table:t, index:PRIMARY(a, b) range:(0,+inf], keep order:false", + "└─IndexReader_17 1.00 root index:IndexRangeScan_16", + " └─IndexRangeScan_16 1.00 cop[tikv] table:t, index:PRIMARY(a, b) range:(0,+inf], keep order:false", )) testKit.MustQuery("select * from (select * from t union all select ifnull(a,b), b from t) sub where a > 0").Check(testkit.Rows( "1 2", diff --git a/util/ranger/testdata/ranger_suite_out.json b/util/ranger/testdata/ranger_suite_out.json index f488dec3ef912..85e77fdf38c1a 100644 --- a/util/ranger/testdata/ranger_suite_out.json +++ b/util/ranger/testdata/ranger_suite_out.json @@ -5,16 +5,16 @@ { "SQL": "explain select t.e in (select count(*) from t s use index(idx), t t1 where s.b = 1 and s.c in (1, 2) and s.d = t.a and s.a = t1.a) from t", "Result": [ - "Projection_11 2.00 root Column#17", - "└─Apply_13 2.00 root CARTESIAN left outer semi join, other cond:eq(test.t.e, Column#16)", - " ├─TableReader_15(Build) 2.00 root data:TableFullScan_14", - " │ └─TableFullScan_14 2.00 cop[tikv] table:t, keep order:false", - " └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#16", - " └─IndexMergeJoin_44 2.00 root inner join, inner:TableReader_42, outer key:test.t.a, inner key:test.t.a", - " ├─IndexReader_33(Build) 2.00 root index:IndexRangeScan_32", - " │ └─IndexRangeScan_32 2.00 cop[tikv] table:s, index:b, c, d, range: decided by [eq(test.t.b, 1) in(test.t.c, 1, 2) eq(test.t.d, test.t.a)], keep order:false", - " └─TableReader_42(Probe) 1.00 root data:TableRangeScan_41", - " └─TableRangeScan_41 1.00 cop[tikv] table:t1, range: decided by [test.t.a], keep order:true" + "Projection_11 2.00 root Column#17", + "└─Apply_13 2.00 root CARTESIAN left outer semi join, other cond:eq(test.t.e, Column#16)", + " ├─TableReader_15(Build) 2.00 root data:TableFullScan_14", + " │ └─TableFullScan_14 2.00 cop[tikv] table:t keep order:false", + " └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->Column#16", + " └─IndexMergeJoin_44 2.00 root inner join, inner:TableReader_42, outer key:test.t.a, inner key:test.t.a", + " ├─IndexReader_33(Build) 2.00 root index:IndexRangeScan_32", + " │ └─IndexRangeScan_32 2.00 cop[tikv] table:s, index:idx(b, c, d) range: decided by [eq(test.t.b, 1) in(test.t.c, 1, 2) eq(test.t.d, test.t.a)], keep order:false", + " └─TableReader_42(Probe) 1.00 root data:TableRangeScan_41", + " └─TableRangeScan_41 1.00 cop[tikv] table:t1 range: decided by [test.t.a], keep order:true" ] }, { diff --git a/util/rowcodec/decoder.go b/util/rowcodec/decoder.go index ea8e514fda59b..8352fc8fa2efc 100644 --- a/util/rowcodec/decoder.go +++ b/util/rowcodec/decoder.go @@ -50,10 +50,11 @@ type ColInfo struct { Flag int32 IsPKHandle bool - Flen int - Decimal int - Elems []string - Collate string + Flen int + Decimal int + Elems []string + Collate string + VirtualGenCol bool } // DatumMapDecoder decodes the row to datum map. @@ -221,6 +222,11 @@ func (decoder *ChunkDecoder) DecodeToChunk(rowData []byte, handle int64, chk *ch chk.AppendInt64(colIdx, handle) continue } + // fill the virtual column value after row calculation + if col.VirtualGenCol { + chk.AppendNull(colIdx) + continue + } idx, isNil, notFound := decoder.row.findColID(col.ID) if !notFound && !isNil { diff --git a/util/sqlexec/restricted_sql_executor.go b/util/sqlexec/restricted_sql_executor.go index 7416e411867d1..08347640944a5 100644 --- a/util/sqlexec/restricted_sql_executor.go +++ b/util/sqlexec/restricted_sql_executor.go @@ -50,6 +50,8 @@ type RestrictedSQLExecutor interface { // session.Session.Execute, then privilege/privileges and tidb would become a circle. type SQLExecutor interface { Execute(ctx context.Context, sql string) ([]RecordSet, error) + // ExecuteInternal means execute sql as the internal sql. + ExecuteInternal(ctx context.Context, sql string) ([]RecordSet, error) } // SQLParser is an interface provides parsing sql statement. diff --git a/util/stmtsummary/statement_summary.go b/util/stmtsummary/statement_summary.go index 00ffe03a0c76a..dd83862ef9697 100644 --- a/util/stmtsummary/statement_summary.go +++ b/util/stmtsummary/statement_summary.go @@ -24,6 +24,7 @@ import ( "sync/atomic" "time" + "github.com/pingcap/parser/auth" "github.com/pingcap/parser/mysql" "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/sessionctx/stmtctx" @@ -81,6 +82,10 @@ type stmtSummaryByDigestMap struct { sessionEnabled string // setInSession indicates whether statement summary has been set in any session. globalEnabled string + // sessionInternalQueryEnabled indicates whether internal statement summary is enabled in current server. + sessionInternalQueryEnabled string + // globalInternalQueryEnabled indicates whether internal statement summary has been set in any session. + globalInternalQueryEnabled string // These variables indicate the refresh interval of summaries. // They must be > 0. @@ -117,6 +122,7 @@ type stmtSummaryByDigest struct { stmtType string normalizedSQL string tableNames string + isInternal bool } // stmtSummaryByDigestElement is the summary for each type of statements in current interval. @@ -129,7 +135,6 @@ type stmtSummaryByDigestElement struct { sampleSQL string prevSQL string samplePlan string - sampleUser string indexNames []string execCount int64 // latency @@ -183,6 +188,7 @@ type stmtSummaryByDigestElement struct { maxTxnRetry int sumBackoffTimes int64 backoffTypes map[fmt.Stringer]int + authUsers map[string]struct{} // other sumMem int64 maxMem int64 @@ -213,6 +219,7 @@ type StmtExecInfo struct { ExecDetail *execdetails.ExecDetails MemMax int64 StartTime time.Time + IsInternal bool } // newStmtSummaryByDigestMap creates an empty stmtSummaryByDigestMap. @@ -257,6 +264,9 @@ func (ssMap *stmtSummaryByDigestMap) AddStatement(sei *StmtExecInfo) { if !ssMap.Enabled() { return nil, 0 } + if sei.IsInternal && !ssMap.EnabledInternal() { + return nil, 0 + } if ssMap.beginTimeForCurInterval+intervalSeconds <= now { // `beginTimeForCurInterval` is a multiple of intervalSeconds, so that when the interval is a multiple @@ -274,6 +284,7 @@ func (ssMap *stmtSummaryByDigestMap) AddStatement(sei *StmtExecInfo) { } else { summary = value.(*stmtSummaryByDigest) } + summary.isInternal = summary.isInternal && sei.IsInternal return summary, beginTime }() @@ -292,8 +303,24 @@ func (ssMap *stmtSummaryByDigestMap) Clear() { ssMap.beginTimeForCurInterval = 0 } +// clearInternal removes all statement summaries which are internal summaries. +func (ssMap *stmtSummaryByDigestMap) clearInternal() { + ssMap.Lock() + defer ssMap.Unlock() + + for _, key := range ssMap.summaryMap.Keys() { + summary, ok := ssMap.summaryMap.Get(key) + if !ok { + continue + } + if summary.(*stmtSummaryByDigest).isInternal { + ssMap.summaryMap.Delete(key) + } + } +} + // ToCurrentDatum converts current statement summaries to datum. -func (ssMap *stmtSummaryByDigestMap) ToCurrentDatum() [][]types.Datum { +func (ssMap *stmtSummaryByDigestMap) ToCurrentDatum(user *auth.UserIdentity, isSuper bool) [][]types.Datum { ssMap.Lock() values := ssMap.summaryMap.Values() beginTime := ssMap.beginTimeForCurInterval @@ -301,7 +328,7 @@ func (ssMap *stmtSummaryByDigestMap) ToCurrentDatum() [][]types.Datum { rows := make([][]types.Datum, 0, len(values)) for _, value := range values { - record := value.(*stmtSummaryByDigest).toCurrentDatum(beginTime) + record := value.(*stmtSummaryByDigest).toCurrentDatum(beginTime, user, isSuper) if record != nil { rows = append(rows, record) } @@ -310,7 +337,7 @@ func (ssMap *stmtSummaryByDigestMap) ToCurrentDatum() [][]types.Datum { } // ToHistoryDatum converts history statements summaries to datum. -func (ssMap *stmtSummaryByDigestMap) ToHistoryDatum() [][]types.Datum { +func (ssMap *stmtSummaryByDigestMap) ToHistoryDatum(user *auth.UserIdentity, isSuper bool) [][]types.Datum { ssMap.Lock() values := ssMap.summaryMap.Values() ssMap.Unlock() @@ -318,7 +345,7 @@ func (ssMap *stmtSummaryByDigestMap) ToHistoryDatum() [][]types.Datum { historySize := ssMap.historySize() rows := make([][]types.Datum, 0, len(values)*historySize) for _, value := range values { - records := value.(*stmtSummaryByDigest).toHistoryDatum(historySize) + records := value.(*stmtSummaryByDigest).toHistoryDatum(historySize, user, isSuper) rows = append(rows, records...) } return rows @@ -341,8 +368,9 @@ func (ssMap *stmtSummaryByDigestMap) GetMoreThanOnceSelect() ([]string, []string if ssbd.history.Len() > 0 { ssElement := ssbd.history.Back().Value.(*stmtSummaryByDigestElement) ssElement.Lock() - // Empty sample users means that it is an internal queries. - if ssElement.sampleUser != "" && (ssbd.history.Len() > 1 || ssElement.execCount > 1) { + + // Empty auth users means that it is an internal queries. + if len(ssElement.authUsers) > 0 && (ssbd.history.Len() > 1 || ssElement.execCount > 1) { schemas = append(schemas, ssbd.schemaName) sqls = append(sqls, ssElement.sampleSQL) } @@ -380,6 +408,32 @@ func (ssMap *stmtSummaryByDigestMap) SetEnabled(value string, inSession bool) { } } +// SetEnabledInternalQuery enables or disables internal statement summary in global(cluster) or session(server) scope. +func (ssMap *stmtSummaryByDigestMap) SetEnabledInternalQuery(value string, inSession bool) { + value = ssMap.normalizeEnableValue(value) + + ssMap.sysVars.Lock() + if inSession { + ssMap.sysVars.sessionInternalQueryEnabled = value + } else { + ssMap.sysVars.globalInternalQueryEnabled = value + } + sessionInternalQueryEnabled := ssMap.sysVars.sessionInternalQueryEnabled + globalInternalQueryEnabled := ssMap.sysVars.globalInternalQueryEnabled + ssMap.sysVars.Unlock() + + // Clear summaries for internal queries once internal statement summary is disabled. + var needClear bool + if ssMap.isSet(sessionInternalQueryEnabled) { + needClear = !ssMap.isEnabled(sessionInternalQueryEnabled) + } else { + needClear = !ssMap.isEnabled(globalInternalQueryEnabled) + } + if needClear { + ssMap.clearInternal() + } +} + // Enabled returns whether statement summary is enabled. func (ssMap *stmtSummaryByDigestMap) Enabled() bool { ssMap.sysVars.RLock() @@ -394,6 +448,20 @@ func (ssMap *stmtSummaryByDigestMap) Enabled() bool { return enabled } +// EnabledInternal returns whether internal statement summary is enabled. +func (ssMap *stmtSummaryByDigestMap) EnabledInternal() bool { + ssMap.sysVars.RLock() + defer ssMap.sysVars.RUnlock() + + var enabled bool + if ssMap.isSet(ssMap.sysVars.sessionInternalQueryEnabled) { + enabled = ssMap.isEnabled(ssMap.sysVars.sessionInternalQueryEnabled) + } else { + enabled = ssMap.isEnabled(ssMap.sysVars.globalInternalQueryEnabled) + } + return enabled +} + // normalizeEnableValue converts 'ON' to '1' and 'OFF' to '0'. func (ssMap *stmtSummaryByDigestMap) normalizeEnableValue(value string) string { switch { @@ -571,7 +639,7 @@ func (ssbd *stmtSummaryByDigest) add(sei *StmtExecInfo, beginTime int64, interva } } -func (ssbd *stmtSummaryByDigest) toCurrentDatum(beginTimeForCurInterval int64) []types.Datum { +func (ssbd *stmtSummaryByDigest) toCurrentDatum(beginTimeForCurInterval int64, user *auth.UserIdentity, isSuper bool) []types.Datum { var ssElement *stmtSummaryByDigestElement ssbd.Lock() @@ -582,19 +650,29 @@ func (ssbd *stmtSummaryByDigest) toCurrentDatum(beginTimeForCurInterval int64) [ // `ssElement` is lazy expired, so expired elements could also be read. // `beginTime` won't change since `ssElement` is created, so locking is not needed here. - if ssElement == nil || ssElement.beginTime < beginTimeForCurInterval { + isAuthed := true + if user != nil && !isSuper { + _, isAuthed = ssElement.authUsers[user.Username] + } + if ssElement == nil || ssElement.beginTime < beginTimeForCurInterval || !isAuthed { return nil } return ssElement.toDatum(ssbd) } -func (ssbd *stmtSummaryByDigest) toHistoryDatum(historySize int) [][]types.Datum { +func (ssbd *stmtSummaryByDigest) toHistoryDatum(historySize int, user *auth.UserIdentity, isSuper bool) [][]types.Datum { // Collect all history summaries to an array. ssElements := ssbd.collectHistorySummaries(historySize) rows := make([][]types.Datum, 0, len(ssElements)) for _, ssElement := range ssElements { - rows = append(rows, ssElement.toDatum(ssbd)) + isAuthed := true + if user != nil && !isSuper { + _, isAuthed = ssElement.authUsers[user.Username] + } + if isAuthed { + rows = append(rows, ssElement.toDatum(ssbd)) + } } return rows } @@ -616,7 +694,7 @@ func (ssbd *stmtSummaryByDigest) collectHistorySummaries(historySize int) []*stm } func newStmtSummaryByDigestElement(sei *StmtExecInfo, beginTime int64, intervalSeconds int64) *stmtSummaryByDigestElement { - // sampleSQL / sampleUser / samplePlan / prevSQL / indexNames store the values shown at the first time, + // sampleSQL / authUsers(sampleUser) / samplePlan / prevSQL / indexNames store the values shown at the first time, // because it compacts performance to update every time. ssElement := &stmtSummaryByDigestElement{ beginTime: beginTime, @@ -625,12 +703,12 @@ func newStmtSummaryByDigestElement(sei *StmtExecInfo, beginTime int64, intervalS prevSQL: sei.PrevSQL, // samplePlan needs to be decoded so it can't be truncated. samplePlan: sei.PlanGenerator(), - sampleUser: sei.User, indexNames: sei.StmtCtx.IndexNames, minLatency: sei.TotalLatency, firstSeen: sei.StartTime, lastSeen: sei.StartTime, backoffTypes: make(map[fmt.Stringer]int), + authUsers: make(map[string]struct{}), } ssElement.add(sei, intervalSeconds) return ssElement @@ -658,6 +736,11 @@ func (ssElement *stmtSummaryByDigestElement) add(sei *StmtExecInfo, intervalSeco ssElement.Lock() defer ssElement.Unlock() + // add user to auth users set + if len(sei.User) > 0 { + ssElement.authUsers[sei.User] = struct{}{} + } + // refreshInterval may change anytime, update endTime ASAP. ssElement.endTime = ssElement.beginTime + intervalSeconds ssElement.execCount++ @@ -794,6 +877,12 @@ func (ssElement *stmtSummaryByDigestElement) toDatum(ssbd *stmtSummaryByDigest) plan = "" } + sampleUser := "" + for key := range ssElement.authUsers { + sampleUser = key + break + } + // Actually, there's a small chance that endTime is out of date, but it's hard to keep it up to date all the time. return types.MakeDatums( types.NewTime(types.FromGoTime(time.Unix(ssElement.beginTime, 0)), mysql.TypeTimestamp, 0), @@ -804,7 +893,7 @@ func (ssElement *stmtSummaryByDigestElement) toDatum(ssbd *stmtSummaryByDigest) ssbd.normalizedSQL, convertEmptyToNil(ssbd.tableNames), convertEmptyToNil(strings.Join(ssElement.indexNames, ",")), - convertEmptyToNil(ssElement.sampleUser), + convertEmptyToNil(sampleUser), ssElement.execCount, int64(ssElement.sumLatency), int64(ssElement.maxLatency), diff --git a/util/stmtsummary/statement_summary_test.go b/util/stmtsummary/statement_summary_test.go index 2737b087048c3..885458a5e9f29 100644 --- a/util/stmtsummary/statement_summary_test.go +++ b/util/stmtsummary/statement_summary_test.go @@ -22,6 +22,7 @@ import ( "time" . "github.com/pingcap/check" + "github.com/pingcap/parser/auth" "github.com/pingcap/parser/mysql" "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/sessionctx/stmtctx" @@ -79,7 +80,6 @@ func (s *testStmtSummarySuite) TestAddStatement(c *C) { sampleSQL: stmtExecInfo1.OriginalSQL, samplePlan: stmtExecInfo1.PlanGenerator(), indexNames: stmtExecInfo1.StmtCtx.IndexNames, - sampleUser: stmtExecInfo1.User, execCount: 1, sumLatency: stmtExecInfo1.TotalLatency, maxLatency: stmtExecInfo1.TotalLatency, @@ -424,7 +424,6 @@ func matchStmtSummaryByDigest(first, second *stmtSummaryByDigest) bool { ssElement1.sampleSQL != ssElement2.sampleSQL || ssElement1.samplePlan != ssElement2.samplePlan || ssElement1.prevSQL != ssElement2.prevSQL || - ssElement1.sampleUser != ssElement2.sampleUser || ssElement1.execCount != ssElement2.execCount || ssElement1.sumLatency != ssElement2.sumLatency || ssElement1.maxLatency != ssElement2.maxLatency || @@ -583,7 +582,7 @@ func (s *testStmtSummarySuite) TestToDatum(c *C) { stmtExecInfo1 := generateAnyExecInfo() s.ssMap.AddStatement(stmtExecInfo1) - datums := s.ssMap.ToCurrentDatum() + datums := s.ssMap.ToCurrentDatum(nil, true) c.Assert(len(datums), Equals, 1) n := types.NewTime(types.FromGoTime(time.Unix(s.ssMap.beginTimeForCurInterval, 0)), mysql.TypeTimestamp, types.DefaultFsp) e := types.NewTime(types.FromGoTime(time.Unix(s.ssMap.beginTimeForCurInterval+1800, 0)), mysql.TypeTimestamp, types.DefaultFsp) @@ -613,7 +612,7 @@ func (s *testStmtSummarySuite) TestToDatum(c *C) { t, t, stmtExecInfo1.OriginalSQL, stmtExecInfo1.PrevSQL, "plan_digest", ""} match(c, datums[0], expectedDatum...) - datums = s.ssMap.ToHistoryDatum() + datums = s.ssMap.ToHistoryDatum(nil, true) c.Assert(len(datums), Equals, 1) match(c, datums[0], expectedDatum...) } @@ -641,7 +640,7 @@ func (s *testStmtSummarySuite) TestAddStatementParallel(c *C) { } // There would be 32 summaries. - datums := s.ssMap.ToCurrentDatum() + datums := s.ssMap.ToCurrentDatum(nil, true) c.Assert(len(datums), Equals, loops) } @@ -650,7 +649,7 @@ func (s *testStmtSummarySuite) TestAddStatementParallel(c *C) { } wg.Wait() - datums := s.ssMap.ToCurrentDatum() + datums := s.ssMap.ToCurrentDatum(nil, true) c.Assert(len(datums), Equals, loops) } @@ -731,14 +730,14 @@ func (s *testStmtSummarySuite) TestDisableStmtSummary(c *C) { stmtExecInfo1 := generateAnyExecInfo() s.ssMap.AddStatement(stmtExecInfo1) - datums := s.ssMap.ToCurrentDatum() + datums := s.ssMap.ToCurrentDatum(nil, true) c.Assert(len(datums), Equals, 0) // Set true in session scope, it will overwrite global scope. s.ssMap.SetEnabled("1", true) s.ssMap.AddStatement(stmtExecInfo1) - datums = s.ssMap.ToCurrentDatum() + datums = s.ssMap.ToCurrentDatum(nil, true) c.Assert(len(datums), Equals, 1) // Set false in global scope, it shouldn't work. @@ -750,21 +749,21 @@ func (s *testStmtSummarySuite) TestDisableStmtSummary(c *C) { stmtExecInfo2.NormalizedSQL = "normalized_sql2" stmtExecInfo2.Digest = "digest2" s.ssMap.AddStatement(stmtExecInfo2) - datums = s.ssMap.ToCurrentDatum() + datums = s.ssMap.ToCurrentDatum(nil, true) c.Assert(len(datums), Equals, 2) // Unset in session scope. s.ssMap.SetEnabled("", true) s.ssMap.beginTimeForCurInterval = now + 60 s.ssMap.AddStatement(stmtExecInfo2) - datums = s.ssMap.ToCurrentDatum() + datums = s.ssMap.ToCurrentDatum(nil, true) c.Assert(len(datums), Equals, 0) // Unset in global scope. s.ssMap.SetEnabled("", false) s.ssMap.beginTimeForCurInterval = now + 60 s.ssMap.AddStatement(stmtExecInfo1) - datums = s.ssMap.ToCurrentDatum() + datums = s.ssMap.ToCurrentDatum(nil, true) c.Assert(len(datums), Equals, 0) // Set back. @@ -790,7 +789,7 @@ func (s *testStmtSummarySuite) TestEnableSummaryParallel(c *C) { s.ssMap.SetEnabled(fmt.Sprintf("%d", i%2), false) s.ssMap.AddStatement(stmtExecInfo1) // Try to read it. - s.ssMap.ToHistoryDatum() + s.ssMap.ToHistoryDatum(nil, true) } s.ssMap.SetEnabled("1", false) } @@ -917,11 +916,11 @@ func (s *testStmtSummarySuite) TestSummaryHistory(c *C) { c.Assert(ssElement.beginTime, Equals, now+20) } } - datum := s.ssMap.ToHistoryDatum() + datum := s.ssMap.ToHistoryDatum(nil, true) c.Assert(len(datum), Equals, 10) s.ssMap.SetHistorySize("5", false) - datum = s.ssMap.ToHistoryDatum() + datum = s.ssMap.ToHistoryDatum(nil, true) c.Assert(len(datum), Equals, 5) } @@ -1027,3 +1026,32 @@ func (s *testStmtSummarySuite) TestPointGet(c *C) { s.ssMap.AddStatement(stmtExecInfo1) c.Assert(ssElement.execCount, Equals, int64(2)) } + +func (s *testStmtSummarySuite) TestAccessPrivilege(c *C) { + s.ssMap.Clear() + + loops := 32 + stmtExecInfo1 := generateAnyExecInfo() + + for i := 0; i < loops; i++ { + stmtExecInfo1.Digest = fmt.Sprintf("digest%d", i) + s.ssMap.AddStatement(stmtExecInfo1) + } + + user := &auth.UserIdentity{Username: "user"} + badUser := &auth.UserIdentity{Username: "bad_user"} + + datums := s.ssMap.ToCurrentDatum(user, false) + c.Assert(len(datums), Equals, loops) + datums = s.ssMap.ToCurrentDatum(badUser, false) + c.Assert(len(datums), Equals, 0) + datums = s.ssMap.ToCurrentDatum(badUser, true) + c.Assert(len(datums), Equals, loops) + + datums = s.ssMap.ToHistoryDatum(user, false) + c.Assert(len(datums), Equals, loops) + datums = s.ssMap.ToHistoryDatum(badUser, false) + c.Assert(len(datums), Equals, 0) + datums = s.ssMap.ToHistoryDatum(badUser, true) + c.Assert(len(datums), Equals, loops) +} diff --git a/util/testkit/testkit.go b/util/testkit/testkit.go index 20d31acfefc22..87edb0a020ecd 100644 --- a/util/testkit/testkit.go +++ b/util/testkit/testkit.go @@ -201,7 +201,7 @@ func (tk *TestKit) HasPlan(sql string, plan string, args ...interface{}) bool { func (tk *TestKit) MustUseIndex(sql string, index string, args ...interface{}) bool { rs := tk.MustQuery("explain "+sql, args...) for i := range rs.rows { - if strings.Contains(rs.rows[i][3], "index:"+index+",") { + if strings.Contains(rs.rows[i][3], "index:"+index) { return true } }