首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2013-06-19 
求大神帮我优化这个sql语句select distinctuserid from userlog where userid not in(selectdistinct user

求大神帮我优化这个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

热点排行