Open mattab opened 12 years ago
I started to look into this bug and found the following:
http://bugs.mysql.com/bug.php?id=21849
It looks like it might have been fixed in MySQL 5.5.0 and/or we can replace the code with something like:
"select count(*) from (select distinct somefield from sometable group by somefield) as somelabel;"
which has much better performance on mysql pre-5.5.0.
Suggested in forum post
Currently we count the number of distinct idvisitor, to get unique per week/month/etc.
Instead, we could count each time a visitor is new (he didn't have the idcookie or wasn't match to recent visit), set a flag. Then count the number of times the flag was set. This will be slightly more inaccurate but much faster than running a new SELECT count(disctinct) on very large datasets.