Skip to content

Commit

Permalink
plan, expression: refine explain count info (pingcap#5810)
Browse files Browse the repository at this point in the history
  • Loading branch information
alivxxx authored Feb 7, 2018
1 parent ae8e594 commit 5be134e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2620,9 +2620,9 @@ func (s *testIntegrationSuite) TestCompareBuiltin(c *C) {
tk.MustExec("drop table if exists t;")
tk.MustExec("create table t(a date)")
result = tk.MustQuery("desc select a = a from t")
result.Check(testkit.Rows("TableScan_4 cop table:t, range:[-inf,+inf], keep order:false 10000",
"TableReader_5 Projection_3 root data:TableScan_4 10000",
"Projection_3 TableReader_5 root eq(test.t.a, test.t.a) 8000"))
result.Check(testkit.Rows("TableScan_4 cop table:t, range:[-inf,+inf], keep order:false 10000.00",
"TableReader_5 Projection_3 root data:TableScan_4 10000.00",
"Projection_3 TableReader_5 root eq(test.t.a, test.t.a) 8000.00"))

// for interval
result = tk.MustQuery(`select interval(null, 1, 2), interval(1, 2, 3), interval(2, 1, 3)`)
Expand Down
24 changes: 12 additions & 12 deletions plan/cbo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func (s *testAnalyzeSuite) TestCBOWithoutAnalyze(c *C) {
h.DumpStatsDeltaToKV()
c.Assert(h.Update(dom.InfoSchema()), IsNil)
testKit.MustQuery("explain select * from t1, t2 where t1.a = t2.a").Check(testkit.Rows(
"TableScan_10 cop table:t1, range:[-inf,+inf], keep order:false 6",
"TableReader_11 HashLeftJoin_8 root data:TableScan_10 6",
"TableScan_12 cop table:t2, range:[-inf,+inf], keep order:false 6",
"TableReader_13 HashLeftJoin_8 root data:TableScan_12 6",
"HashLeftJoin_8 TableReader_11,TableReader_13 root inner join, inner:TableReader_13, equal:[eq(test.t1.a, test.t2.a)] 7.499999999999999",
"TableScan_10 cop table:t1, range:[-inf,+inf], keep order:false 6.00",
"TableReader_11 HashLeftJoin_8 root data:TableScan_10 6.00",
"TableScan_12 cop table:t2, range:[-inf,+inf], keep order:false 6.00",
"TableReader_13 HashLeftJoin_8 root data:TableScan_12 6.00",
"HashLeftJoin_8 TableReader_11,TableReader_13 root inner join, inner:TableReader_13, equal:[eq(test.t1.a, test.t2.a)] 7.50",
))
}

Expand Down Expand Up @@ -88,10 +88,10 @@ func (s *testAnalyzeSuite) TestEstimation(c *C) {
h.DumpStatsDeltaToKV()
c.Assert(h.Update(dom.InfoSchema()), IsNil)
testKit.MustQuery("explain select count(*) from t group by a").Check(testkit.Rows(
"TableScan_8 HashAgg_5 cop table:t, range:[-inf,+inf], keep order:false 8",
"HashAgg_5 TableScan_8 cop group by:test.t.a, funcs:count(1) 2",
"TableReader_10 HashAgg_9 root data:HashAgg_5 2",
"HashAgg_9 TableReader_10 root group by:col_1, funcs:count(col_0) 2",
"TableScan_8 HashAgg_5 cop table:t, range:[-inf,+inf], keep order:false 8.00",
"HashAgg_5 TableScan_8 cop group by:test.t.a, funcs:count(1) 2.00",
"TableReader_10 HashAgg_9 root data:HashAgg_5 2.00",
"HashAgg_9 TableReader_10 root group by:col_1, funcs:count(col_0) 2.00",
))
}

Expand Down Expand Up @@ -387,9 +387,9 @@ func (s *testAnalyzeSuite) TestOutdatedAnalyze(c *C) {
h.DumpStatsDeltaToKV()
c.Assert(h.Update(dom.InfoSchema()), IsNil)
testKit.MustQuery("explain select * from t where a <= 5 and b <= 5").Check(testkit.Rows(
"TableScan_5 Selection_6 cop table:t, range:[-inf,+inf], keep order:false 80",
"Selection_6 TableScan_5 cop le(test.t.a, 5), le(test.t.b, 5) 28.799999999999997",
"TableReader_7 root data:Selection_6 28.799999999999997",
"TableScan_5 Selection_6 cop table:t, range:[-inf,+inf], keep order:false 80.00",
"Selection_6 TableScan_5 cop le(test.t.a, 5), le(test.t.b, 5) 28.80",
"TableReader_7 root data:Selection_6 28.80",
))
}

Expand Down
2 changes: 1 addition & 1 deletion plan/common_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func (e *Explain) prepareExplainInfo4DAGTask(p PhysicalPlan, taskType string, pa
}
childrenInfo := strings.Join(childrenIDs, ",")
operatorInfo := p.ExplainInfo()
count := string(strconv.AppendFloat([]byte{}, p.StatsInfo().count, 'f', -1, 64))
count := string(strconv.AppendFloat([]byte{}, p.StatsInfo().count, 'f', 2, 64))
row := []string{p.ExplainID(), parentID, childrenInfo, taskType, operatorInfo, count}
e.Rows = append(e.Rows, row)
}
Expand Down

0 comments on commit 5be134e

Please sign in to comment.