首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

大数据量 update语句 优化?解决方法

2012-03-28 
大数据量 update语句 优化??mysql 中,一百万条记录,根据如下语句更新?还能继续优化吗SQL codeupdate a set

大数据量 update语句 优化??
mysql 中,一百万条记录,根据如下语句更新?还能继续优化吗

SQL code
update a set identity=(select identity  from b where id='002512' ORDER BY identity desc limit 1 ) where  msgidentify='002512' and (identity is null or  identity='') ;




[解决办法]
语句上没什么可优化了。

不过如果有如下索引会提高这个SQL语句的速度。

b(id,identity)

a(msgidentify,identity)
[解决办法]
语句好像没能呢,加索引试试
[解决办法]
如果你的msgidentify是主键或索引的话,那就已经没有优化空间了
[解决办法]
select identity from b where id='002512' 
ORDER BY identity desc limit 1 
生成临时表,再替换

热点排行