You are here: Re: faster count(*) or alternative « MsSQL Server « IT news, forums, messages
Re: faster count(*) or alternative

Posted by Greg D. Moore \(Strider\) on 02/26/07 16:26

"C10B" <tswalton@gmail.com> wrote in message
news:1172502298.291068.60420@s48g2000cws.googlegroups.com...
>
>> If you want more help, I suggest you give us a complete DDL of your
>> database, some real example data and perhaps we can do better.
>
>
> The requirement is simply this...
>
> I have a lot of pages and I want to record when each is visited.
> I then need to be able to answer questions like this...
>

Yes, we understand the requirements. That doesn't eliminate the value of a
DDL and sample data.




> "Which was the most popular page in January 07?"
> "Which are the top 10 most viewed pages between 2 and 3 in the
> afternoon"
>
> with unlimited segmenting of the data really.
>
> So I thought I would record an entry in a table everytime a page is
> viewed, along with the date and time.
> Using some simple queries using "count(*)", a where clause and a group
> by clause I was answering all the questions.
> Trouble is the speed. Several million records (and growing rapidly)
> and count(*) gets slow.
>

Define slow?

(my former employer did queries similar to this in subsecond times.)


> Just while I was writing this I had an idea - I could move a finished
> month's data to another table, so each month has a table of data. It
> might still be a million records though, but at least it wont get
> worse and worse over time. This would make some results harder to get
> like "most viewed page of all time" but my monthy, hourly, weekly
> figures would be quicker.
>
> Any other tips?

Yes, post a full DDL.


>
> Thanks
>


--
Greg Moore
SQL Server DBA Consulting
sql (at) greenms.com http://www.greenms.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация