mysql - Sql database query optimization for web page visitors statistics -


I'm trying to create a web log analyzer based on the Tomcat log.

And I first enter the push database, then do some statistics.

Now I get a problem:

For the given data range (2010-09-20 to 2010-09-25), for example, To calculate, so I divided the data range in the first day:

 Split: (2010-09-20,2010-09-25) to (2010-09 -20 00:00:00, 2010-09-21 00:00:00), (2010-09-21 00:00:00, 2010-09-22 00:00:00), (2010-09-22 00:00:00, 2010- 09-23 00:00:00), (2010-09-23 00:00:00, 2010-09-24 00:00:00), (2010-09-24 00: 00:00, 2010-09- 25 00:00:00), 

Then I use SQL to query the audience points of each category .

For example: Select

 Count (specific IP) from the log, where is the time between 201009200000 and 201009210000 group by IP 

this SQL Is used to calculate the visitors of 2010-09-20.

So if the user has more than a day in the data range from the request, then I should connect more to the database than at a time, is this less efficient?

Any solution?

BWT, I use MySQL.

You start by creating a table (days) with all the days in a year.

Select an example day (different IP), day. Log in within log in at the start time log in from the login. Time between times Starttime and daytime.time where ip, day.starttime

or something like

between log, 200 9 200 20000 and 201009210000 group

Comments