1
我在我的应用程序中使用SqlserverCe精简版。 我在查询中使用左连接。 Sqlce需要更多的时间来执行。下面 是代码SqlServerCe精简版中的查询优化
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
请帮助我,我怎么能避免complexty
我没有任何列索引。在这种情况下,索引会提高性能 – Ram
是的。索引提高了性能。没有它们,SQL必须查看每一行来决定是否包含它。 –