Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / February 2008

Tip: Looking for answers? Try searching our database.

Slow Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
google@gwpsoftware.com - 29 Feb 2008 15:58 GMT
I have a log file with about 180K records.
I'm looking to create a ranking of most frequently visited pages.
This is the query I'm currently using:

Select top 10  * from
( SELECT HitPage, URL, count(HitPage) as f1, PageTitle   from
tblSession
where LogDate >=39142
GROUP BY HitPage, url, PageTitle  ) order by f1  desc

I have tried indexes on:
LogDate, HitPage, URL, PageTItle
HitPage, URL, PageTitle, LogDate

When the LogDate is less than a month ago, its very quick, but when
looking at a year's worth of data is very slow

Any advice would be appreciated!
John Spencer - 29 Feb 2008 16:23 GMT
I'm not sure if you mean you set individual indexes on each field or you set
up a compound index.

In this set up, I would try having an index on each individual field
instead of a compound index.

Select top 10  *
FROM
  ( SELECT HitPage, URL, count(HitPage) as f1, PageTitle
    from tblSession
    WHERE LogDate >=39142
    GROUP BY HitPage, url, PageTitle  )
order by f1  desc

LogDate, HitPage, URL, PageTItle

Signature

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

>I have a log file with about 180K records.
> I'm looking to create a ranking of most frequently visited pages.
[quoted text clipped - 14 lines]
>
> Any advice would be appreciated!
google@gwpsoftware.com - 29 Feb 2008 16:52 GMT
Thanks for the idea.  I tried it but it didn't improve the query
processing time.

Any other thoughts?
Jerry Whittle - 29 Feb 2008 17:56 GMT
Hi,

I ran the same query on a table with 750K records and no indexes. It took
about 10 seconds to return records the second time I ran it.

I put an index on LogDate and it ran in about 7 seconds. I then added a
second index on the other three fields. It was slower therfore I removed the
second index.

I did simplify things somewhat but it didn't seem to help any:

SELECT TOP 10 HitPage,
 URL,
 PageTitle,
 Count(HitPage) as f1
FROM tblSession
WHERE LogDate >=39142
GROUP BY HitPage, url, PageTitle  
ORDER BY 4  desc  ;

I only had three different LogDate's so YMMV.

Signature

Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

> I have a log file with about 180K records.
> I'm looking to create a ranking of most frequently visited pages.
[quoted text clipped - 14 lines]
>
> Any advice would be appreciated!
Michel Walsh - 29 Feb 2008 18:07 GMT
Can you try:

SELECT TOP 10 HitPage, URL, COUNT(HitPage) as f1, PageTitle
FROM tblSession
WHERE LogDate >=39142
GROUP BY HitPage, url, PageTitle
ORDER BY COUNT(HitPage)  DESC

ie, without using a virtual table.

Vanderghast, Access MVP

>I have a log file with about 180K records.
> I'm looking to create a ranking of most frequently visited pages.
[quoted text clipped - 14 lines]
>
> Any advice would be appreciated!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.