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

add integration tests for access path selection #9212

Merged
merged 10 commits into from
Feb 18, 2019
Next Next commit
add explain tests for access_path selection
  • Loading branch information
qw4990 committed Feb 14, 2019
commit 4ae1ed27ced31ab7b1004ee8d460b2088c6e98f2
87 changes: 87 additions & 0 deletions cmd/explaintest/r/access_path_selection.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
CREATE TABLE `pay_daily` (
`id` varchar(50) NOT NULL DEFAULT '',
`tenant_id` bigint(11) NOT NULL DEFAULT '0',
`poi_id` bigint(11) NOT NULL DEFAULT '0',
`time_stamp` bigint(11) DEFAULT NULL,
`datekey` int(20) DEFAULT NULL,
`hour` int(11) DEFAULT NULL,
`meal_type` int(11) DEFAULT NULL,
`cashier_id` bigint(11) DEFAULT NULL,
`cashier_name` varchar(50) DEFAULT NULL,
`pay_type_id` bigint(11) DEFAULT NULL,
`pay_type_name` varchar(32) DEFAULT NULL,
`is_custom` varchar(32) DEFAULT NULL,
`account_io_type` int(11) DEFAULT NULL,
`pay_cnt` bigint(11) DEFAULT NULL,
`pay_amt` bigint(11) DEFAULT NULL,
`update_source` int(11) DEFAULT NULL,
`update_time` timestamp DEFAULT NULL,
PRIMARY KEY (`id`, `tenant_id`, `poi_id`),
KEY `IDX_ID` (`tenant_id`, `poi_id`, `time_stamp`),
KEY `IDX_DK` (`datekey`),
KEY `IDX_TENANT_POI_DATEKEY` (`tenant_id`, `poi_id`, `datekey`),
KEY `IDX_US` (`update_source`, `tenant_id`)
);
explain select id, tenant_id, poi_id, time_stamp, datekey, hour, meal_type, cashier_id, cashier_name, pay_type_id, is_custom, account_io_type, pay_cnt, pay_amt, update_source from pay_daily where tenant_id=12565 and poi_id=159298363 and datekey=20180731;
id count task operator info
IndexLookUp_18 0.00 root
├─IndexScan_16 0.00 cop table:pay_daily, index:tenant_id, poi_id, datekey, range:[12565 159298363 20180731,12565 159298363 20180731], keep order:false, stats:pseudo
└─TableScan_17 0.00 cop table:pay_daily, keep order:false, stats:pseudo
explain select id from pay_daily where tenant_id=12565 and poi_id=159298363 and time_stamp=10000;
id count task operator info
Projection_4 0.00 root test.pay_daily.id
└─IndexLookUp_10 0.00 root
├─IndexScan_8 0.00 cop table:pay_daily, index:tenant_id, poi_id, time_stamp, range:[12565 159298363 10000,12565 159298363 10000], keep order:false, stats:pseudo
└─TableScan_9 0.00 cop table:pay_daily, keep order:false, stats:pseudo
explain select id from pay_daily where update_source>12565 and tenant_id<159298363;
id count task operator info
Projection_4 1107.78 root test.pay_daily.id
└─IndexLookUp_19 1107.78 root
├─Selection_18 1107.78 cop lt(test.pay_daily.tenant_id, 159298363)
│ └─IndexScan_16 3333.33 cop table:pay_daily, index:update_source, tenant_id, range:(12565,+inf], keep order:false, stats:pseudo
└─TableScan_17 1107.78 cop table:pay_daily, keep order:false
explain select id from pay_daily where datekey>12565;
id count task operator info
Projection_4 3333.33 root test.pay_daily.id
└─IndexLookUp_10 3333.33 root
├─IndexScan_8 3333.33 cop table:pay_daily, index:datekey, range:(12565,+inf], keep order:false, stats:pseudo
└─TableScan_9 3333.33 cop table:pay_daily, keep order:false, stats:pseudo
explain select id from pay_daily where datekey>12565 and account_io_type=1;
id count task operator info
Projection_4 3.33 root test.pay_daily.id
└─IndexLookUp_11 3.33 root
├─IndexScan_8 3333.33 cop table:pay_daily, index:datekey, range:(12565,+inf], keep order:false, stats:pseudo
└─Selection_10 3.33 cop eq(test.pay_daily.account_io_type, 1)
└─TableScan_9 3333.33 cop table:pay_daily, keep order:false, stats:pseudo
explain select id from pay_daily where datekey>12565 and tenant_id<159298363;
id count task operator info
Projection_4 1107.78 root test.pay_daily.id
└─IndexLookUp_19 1107.78 root
├─Selection_18 1107.78 cop gt(test.pay_daily.datekey, 12565)
│ └─IndexScan_16 3323.33 cop table:pay_daily, index:tenant_id, poi_id, datekey, range:[-inf,159298363), keep order:false, stats:pseudo
└─TableScan_17 1107.78 cop table:pay_daily, keep order:false
CREATE TABLE `access_path_selection` (
`a` int,
`b` int,
KEY `IDX_a` (`a`),
KEY `IDX_b` (`b`),
KEY `IDX_ab` (`a`, `b`)
);
insert into `access_path_selection` values (1, 0);
insert into `access_path_selection` values (2, 0);
insert into `access_path_selection` values (3, 0);
insert into `access_path_selection` values (4, 0);
explain select a, b from access_path_selection where a < 3;
id count task operator info
IndexReader_12 3323.33 root index:IndexScan_11
└─IndexScan_11 3323.33 cop table:access_path_selection, index:a, b, range:[-inf,3), keep order:false, stats:pseudo
explain select a, b from access_path_selection where b < 3;
id count task operator info
IndexLookUp_10 3323.33 root
├─IndexScan_8 3323.33 cop table:access_path_selection, index:b, range:[-inf,3), keep order:false, stats:pseudo
└─TableScan_9 3323.33 cop table:access_path_selection, keep order:false, stats:pseudo
explain select a, b from access_path_selection where a < 3 and b < 3;
id count task operator info
IndexReader_18 1104.45 root index:Selection_17
└─Selection_17 1104.45 cop lt(test.access_path_selection.b, 3)
└─IndexScan_16 3323.33 cop table:access_path_selection, index:a, b, range:[-inf,3), keep order:false, stats:pseudo
45 changes: 45 additions & 0 deletions cmd/explaintest/t/access_path_selection.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
CREATE TABLE `pay_daily` (
`id` varchar(50) NOT NULL DEFAULT '',
`tenant_id` bigint(11) NOT NULL DEFAULT '0',
`poi_id` bigint(11) NOT NULL DEFAULT '0',
`time_stamp` bigint(11) DEFAULT NULL,
`datekey` int(20) DEFAULT NULL,
`hour` int(11) DEFAULT NULL,
`meal_type` int(11) DEFAULT NULL,
`cashier_id` bigint(11) DEFAULT NULL,
`cashier_name` varchar(50) DEFAULT NULL,
`pay_type_id` bigint(11) DEFAULT NULL,
`pay_type_name` varchar(32) DEFAULT NULL,
`is_custom` varchar(32) DEFAULT NULL,
`account_io_type` int(11) DEFAULT NULL,
`pay_cnt` bigint(11) DEFAULT NULL,
`pay_amt` bigint(11) DEFAULT NULL,
`update_source` int(11) DEFAULT NULL,
`update_time` timestamp DEFAULT NULL,
alivxxx marked this conversation as resolved.
Show resolved Hide resolved
PRIMARY KEY (`id`, `tenant_id`, `poi_id`),
KEY `IDX_ID` (`tenant_id`, `poi_id`, `time_stamp`),
KEY `IDX_DK` (`datekey`),
KEY `IDX_TENANT_POI_DATEKEY` (`tenant_id`, `poi_id`, `datekey`),
KEY `IDX_US` (`update_source`, `tenant_id`)
);
explain select id, tenant_id, poi_id, time_stamp, datekey, hour, meal_type, cashier_id, cashier_name, pay_type_id, is_custom, account_io_type, pay_cnt, pay_amt, update_source from pay_daily where tenant_id=12565 and poi_id=159298363 and datekey=20180731;
explain select id from pay_daily where tenant_id=12565 and poi_id=159298363 and time_stamp=10000;
explain select id from pay_daily where update_source>12565 and tenant_id<159298363;
explain select id from pay_daily where datekey>12565;
explain select id from pay_daily where datekey>12565 and account_io_type=1;
explain select id from pay_daily where datekey>12565 and tenant_id<159298363;

CREATE TABLE `access_path_selection` (
`a` int,
`b` int,
KEY `IDX_a` (`a`),
KEY `IDX_b` (`b`),
KEY `IDX_ab` (`a`, `b`)
);
insert into `access_path_selection` values (1, 0);
winoros marked this conversation as resolved.
Show resolved Hide resolved
insert into `access_path_selection` values (2, 0);
insert into `access_path_selection` values (3, 0);
insert into `access_path_selection` values (4, 0);
explain select a, b from access_path_selection where a < 3;
explain select a, b from access_path_selection where b < 3;
explain select a, b from access_path_selection where a < 3 and b < 3;