1.插入
分批次插入
5w條數據,每次插入5000,總耗時在50s左右
2.刪除
mysql一次性刪除大量數據是有可能造成死鎖的,而且也會拋異常
這是由於需要刪除的數據太大,mysql給的buffer好像只有8MB左右
The total number of locks exceeds the lock table size in MySQL
這是由於需要刪除的數據太大,mysql給的buffer好像只有8MB左右
lock wait timeout exceed
超時
加索引、計算maxId,統計數目count
SELECT max(id) from indonesia_camp_pit where timestamp <時間
SELECT count(*) from indonesia_camp_pit where id <maxId
循環分批次刪除
delete from indonesia_camp_pit where id <maxId limit 10000
每次刪除1w條耗時300ms-500ms左右,總共刪除100w-200w耗時30s