zoukankan      html  css  js  c++  java
  • mysql update语句 in执行效率优化

    1、常用的mysql执行更新操作语句如下:

    UPDATE table1 set num = num + 1 where id in (SELECT id FROM table2 WHERE date>'2017-05-09)

    in条件的更新效率可优化使用join语法;
    2、join预发更新操作

    UPDATE table1 t1 INNER JOIN table2 t2 on t1.id = t2.id set t1.num = t1.num + 1 where t2.date>'2017-05-09'

    1、要更新的数据大概 有10W多条  然后 我执行了下 结果 2个小时了 还是没 执行成功

    pdate  table1 t  set t.column1 =0 where t.id in (select id from table2)  

     2、 sql 改成

    update table1 t ,table2 b set t.column1=0 where t.id=b.id  

       几秒钟就执行成功  !!!

  • 相关阅读:
    luogu 2962 [USACO09NOV]灯Lights
    bzoj 1923
    bzoj 1013
    bzoj 3513
    bzoj 4259
    bzoj 4503
    CF 632E
    bzoj 3527
    bzoj 3160
    bzoj 2179
  • 原文地址:https://www.cnblogs.com/microtiger/p/13590713.html
Copyright © 2011-2022 走看看