update t1 as a inner join t2 as b on a.ip=b.ip set a.hostroom=b.hostroom where a.hostroom is null
超慢,卡住不动了
where a.hostroom is null有17000条记录
怎么这样呢

解决方案 »

  1.   

    on a.ip=b.ipIP字段上需要添加索引。
      

  2.   

    update 操作是先找到需要修改的记录,然后再改成目标数据,然后再刷写到磁盘固化,一般来说查找是效率的短板,解决这个之后UPDATE就会快起来。
    a.ip=b.ip IP字段加上索引能解决问题。
      

  3.   


    explain 
    select a.hostroom ,b.hostroom
    t1 as a inner join t2 as b on a.ip=b.ip  where a.hostroom is null
    ;