+ -
当前位置:首页 → 问答吧 → MySQL 加快 update 速度

MySQL 加快 update 速度

时间:2014-07-16

来源:互联网

小弟有个 program 会行一条 SQL 来 update 由上个月到而家某些 record, 将 flag3 由 N 变成 Y:

update table1 as a, table1 as b set b.flag3='Y' where a.flag3='Y' and a.connection=b.connection and and a.employee_id=b.employee_id and b.flag3='N' and b.flag2='DD' and b.flag1 like 'BB%' and b.connection>='2014-03-01'

同一组我想搵出来既会有两条 record, 个 connection time 会系一样, 其余 flag1, flag2, flag3 唔一样, 但由於其他 employee_id 亦有机会产生任何 connection time 既 record, 所以我用左 table1 self join 形式去搵相关 record 出来.
但发觉速度好慢, 要用一粒钟先行完, 请问有冇方法改动一下可以加快速度呢? 唔该晒.

作者: barca883   发布时间: 2014-07-16

点解唔真接update N 做Y???

作者: powerman3099   发布时间: 2014-07-16

可以减少你的where causes?

作者: 风生汽水   发布时间: 2014-07-16