Skip to content

Commit

Permalink
planner: fix wrong stats for physical union scan (pingcap#14093)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzmhhh123 committed Dec 19, 2019
1 parent f472a98 commit e7ed91a
Show file tree
Hide file tree
Showing 4 changed files with 56,009 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cmd/explaintest/r/explain_union_scan.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
drop table if exists city;
CREATE TABLE `city` (
`id` varchar(70) NOT NULL,
`province_id` int(15) DEFAULT NULL,
`city_name` varchar(90) DEFAULT NULL,
`description` varchar(90) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
load stats "s/explain_union_scan.json";
insert into city values("06766b3ef41d484d8878606393f1ed0b", 88, "chongqing", "chongqing city");
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 count task operator info
Projection_17 10.00 root test.city.id, test.city.province_id, test.city.city_name, test.city.description, test.city.province_id, test.city.city_name, test.city.description
└─Limit_20 10.00 root offset:0, count:10
└─HashLeftJoin_22 10.00 root left outer join, inner:Limit_25 (REVERSED), equal:[eq(test.city.province_id, test.city.province_id)]
├─Limit_25 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_37 0.97 root gt(test.city.province_id, 1), lt(test.city.province_id, 100)
│ │ └─IndexLookUp_36 0.97 root
│ │ ├─IndexScan_33 1.00 cop[tikv] table:t1, index:id, range: decided by [eq(test.city.id, test.city.id)], keep order:false
│ │ └─Selection_35 0.97 cop[tikv] gt(test.city.province_id, 1), lt(test.city.province_id, 100)
│ │ └─TableScan_34 1.00 cop[tikv] table:t1, keep order:false
│ └─UnionScan_47 10.33 root
│ └─TableReader_49 10.33 root data:TableScan_48
│ └─TableScan_48 10.33 cop[tikv] table:t2, range:[-inf,+inf], keep order:false
└─UnionScan_57 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))
└─TableScan_58 536284.00 cop[tikv] table:t3, range:[-inf,+inf], keep order:false
commit;
Loading

0 comments on commit e7ed91a

Please sign in to comment.