SELECT url_id
,Url
,Url_Title
,MIN([First_Visite_Time]) AS 'First_Visite_Time'
,MAX([Last_Visite_Time]) AS 'Last_Visite_Time'
,SUM([User_Count]) + SUM (ISNULL([e_user_count],0)) AS 'UC'
,SUM([IP_Count]) + SUM (ISNULL([e_ip_count],0)) AS 'IP'
,SUM([PV_count]) + SUM (ISNULL([e_pv_count],0)) AS 'PV'
,SUM([Access_Count]) + ISNULL (sum([e_visite_count]),0) AS 'Access_Count'
FROM [report_LinkInfo]
where dt>='2010-7-1' and dt<='2010-8-2'
GROUP BY Url_Id,Url,Url_Title
order by [PV] DESC, [IP] DESC
通过查看执行计划,大部分的时间都花在group by字段和order by字段进行排序,原表在Url_Id,Url,Url_Title字段中已经创建了非聚集索引,但加上order by字段后,就失效了,去掉order by就非常快
精慕HU
慕码人8056858
杨__羊羊
慕运维8079593
相关分类