当前位置: 代码迷 >> Sql Server >> 求大神帮小弟我优化这个sql语句
  详细解决方案

求大神帮小弟我优化这个sql语句

热度:68   发布时间:2016-04-24 22:40:49.0
求大神帮我优化这个sql语句
select distinct  userid from userlog where userid not in(select  distinct userid from #user) 
and accesstime >='2013-04-27' and accesstime<'2013-04-28';


怎么修改? 现在效率太低

------解决方案--------------------
select distinct  userid 
from userlog t
where 
not exists(select userid from #user t1 where t.userid=t1.userid) 
and accesstime >='2013-04-27' and accesstime<'2013-04-28';

userlog以及#user表中userid设置索引
userlog中创建accesstime索引

http://www.cnblogs.com/worfdream/articles/3040204.html
  相关解决方案