一个大表a更新发现速度很慢
a有数据100多万
这个update语句是 update a set isHis='Y',isLog="Y" where isHis='N'
and id in(23243,122323,345345,..................)-----  这些id共有22万个我当前在java+linux+mysql+tomcat
我当前用的是批量提交方式,
将这22w划分为每1w提交1次,现在发现在本地是1w 是1分(最快), linxu环境
那么这22wid和100w的a表的更新共计20多分。在my.cnf已经做了配置优化。 现在想知道如何才能提高速度 ,这个以后上线必须提高速度?(a表的那3个字段分别有索引)

解决方案 »

  1.   

    isHis='Y',isLog="Y" where isHis='N'
    这3个字段有索引不如没有索引。
      

  2.   

    explain  发现是走索引的
    ---+
    | id | select_type | table                         | type | possible_keys                          | key             | key_len | ref   | rows  | Extra       |
    +----+-------------+-------------------------------+------+----------------------------------------+-----------------+---------+-------+-------+-------------+
    |  1 | SIMPLE      | Eventhistory_copy | ref  | idx_EP_history,idx_EPH1_islast | idx_EPH1_islast | 3       | const | 80770 | Using where |
    +----+-------------+-------------------------------+------+----------------------------------------+-----------------+---------+-------+-------+-------------+
    1 row in set