先建一个简单的表,表里有 a、b 两个字段,并分别建上索引

CREATE TABLE `t` (
  `id` int(11) NOT NULL,
  `a` int(11) DEFAULT NULL,
  `b` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `a` (`a`),
  KEY `b` (`b`)
) ENGINE=InnoDB;

存储过程脚本

delimiter ;;
create procedure idata()
begin
  declare i int;
  set i=1;
START TRANSACTION;
  while(i<=100000)do
    insert into t values(i, i, i);
    set i=i+1;
  end while;
commit;
end;;
delimiter ;
call idata();