建表

CREATE TABLE `ts_ab` (   `id` int(11) NOT NULL,   `a` int(11) DEFAULT NULL,   `b` varchar(20) CHARACTER SET utf8 DEFAULT NULL,   PRIMARY KEY (`id`),   KEY `ind_b` (`b`) USING BTREE,   KEY `ind_a` (`a`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `ts_ef` (   `id` int(11) NOT NULL,   `e` int(11) DEFAULT NULL,   `f` varchar(20) CHARACTER SET utf8 DEFAULT NULL,   PRIMARY KEY (`id`),   KEY `ind_e` (`e`) USING BTREE,   KEY `ind_f` (`f`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

插入数据

create PROCEDURE addDataab() BEGIN     DECLARE i int;     set i=1;     WHILE(i<=10000) DO         INSERT ts_ab(id, a, b) VALUES(i, i, CONCAT('b',i));         set i= i+1;     end WHILE;     WHILE(i<=20000) DO         INSERT ts_ab(id, a, b) VALUES(i, i, CONCAT('c',i));         set i= i+1;     end WHILE;     WHILE(i<=30000) DO         INSERT ts_ab(id, a, b) VALUES(i, i, CONCAT('d',i));         set i= i+1;     end WHILE; end; CALL addDataab();