![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
hi, I have a table with several million rows. Each row is simply the date and time a certain page was viewed. |
|
eg page1 1-1-00 page2 2-1-00 page1 16-1-00 page1 17-1-00 page2 19-1-00 I now need to find the most popular pages so I do this... SELECT TOP 10 COUNT(*) AS mycount FROM tblPageViews GROUP BY place ORDER BY COUNT(place) DESC ...which gives me the top 10 most viewed pages big problem - this is getting slower and slower as the table grows and grows. what should I do? is there an alternative? I think I need all the rows (rather than a simple incrementing counter) because I might want to say "what was the most popular page on a certain day or within a certain period" tia Tim |
#3
| |||
| |||
|
|
I have a table with several million rows. Each row is simply the date and time a certain page was viewed. eg page1 1-1-00 page2 2-1-00 page1 16-1-00 page1 17-1-00 page2 19-1-00 I now need to find the most popular pages so I do this... SELECT TOP 10 COUNT(*) AS mycount FROM tblPageViews GROUP BY place ORDER BY COUNT(place) DESC ...which gives me the top 10 most viewed pages big problem - this is getting slower and slower as the table grows and grows. what should I do? |
#4
| |||
| |||
|
|
hi, I have a table with several million rows. Each row is simply the date and time a certain page was viewed. eg page1 1-1-00 page2 2-1-00 page1 16-1-00 page1 17-1-00 page2 19-1-00 I now need to find the most popular pages so I do this... SELECT TOP 10 COUNT(*) AS mycount FROM tblPageViews GROUP BY place ORDER BY COUNT(place) DESC ...which gives me the top 10 most viewed pages big problem - this is getting slower and slower as the table grows and grows. what should I do? is there an alternative? I think I need all the rows (rather than a simple incrementing counter) because I might want to say "what was the most popular page on a certain day or within a certain period" tia Tim |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
greg - I don't know what a DDL is |
|
russ - thanks |
#7
| |||
| |||
|
|
C10B (tswalton (AT) gmail (DOT) com) writes: greg - I don't know what a DDL is DDL = Data Definition Language. That is, CREATE TABLE and CREATE INDEX and the like. If I had had a penny for every time someone says DDL in answer, without the person asking having no idea what it means, I would be a rich man now. russ - thanks What Russ proposed is the same idea that I proposed, but rather than relying SQL Server updating an indexed view, he suggested a separate table that you update through a trigger. |
|
-- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx |
![]() |
| Thread Tools | |
| Display Modes | |
| |