日期:2014-05-18  浏览次数:20370 次

非常奇怪的问题
SELECT   CASE   WHEN   temp2.UserCount   IS   NULL   THEN   9   ELSE   temp2.UserCount+9   END   AS   UserCount,a.Application  
FROM  
(select   temp.Application,COUNT(*)   AS   UserCount
from  
(select   f.Application
from   myUserRights   ur
inner   join   myFunction   f   on   ur.ObjectType=f.FunctionCode
inner   join   myUser   u   on   ur.UserGUID=u.UserGUID
where   u.IsAdmin=0   and   (IsDisabeld=0   or   IsDisabeld   is   null)
group   by   f.Application,ur.UserGUID
)   as   temp                
group   by   temp.Application
)   AS   temp2    
RIGHT   JOIN  
myApplication   a   ON   a.Application=temp2.Application
--WHERE   a.Level=1

执行时间136   ms,如果不注释掉最后的where子句,执行时间63563     ms
不知道怎么会有这种怪事,temp2的表只有3行数据,myApplication也只有10行数据。
求高手指导

------解决方案--------------------
这么少的数据,把你的数据和结构贴出来,包括索引约束,我来测试测试
------解决方案--------------------
重装了一下数据库,还不正常,才真是怪.
------解决方案--------------------
呵呵~~。。。重装还真能解决不少问题啊
------解决方案--------------------
楼主太有才了!