MySQL的测试环境
测试表如下
create tabletest_table2
(
idint auto_increment primary key,
pay_idint,
pay_timedatetime,
other_colvarchar(100)
)
建一个存储过程插入测试数据,测试数据的特点是pay_id可重复,这里在存储过程处理成,循环插入300W条数据的过程中,每隔100条数据插入一条重复的pay_id,时间字段在一定范围内随机
CREATE DEFINER=`root`@`%` PROCEDURE `test_insert`(IN `loopcount` INT)
LANGUAGE SQLNOTDETERMINISTICCONTAINSSQL
SQL SECURITY DEFINER
COMMENT”
BEGIN
declare cnt int;set cnt = 0;while cnt
insert into test_table2 (pay_id,pay_time,other_col) values (cnt,date_add(now(), interval floor(300*rand()) day),uuid());end if;set cnt = cnt + 1;end while;END<