Massive SELECTs for a hit counter
I have a hit counter in PHP/MySQL that generates an image on the fly. Unlike novel methods of incrementing a scalar value, the script determines the total number of hits for the user by determining COUNT(*) in the table of (hits) that belong to a particular (user).
table hits
(
hit_id (primary key)
user_id (indexed)
referrer
timestamp (indexed)
etc.
)
I want to be able to keep records of all visits (to keep the referral, timestamp, etc. data). However, to allow multiple users to use such a service would cause row counts in the millions. Using the query SELECT COUNT(*) FROM hits WHERE user_id = 1, it can take up to half a minute to run. But the counter needs to be updated quickly, as it is done on the fly for the visitor to a web page.
Is there any way around this, or is this an inevitable feature of having such a large number of rows?
Subject
Views
Written By
Posted
Massive SELECTs for a hit counter
3911
December 13, 2004 04:18PM
2532
December 13, 2004 10:42PM
2615
December 14, 2004 11:45AM
2470
December 14, 2004 12:48PM
2433
December 14, 2004 08:06PM
2512
December 14, 2004 12:55PM
2339
December 14, 2004 11:35PM
4001
December 16, 2004 01:45AM
2633
December 15, 2004 01:19PM
2557
December 15, 2004 01:39PM
2434
December 15, 2004 01:53PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.