SqlServerCe Compact Edition中的查询优化

时间:2011-10-25 13:27:56

标签: sql-server-ce

我在我的应用程序中使用SqlserverCe压缩版。 我在查询中使用左连接。 Sqlce需要更多时间来执行。 下面是代码

SELECT calllog.consolename AS consolename, 
       COUNT(consolename)  AS totalcalls, 
       sub.cnt             AS emergencycalls 
FROM   calllog 
       LEFT JOIN (SELECT consolename, 
                         COUNT(*) AS cnt 
                  FROM   calllog 
                  WHERE  emergencycall = 'False' 
                         AND ( begintime >= '3/6/2011 10:52:39 AM' 
                               AND endtime <= '10/25/2011 6:52:39 PM' ) 
                  GROUP  BY consolename) AS sub 
         ON calllog.consolename = sub.consolename 
WHERE  ( begintime >= '3/6/2011 10:52:39 AM' 
         AND endtime <= '10/25/2011 6:52:39 PM' ) 
GROUP  BY calllog.consolename, 
          sub.cnt 
ORDER  BY totalcalls ASC 

请帮助我如何避免复杂

1 个答案:

答案 0 :(得分:0)

确保您拥有BeginTime,EndTime,EmergencyCall等的索引