Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance: Faster algorithm to count unique visitors #3120

Open
mattab opened this issue Apr 23, 2012 · 1 comment
Open

Performance: Faster algorithm to count unique visitors #3120

mattab opened this issue Apr 23, 2012 · 1 comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.

Comments

@mattab
Copy link
Member

mattab commented Apr 23, 2012

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.

@anonymous-matomo-user
Copy link

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.

@mattab mattab added this to the Future releases milestone Jul 8, 2014
@mattab mattab removed the P: normal label Aug 3, 2014
@mattab mattab modified the milestones: Long term, Mid term Dec 23, 2015
@mattab mattab modified the milestones: Long term, Mid term Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.
Projects
None yet
Development

No branches or pull requests

2 participants