What is the best database model to store user visits and count unique users using the IP in a big database with 1.000.000 rows for example?
SELECT COUNT(DISTINCT ip) FROM visits
But with 1.000.000 diferent ip’s it can be a slow query. Caching will not return the real number.
How big stats systems counts uniques visits?
Have another MyISAM table with only IP column and UNIQUE index on it. You’ll get the proper count in no time (MyISAM caches number of rows in table)
[added after comments]
If you also need to count visits from each IP, add one more column
visitCountand use