Update Client a
INNER JOIN DoNotCallList b on (a.tmpphone=b.PhoneNo)
set a.donotcall=b.status,a.DateOfLastDNCLScrub=b.DateCreated
where a.tmpphone in (select c.phoneNO FROM DoNotCallList c);
结果,发现如果 client中的tmpphone 都不在DoNotCallList表中时,速度却很慢,,若有数据倒是会快点。是不是我的sql有的问题?
表结构如个
Client(clientid,HomePhone,Cellphone,TmpPhone)
DoNotCallList(PhoneNo,status,DateCreated)
4 个解决方案
#1
where a.tmpphone in (select c.phoneNO FROM DoNotCallList c);可以不需要吧?
建立索引没有 tmpphone 、PhoneNo
建立索引没有 tmpphone 、PhoneNo
#2
Update Client a
INNER JOIN DoNotCallList b on (a.tmpphone=b.PhoneNo)
set a.donotcall=b.status,a.DateOfLastDNCLScrub=b.DateCreated
INNER JOIN DoNotCallList b on (a.tmpphone=b.PhoneNo)
set a.donotcall=b.status,a.DateOfLastDNCLScrub=b.DateCreated
#3
二边的phoneno都有索引。看来就有我多加了个条件引起的where a.tmpphone in (select c.phoneNO FROM DoNotCallList c);我再测试一下
#4
where a.tmpphone in (select c.phoneNO FROM DoNotCallList c);
这种in语句在mysql中效率非常低
这种in语句在mysql中效率非常低
#1
where a.tmpphone in (select c.phoneNO FROM DoNotCallList c);可以不需要吧?
建立索引没有 tmpphone 、PhoneNo
建立索引没有 tmpphone 、PhoneNo
#2
Update Client a
INNER JOIN DoNotCallList b on (a.tmpphone=b.PhoneNo)
set a.donotcall=b.status,a.DateOfLastDNCLScrub=b.DateCreated
INNER JOIN DoNotCallList b on (a.tmpphone=b.PhoneNo)
set a.donotcall=b.status,a.DateOfLastDNCLScrub=b.DateCreated
#3
二边的phoneno都有索引。看来就有我多加了个条件引起的where a.tmpphone in (select c.phoneNO FROM DoNotCallList c);我再测试一下
#4
where a.tmpphone in (select c.phoneNO FROM DoNotCallList c);
这种in语句在mysql中效率非常低
这种in语句在mysql中效率非常低