我有一个页面,它需要太长时间才能加载,因为它必须计算每个类别中成员的数量。 http://www.storeboard.com/counties/default.asp?cou=1196更快的SQL计数
经进一步调查,我偶然发现这个页面:http://blogs.msdn.com/b/martijnh/archive/2010/07/15/sql-server-how-to-quickly-retrieve-accurate-row-count-for-table.aspx
我的问题是我如何改变这样的:在我引用的页面的解决方案4
SELECT COUNT(MemberID) AS MembersInCountyCat
FROM Member
WHERE NYKACountyID = @NYKACountyID
AND (
NYKACatID = @NYKACatID
OR NYKACatIDExtra1 = @NYKACatID
OR NYKACatIDExtra2 = @NYKACatID
OR NYKACatIDExtra3 = @NYKACatID
OR NYKACatIDExtra4 = @NYKACatID
OR NYKACatIDExtra5 = @NYKACatID
OR NYKACatIDExtra6 = @NYKACatID
OR NYKACatIDExtra7 = @NYKACatID
OR NYKACatIDExtra8 = @NYKACatID
OR NYKACatIDExtra9 = @NYKACatID
OR NYKACatIDExtra10 = @NYKACatID
)
AND ProfileTypeID <> 1
走进建议。
任何帮助,您可以提供将不胜感激。
非常感谢,保罗
为表这些例子查询对象/索引级统计的MemberIds,你不能给他们应用一个条件 - 你的示例页面看起来像是希望为每个类别计算X,但是你的查询示例似乎并不适用于它们的集合,那么你使用的整个sql – 2012-03-19 17:15:18