Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner/core: change agg cost factor #25210

Merged
merged 10 commits into from
Jun 8, 2021
42 changes: 24 additions & 18 deletions cmd/explaintest/r/explain_easy.result
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ explain format = 'brief' select c1 from t1 where c1 in (select c2 from t2);
id estRows task access object operator info
HashJoin 9990.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)]
├─HashAgg(Build) 7992.00 root group by:test.t2.c2, funcs:firstrow(test.t2.c2)->test.t2.c2
│ └─TableReader 9990.00 root data:Selection
│ └─Selection 9990.00 cop[tikv] not(isnull(test.t2.c2))
│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo
│ └─TableReader 7992.00 root data:HashAgg
│ └─HashAgg 7992.00 cop[tikv] group by:test.t2.c2,
│ └─Selection 9990.00 cop[tikv] not(isnull(test.t2.c2))
│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo
└─TableReader(Probe) 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo
explain format = 'brief' select (select count(1) k from t1 s where s.c1 = t1.c1 having k != 0) from t1;
Expand Down Expand Up @@ -165,27 +166,32 @@ id estRows task access object operator info
Union 26000.00 root
├─HashAgg 16000.00 root group by:Column#10, funcs:firstrow(Column#12)->Column#10
│ └─Union 16000.00 root
│ ├─StreamAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#12, funcs:firstrow(test.t2.c1)->Column#10
│ │ └─IndexReader 10000.00 root index:IndexFullScan
│ │ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo
│ └─StreamAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#12, funcs:firstrow(test.t2.c1)->Column#10
│ └─IndexReader 10000.00 root index:IndexFullScan
│ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo
│ ├─HashAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#12, funcs:firstrow(test.t2.c1)->Column#10
│ │ └─IndexReader 8000.00 root index:HashAgg
│ │ └─HashAgg 8000.00 cop[tikv] group by:test.t2.c1,
│ │ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo
│ └─HashAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#12, funcs:firstrow(test.t2.c1)->Column#10
│ └─IndexReader 8000.00 root index:HashAgg
│ └─HashAgg 8000.00 cop[tikv] group by:test.t2.c1,
│ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo
└─IndexReader 10000.00 root index:IndexFullScan
└─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo
explain format = 'brief' select c1 from t2 union all select c1 from t2 union select c1 from t2;
id estRows task access object operator info
HashAgg 24000.00 root group by:Column#10, funcs:firstrow(Column#11)->Column#10
└─Union 24000.00 root
├─StreamAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10
│ └─IndexReader 10000.00 root index:IndexFullScan
│ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo
├─StreamAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10
│ └─IndexReader 10000.00 root index:IndexFullScan
│ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo
└─StreamAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10
└─IndexReader 10000.00 root index:IndexFullScan
└─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:true, stats:pseudo
├─HashAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10
│ └─IndexReader 8000.00 root index:HashAgg
│ └─HashAgg 8000.00 cop[tikv] group by:test.t2.c1,
│ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo
├─HashAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10
│ └─IndexReader 8000.00 root index:HashAgg
│ └─HashAgg 8000.00 cop[tikv] group by:test.t2.c1,
│ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo
└─HashAgg 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->Column#11, funcs:firstrow(test.t2.c1)->Column#10
└─IndexReader 8000.00 root index:HashAgg
└─HashAgg 8000.00 cop[tikv] group by:test.t2.c1,
└─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, 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 IS_VISIBLE CLUSTERED
test t4 0 PRIMARY 1 a NULL NULL 0 YES YES
Expand Down
7 changes: 4 additions & 3 deletions cmd/explaintest/r/index_join.result
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ create table t2(a int not null, b int not null, key a(a));
explain format = 'brief' select /*+ TIDB_INLJ(t1) */ * from t1 where t1.a in (select t2.a from t2);
id estRows task access object operator info
IndexJoin 10000.00 root inner join, inner:IndexLookUp, outer key:test.t2.a, inner key:test.t1.a, equal cond:eq(test.t2.a, test.t1.a)
├─StreamAgg(Build) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a
│ └─IndexReader 10000.00 root index:IndexFullScan
│ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:a(a) keep order:true, stats:pseudo
├─HashAgg(Build) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a
│ └─IndexReader 8000.00 root index:HashAgg
│ └─HashAgg 8000.00 cop[tikv] group by:test.t2.a,
│ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:a(a) keep order:false, stats:pseudo
└─IndexLookUp(Probe) 1.25 root
├─IndexRangeScan(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(Probe) 1.25 cop[tikv] table:t1 keep order:false, stats:pseudo
Loading