github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/dbs/cmd/benchdb/explaintest/r/topn_push_down.result (about) 1 CREATE TABLE `tr` ( 2 `id` bigint(20) NOT NULL, 3 `biz_date` date NOT NULL, 4 `petri_type` tinyint(4) NOT NULL, 5 `business_type` tinyint(4) NOT NULL, 6 `trade_type` tinyint(4) NOT NULL DEFAULT '1', 7 `trade_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), 8 `trade_status` tinyint(4) NOT NULL DEFAULT '0', 9 `trade_pay_status` tinyint(4) NOT NULL DEFAULT '0', 10 `delivery_type` tinyint(4) NOT NULL DEFAULT '0', 11 `source` tinyint(4) NOT NULL, 12 `source_child` mediumint(9) DEFAULT NULL, 13 `trade_no` varchar(26) NOT NULL, 14 `sku_HoTT_count` int(11) NOT NULL, 15 `sale_amount` decimal(10,2) NOT NULL DEFAULT '0.00', 16 `privilege_amount` decimal(10,2) NOT NULL DEFAULT '0.00', 17 `trade_amount` decimal(10,2) NOT NULL DEFAULT '0.00', 18 `trade_amount_before` decimal(10,2) NOT NULL DEFAULT '0.00', 19 `trade_memo` varchar(100) DEFAULT NULL, 20 `relate_trade_id` bigint(20) DEFAULT NULL, 21 `relate_trade_uuid` varchar(32) DEFAULT NULL, 22 `brand_identy` bigint(20) NOT NULL, 23 `shop_identy` bigint(20) NOT NULL, 24 `device_identy` varchar(36) NOT NULL, 25 `uuid` varchar(32) NOT NULL, 26 `status_flag` tinyint(4) NOT NULL, 27 `client_create_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), 28 `client_uFIDelate_time` timestamp(3) NULL DEFAULT NULL, 29 `server_create_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), 30 `server_uFIDelate_time` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3) ON UFIDelATE CURRENT_TIMESTAMP(3), 31 `creator_id` bigint(20) DEFAULT NULL, 32 `creator_name` varchar(32) DEFAULT NULL, 33 `uFIDelator_id` bigint(20) DEFAULT NULL, 34 `uFIDelator_name` varchar(32) DEFAULT NULL, 35 `trade_people_count` int(4) DEFAULT NULL, 36 `trade_pay_form` tinyint(4) NOT NULL DEFAULT '1', 37 `print_time` timestamp(3) NULL DEFAULT NULL, 38 `action_type` tinyint(4) NOT NULL DEFAULT '1', 39 `recycle_status` tinyint(1) NOT NULL DEFAULT '1', 40 `rds_source_calm` varchar(100) DEFAULT NULL, 41 PRIMARY KEY (`id`), 42 UNIQUE KEY `uuid` (`uuid`), 43 KEY `idx_server_uFIDelate_time` (`shop_identy`,`server_uFIDelate_time`), 44 KEY `idx_server_create_time` (`server_create_time`), 45 KEY `idx_trade_no` (`trade_no`), 46 KEY `idx_relate_trade_id` (`relate_trade_id`), 47 KEY `idx_brand_identy_biz_date` (`brand_identy`,`biz_date`), 48 KEY `idx_trade_status_server_create_time` (`trade_status`,`server_create_time`), 49 KEY `idx_shop_identy_biz_date` (`shop_identy`,`biz_date`), 50 KEY `idx_shop_identy_server_create_time` (`shop_identy`,`server_create_time`), 51 KEY `idx_shop_identy_trade_status_business_type` (`shop_identy`,`trade_status`,`business_type`,`trade_pay_status`,`trade_type`,`delivery_type`,`source`,`biz_date`) 52 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT=''; 53 CREATE TABLE `p` ( 54 `id` bigint(20) NOT NULL, 55 `biz_date` date NOT NULL, 56 `payment_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 57 `payment_type` int(11) NOT NULL, 58 `relate_id` bigint(20) DEFAULT NULL, 59 `relate_uuid` varchar(32) DEFAULT NULL, 60 `receivable_amount` decimal(10,2) NOT NULL DEFAULT '0.00', 61 `exempt_amount` decimal(10,2) NOT NULL DEFAULT '0.00', 62 `actual_amount` decimal(10,2) NOT NULL DEFAULT '0.00', 63 `handover_uuid` varchar(32) DEFAULT NULL, 64 `brand_identy` bigint(20) NOT NULL, 65 `shop_identy` bigint(20) NOT NULL, 66 `device_identy` varchar(36) NOT NULL, 67 `uuid` varchar(32) NOT NULL, 68 `status_flag` tinyint(4) NOT NULL DEFAULT '1', 69 `client_create_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), 70 `client_uFIDelate_time` timestamp(3) NULL DEFAULT NULL, 71 `server_create_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), 72 `server_uFIDelate_time` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3) ON UFIDelATE CURRENT_TIMESTAMP(3), 73 `creator_id` bigint(20) DEFAULT NULL, 74 `creator_name` varchar(32) DEFAULT NULL, 75 `uFIDelator_id` bigint(20) DEFAULT NULL, 76 `uFIDelator_name` varchar(32) DEFAULT NULL, 77 `is_paid` tinyint(4) DEFAULT '1', 78 `memo` varchar(100) DEFAULT NULL, 79 `recycle_status` tinyint(1) NOT NULL DEFAULT '1', 80 `shop_actual_amount` decimal(10,2) NOT NULL DEFAULT '0.00', 81 `rds_source_calm` varchar(100) DEFAULT NULL, 82 PRIMARY KEY (`id`), 83 UNIQUE KEY `uuid` (`uuid`), 84 KEY `payment_relate_id` (`relate_id`), 85 KEY `idx_shop_identy_biz_date` (`shop_identy`,`biz_date`), 86 KEY `idx_relate_uuid` (`relate_uuid`(8)), 87 KEY `idx_shop_identy_server_uFIDelate_time` (`shop_identy`,`server_uFIDelate_time`), 88 KEY `idx_shop_identy_server_create_time` (`shop_identy`,`server_create_time`), 89 KEY `idx_server_create_time` (`server_create_time`), 90 KEY `idx_brand_identy_shop_identy_payment_time` (`brand_identy`,`shop_identy`,`payment_time`), 91 KEY `idx_handover_uuid` (`handover_uuid`(8)), 92 KEY `idx_shop_identy_handover_uuid_payment_time` (`shop_identy`,`handover_uuid`(1),`payment_time`) 93 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT=''; 94 CREATE TABLE `te` ( 95 `id` bigint(20) NOT NULL, 96 `trade_id` bigint(20) NOT NULL, 97 `trade_uuid` varchar(32) NOT NULL, 98 `number_plate` varchar(32) DEFAULT NULL, 99 `fix_type` tinyint(4) DEFAULT NULL, 100 `called` tinyint(4) DEFAULT NULL, 101 `invoice_title` varchar(64) DEFAULT NULL, 102 `expect_time` timestamp NULL DEFAULT NULL, 103 `receiver_phone` varchar(16) DEFAULT NULL, 104 `receiver_name` varchar(32) DEFAULT NULL, 105 `receiver_sex` tinyint(4) DEFAULT NULL, 106 `delivery_address_id` bigint(20) DEFAULT NULL, 107 `delivery_address` varchar(500) DEFAULT NULL, 108 `received_time` timestamp NULL DEFAULT NULL, 109 `delivery_fee` decimal(10,2) DEFAULT NULL, 110 `device_platform` varchar(20) DEFAULT NULL, 111 `device_token` varchar(128) DEFAULT NULL, 112 `open_identy` varchar(100) DEFAULT NULL, 113 `user_identy` bigint(20) DEFAULT NULL, 114 `third_tran_no` varchar(100) DEFAULT NULL, 115 `brand_identy` bigint(20) NOT NULL, 116 `shop_identy` bigint(20) NOT NULL, 117 `device_identy` varchar(36) NOT NULL, 118 `uuid` varchar(32) NOT NULL, 119 `status_flag` tinyint(4) NOT NULL, 120 `client_create_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), 121 `client_uFIDelate_time` timestamp(3) NULL DEFAULT NULL, 122 `server_create_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), 123 `server_uFIDelate_time` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3) ON UFIDelATE CURRENT_TIMESTAMP(3), 124 `creator_id` bigint(20) DEFAULT NULL, 125 `creator_name` varchar(32) DEFAULT NULL, 126 `uFIDelator_id` bigint(20) DEFAULT NULL, 127 `uFIDelator_name` varchar(32) DEFAULT NULL, 128 `call_dish_status` tinyint(4) NOT NULL DEFAULT '0', 129 `delivery_man` varchar(50) DEFAULT NULL, 130 `delivery_status` tinyint(4) NOT NULL DEFAULT '0', 131 `delivery_user_id` varchar(50) DEFAULT NULL, 132 `delivery_real_time` timestamp NULL DEFAULT NULL, 133 `send_area_id` bigint(20) DEFAULT NULL, 134 `order_tip` tinyint(4) NOT NULL DEFAULT '0', 135 `binding_delivery_user_time` timestamp(3) NULL DEFAULT NULL, 136 `square_up_time` timestamp(3) NULL DEFAULT NULL, 137 `is_sub_mch` tinyint(1) DEFAULT '0', 138 `serial_number` varchar(50) NOT NULL DEFAULT '', 139 `recycle_status` tinyint(1) NOT NULL DEFAULT '1', 140 `delivery_platform` bigint(20) NOT NULL DEFAULT '1', 141 `is_printed` tinyint(4) NOT NULL DEFAULT '1', 142 `third_serial_no` varchar(50) DEFAULT NULL, 143 `has_serving` tinyint(4) NOT NULL DEFAULT '1', 144 `device_no` varchar(6) DEFAULT NULL, 145 `third_service_charge` decimal(10,2) DEFAULT '0.00', 146 `third_subsidies` decimal(10,2) DEFAULT '0.00', 147 `rds_source_calm` varchar(100) DEFAULT NULL, 148 PRIMARY KEY (`id`), 149 UNIQUE KEY `uuid` (`uuid`), 150 KEY `idx_trade_id` (`trade_id`), 151 KEY `idx_server_uFIDelate_time` (`shop_identy`,`server_uFIDelate_time`), 152 KEY `idx_receiver_phone` (`receiver_phone`(11)), 153 KEY `idx_delivery_status_delivery_user_id` (`delivery_status`,`delivery_user_id`(10)), 154 KEY `idx_trade_uuid` (`trade_uuid`(10)), 155 KEY `idx_third_tran_no` (`third_tran_no`(10)) 156 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT=''; 157 EXPLAIN SELECT te.expect_time AS expected_time FROM 158 tr tr inner JOIN te te ON te.trade_id = tr.id 159 left JOIN p p ON p.relate_id = tr.id 160 WHERE 161 tr.brand_identy = 32314 AND 162 tr.shop_identy = 810094178 AND 163 tr.petri_type = 2 AND 164 tr.business_type = 18 AND 165 tr.trade_type IN (1) AND 166 te.expect_time BETWEEN '2020-04-23 00:00:00.0' AND '2020-04-23 23:59:59.0' 167 ORDER BY te.expect_time asc 168 LIMIT 0, 5; 169 id estRows task access object operator info 170 Limit_19 0.00 root offset:0, count:5 171 └─IndexJoin_118 0.00 root left outer join, inner:IndexReader_117, outer key:test.tr.id, inner key:test.p.relate_id 172 ├─TopN_127(Build) 0.00 root test.te.expect_time, offset:0, count:5 173 │ └─IndexMergeJoin_53 0.00 root inner join, inner:Projection_51, outer key:test.tr.id, inner key:test.te.trade_id 174 │ ├─IndexLookUp_98(Build) 0.00 root 175 │ │ ├─Selection_96(Build) 0.00 cop[einsteindb] eq(test.tr.business_type, 18), eq(test.tr.trade_type, 1) 176 │ │ │ └─IndexRangeScan_94 10.00 cop[einsteindb] causet: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 177 │ │ └─Selection_97(Probe) 0.00 cop[einsteindb] eq(test.tr.brand_identy, 32314), eq(test.tr.petri_type, 2) 178 │ │ └─TableRowIDScan_95 0.00 cop[einsteindb] causet:tr keep order:false, stats:pseudo 179 │ └─Projection_51(Probe) 1.25 root test.te.trade_id, test.te.expect_time 180 │ └─IndexLookUp_50 1.25 root 181 │ ├─IndexRangeScan_47(Build) 50.00 cop[einsteindb] causet:te, index:idx_trade_id(trade_id) range: decided by [eq(test.te.trade_id, test.tr.id)], keep order:true, stats:pseudo 182 │ └─Selection_49(Probe) 1.25 cop[einsteindb] ge(test.te.expect_time, 2020-04-23 00:00:00.000000), le(test.te.expect_time, 2020-04-23 23:59:59.000000) 183 │ └─TableRowIDScan_48 50.00 cop[einsteindb] causet:te keep order:false, stats:pseudo 184 └─IndexReader_117(Probe) 1.25 root index:Selection_116 185 └─Selection_116 1.25 cop[einsteindb] not(isnull(test.p.relate_id)) 186 └─IndexRangeScan_115 1.25 cop[einsteindb] causet:p, index:payment_relate_id(relate_id) range: decided by [eq(test.p.relate_id, test.tr.id)], keep order:false, stats:pseudo 187 desc select 1 as a from dual order by a limit 1; 188 id estRows task access object operator info 189 Projection_6 1.00 root 1->DeferredCauset#1 190 └─TableDual_7 1.00 root rows:1 191 drop causet if exists t1; 192 drop causet if exists t2; 193 create causet t1(a bigint, b bigint); 194 create causet t2(a bigint, b bigint); 195 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); 196 id estRows task access object operator info 197 Apply_15 9990.00 root semi join, equal:[eq(test.t1.a, test.t2.a)] 198 ├─TableReader_18(Build) 9990.00 root data:Selection_17 199 │ └─Selection_17 9990.00 cop[einsteindb] not(isnull(test.t1.a)) 200 │ └─TableFullScan_16 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 201 └─Selection_19(Probe) 0.80 root not(isnull(test.t2.a)) 202 └─Limit_20 1.00 root offset:0, count:1 203 └─TableReader_26 1.00 root data:Limit_25 204 └─Limit_25 1.00 cop[einsteindb] offset:0, count:1 205 └─Selection_24 1.00 cop[einsteindb] gt(test.t2.b, test.t1.b) 206 └─TableFullScan_23 1.25 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 207 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); 208 id estRows task access object operator info 209 Apply_17 9990.00 root semi join, equal:[eq(test.t1.a, test.t2.a)] 210 ├─TableReader_20(Build) 9990.00 root data:Selection_19 211 │ └─Selection_19 9990.00 cop[einsteindb] not(isnull(test.t1.a)) 212 │ └─TableFullScan_18 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 213 └─Selection_21(Probe) 0.80 root not(isnull(test.t2.a)) 214 └─Projection_22 1.00 root test.t2.a 215 └─Limit_23 1.00 root offset:0, count:1 216 └─TableReader_29 1.00 root data:Limit_28 217 └─Limit_28 1.00 cop[einsteindb] offset:0, count:1 218 └─Selection_27 1.00 cop[einsteindb] gt(test.t2.b, test.t1.b) 219 └─TableFullScan_26 1.25 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 220 drop causet if exists t; 221 create causet t(a int not null, index idx(a)); 222 explain select /*+ MilevaDB_INLJ(t2) */ * from t t1 join t t2 on t1.a = t2.a limit 5; 223 id estRows task access object operator info 224 Limit_11 5.00 root offset:0, count:5 225 └─IndexJoin_15 5.00 root inner join, inner:IndexReader_14, outer key:test.t.a, inner key:test.t.a 226 ├─TableReader_23(Build) 4.00 root data:TableFullScan_22 227 │ └─TableFullScan_22 4.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 228 └─IndexReader_14(Probe) 1.25 root index:IndexRangeScan_13 229 └─IndexRangeScan_13 1.25 cop[einsteindb] causet:t2, index:idx(a) range: decided by [eq(test.t.a, test.t.a)], keep order:false, stats:pseudo 230 explain select /*+ MilevaDB_INLJ(t2) */ * from t t1 left join t t2 on t1.a = t2.a where t2.a is null limit 5; 231 id estRows task access object operator info 232 Limit_12 5.00 root offset:0, count:5 233 └─Selection_13 5.00 root isnull(test.t.a) 234 └─IndexJoin_17 5.00 root left outer join, inner:IndexReader_16, outer key:test.t.a, inner key:test.t.a 235 ├─TableReader_25(Build) 4.00 root data:TableFullScan_24 236 │ └─TableFullScan_24 4.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 237 └─IndexReader_16(Probe) 1.25 root index:IndexRangeScan_15 238 └─IndexRangeScan_15 1.25 cop[einsteindb] causet:t2, index:idx(a) range: decided by [eq(test.t.a, test.t.a)], keep order:false, stats:pseudo 239 explain select /*+ MilevaDB_SMJ(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a limit 5; 240 id estRows task access object operator info 241 Limit_11 5.00 root offset:0, count:5 242 └─MergeJoin_12 5.00 root inner join, left key:test.t.a, right key:test.t.a 243 ├─IndexReader_17(Build) 4.00 root index:IndexFullScan_16 244 │ └─IndexFullScan_16 4.00 cop[einsteindb] causet:t2, index:idx(a) keep order:true, stats:pseudo 245 └─IndexReader_15(Probe) 4.00 root index:IndexFullScan_14 246 └─IndexFullScan_14 4.00 cop[einsteindb] causet:t1, index:idx(a) keep order:true, stats:pseudo 247 explain select /*+ MilevaDB_SMJ(t1, t2) */ * from t t1 left join t t2 on t1.a = t2.a where t2.a is null limit 5; 248 id estRows task access object operator info 249 Limit_12 5.00 root offset:0, count:5 250 └─Selection_13 5.00 root isnull(test.t.a) 251 └─MergeJoin_14 5.00 root left outer join, left key:test.t.a, right key:test.t.a 252 ├─IndexReader_19(Build) 4.00 root index:IndexFullScan_18 253 │ └─IndexFullScan_18 4.00 cop[einsteindb] causet:t2, index:idx(a) keep order:true, stats:pseudo 254 └─IndexReader_17(Probe) 4.00 root index:IndexFullScan_16 255 └─IndexFullScan_16 4.00 cop[einsteindb] causet:t1, index:idx(a) keep order:true, stats:pseudo 256 explain select /*+ MilevaDB_HJ(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a limit 5; 257 id estRows task access object operator info 258 Limit_11 5.00 root offset:0, count:5 259 └─HashJoin_31 5.00 root inner join, equal:[eq(test.t.a, test.t.a)] 260 ├─TableReader_38(Build) 10000.00 root data:TableFullScan_37 261 │ └─TableFullScan_37 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 262 └─TableReader_34(Probe) 4.00 root data:TableFullScan_33 263 └─TableFullScan_33 4.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 264 explain select /*+ MilevaDB_HJ(t1, t2) */ * from t t1 left join t t2 on t1.a = t2.a where t2.a is null limit 5; 265 id estRows task access object operator info 266 Limit_12 5.00 root offset:0, count:5 267 └─Selection_13 5.00 root isnull(test.t.a) 268 └─HashJoin_25 5.00 root left outer join, equal:[eq(test.t.a, test.t.a)] 269 ├─TableReader_27(Build) 4.00 root data:TableFullScan_26 270 │ └─TableFullScan_26 4.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 271 └─TableReader_31(Probe) 10000.00 root data:TableFullScan_30 272 └─TableFullScan_30 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo