文章出處

新增索引:
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













相關:ORACLE中用rownum分頁并排序的SQL語句


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()