mysql存储过程对900w数据进行操作测试

新增索引:
LTER TABLE `tablename` ADD INDEX `sdhid` (`createTime`) USING BTREE ;
[SQL]ALTER TABLE `tablename` ADD INDEX `sdhid` (`createTime`) USING BTREE ;
受影响的行: 0
时间: 737.600s

[SQL]ALTER TABLE  tablename add INDEX jkjk(createTime) USING BTREE;
受影响的行: 0
时间: 1586.745s 26分钟

[SQL]delete from tablename where createTime< 95 limit 1;
受影响的行: 0
时间: 109.540s

createTime有索引时删除测试:
[SQL]ALTER TABLE  tablename add INDEX jkjk(createTime) USING BTREE;
受影响的行: 0
时间: 1586.745s 26分钟

[SQL]delete from tablename where createTime< 95 limit 1;
受影响的行: 0
时间: 109.540s

[SQL] delete from tablename where createTime< 95 order by createTime,id limit 1;
[Err] 1205 - Lock wait timeout exceeded; try restarting transaction

[SQL] delete from tablename where createTime< 95 order by createTime,id limit 1;
受影响的行: 0
时间: 185.007s

[SQL]delete from tablename where createTime< 95 order by createTime limit 1;
受影响的行: 0
时间: 169.260s

[SQL]delete from tablename where createTime< 95 limit 1;
受影响的行: 0
时间: 153.959s

createTime无索引时删除测试:
[SQL]delete from tablename where createTime< 95 limit 1;
[Err] 1205 - Lock wait timeout exceeded; try restarting transaction

[SQL]delete from tablename where createTime< 95 limit 1;
[Err] 1205 - Lock wait timeout exceeded; try restarting transaction

[SQL] delete from tablename where createTime< 95 order by createTime,id limit 1;
[Err] 1205 - Lock wait timeout exceeded; try restarting transaction

[SQL]delete from tablename where createTime< 95 limit 1;
[Err] 1205 - Lock wait timeout exceeded; try restarting transaction

[SQL]delete from tablename where createTime< 95 limit 1;
[Err] 1205 - Lock wait timeout exceeded; try restarting transaction

[SQL]delete from tablename where createTime< 95 limit 1;
[Err] 1205 - Lock wait timeout exceeded; try restarting transaction

[SQL]delete from tl_accrued_bil_dtl where create_tm< NOW() limit 1;
受影响的行: 1
时间: 118.756s

[SQL]delete from tl_accrued_bil_dtl where create_tm< NOW() and id=1;
受影响的行: 1
时间: 0.042s
[SQL]delete from tl_accrued_bil_dtl where create_tm< NOW() limit 1;
受影响的行: 1
时间: 80.775s

[SQL]delete from tl_accrued_bil_dtl where create_tm< NOW() and id=3;
受影响的行: 1
时间: 0.052s

[SQL]SELECT * FROM tl_accrued_bil_dtl where create_tm< NOW() ORDER BY id limit 0,2
受影响的行: 0
时间: 0.011s

[SQL]SELECT * FROM tl_accrued_bil_dtl where create_tm< NOW() ORDER BY create_tm limit 0,2
受影响的行: 0
时间: 0.011s

[SQL]SELECT * FROM tl_accrued_bil_dtl where create_tm< NOW()  limit 0,2
受影响的行: 0
时间: 0.978s

[SQL]SELECT * FROM tl_accrued_bil_dtl where create_tm< NOW()  limit 1000
受影响的行: 0
时间: 0.966s

[SQL]SELECT * FROM tl_accrued_bil_dtl where create_tm< NOW()  limit 1000
受影响的行: 0
时间: 1.052s

[SQL]SELECT * FROM tl_accrued_bil_dtl where create_tm< NOW()  limit 0,1000
受影响的行: 0
时间: 1.028s

[SQL]delete from tl_accrued_bil_dtl where create_tm<  NOW() and id=6;
受影响的行: 1
时间: 0.066s

[SQL]delete from tl_accrued_bil_dtl where create_tm<  NOW() limit 1;
受影响的行: 1
时间: 36.632s

[SQL]delete from tl_accrued_bil_dtl where create_tm<  NOW() limit 1000;
受影响的行: 1000
时间: 113.335s

[SQL]delete from tl_accrued_bil_dtl where create_tm<  NOW() limit 1000;
受影响的行: 1000
时间: 72.046s

[SQL]delete from tl_accrued_bil_dtl where create_tm<  NOW() limit 1000;
受影响的行: 1000
时间: 100.126s
[SQL]delete from tl_accrued_bil_dtl where create_tm<  NOW() limit 1000;
受影响的行: 1000
时间: 100.126s

[SQL]SELECT * FROM tl_accrued_bil_dtl where create_tm< NOW()  limit 1000
受影响的行: 0
时间: 1.159s

[SQL]DELETE FROM tl_accrued_bil_dtl where id > 446851336 and id < 446852336 ORDER BY id;
受影响的行: 999
时间: 96.731s

[SQL]DELETE FROM tl_accrued_bil_dtl where id > 446852336 and id < 446853336 ORDER BY id;
受影响的行: 1
时间: 66.578s

[SQL]DELETE FROM tl_accrued_bil_dtl where id > 446853336 and id < 446854336 ORDER BY id;
受影响的行: 999
时间: 73.514s

[SQL]DELETE FROM tl_accrued_bil_dtl where id > 446854336 and id < 446855336 ORDER BY id;
受影响的行: 999
时间: 71.382s

时间: 144.727s
Procedure executed successfully
受影响的行: 0

[SQL]DELETE FROM tl_accrued_bil_dtl where create_tm<NOW() LIMIT 999;
受影响的行: 999
时间: 70.356s

[SQL]DELETE FROM tl_accrued_bil_dtl where create_tm<NOW() LIMIT 999;
受影响的行: 999
时间: 65.939s

多多指教呀,什么

上一篇:[MySQL] MySQL存储过程 事务transaction 数据表重建


下一篇:MySQL存储过程循环添加数据