场景:MySQL,MyISAM表类型,没有事务
表结构: a1,a2字段为联合主键,a3为要修改的字段先在内存里收集一小时,再更新到数据库存(只更新数据,不能新增数据)
数据量大概2W条记录
如何把内存只的2W条记录快速的更新数据库存的记录?
我现在使用拼接SQL的方法,把100条语句拼成一条再提交
比如
update t set a3='a1' where a1=1 and a2=2;update t set a3='a2' where a1=2 and a2=2;update t set a3='a3' where a1=3 and a2=3;
但还是有点慢啊网上还有介绍说使用replace into
表结构: a1,a2字段为联合主键,a3为要修改的字段先在内存里收集一小时,再更新到数据库存(只更新数据,不能新增数据)
数据量大概2W条记录
如何把内存只的2W条记录快速的更新数据库存的记录?
我现在使用拼接SQL的方法,把100条语句拼成一条再提交
比如
update t set a3='a1' where a1=1 and a2=2;update t set a3='a2' where a1=2 and a2=2;update t set a3='a3' where a1=3 and a2=3;
但还是有点慢啊网上还有介绍说使用replace into
使用replace int会不会快很多呢?
再将文件写入到数据库中。
写入文本 在用crontab 来实现吧