@anonymous-piwik-user opened this Issue on January 12th 2009

When trying to log in as superuser and having thousands of websites listed. the system is tremendously slow. the reason seems to be line 82 in /core/View.php

the function usort is being used and the sort is very slow causing the many timeouts.

Maybe sort in db? or in other efficient way?

@robocoder commented on January 12th 2009 Contributor

Scaleability is on the TODO list (e.g., tickets #386 and #409).

Assuming your profiling has pinpointed it to this line, try replacing it with:

usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1[$site2"name");'));

@robocoder commented on January 12th 2009 Contributor

Let's try that again in a code block:

usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);'));
@robocoder commented on January 12th 2009 Contributor

I don't think that line of code is the bottleneck.

I just ran a simulation using 23,000+ domain names. Before my optimization: 2.83 seconds; After: 1.89 seconds.

@robocoder commented on January 13th 2009 Contributor

What server side errors are you seeing?

@anonymous-piwik-user commented on January 14th 2009

I get this message: Allowed memory size of X bytes exhausted (tried to allocate Y bytes )...

the only thing that helped me "solve" the problem is to give up the sorting.
We have over 80K sites listed and growing. and it is impossible to sort them this way.

After all the sorting is for the admin interface and in our case is less important.
I also disabled the option of showing the drop down by turning $showSitesSelection to false

So even when i use the admin to see data, i will not load all these sites into the dropdown.
This is pretty much solved my problems. thx

@robocoder commented on January 14th 2009 Contributor

Yes, 80K domains would be a problem. The memory exhausted error depends on your memory_limit in php.ini. My test with 23,000 domains maxed out my 32MB limit, which is around the norm. Using strcasecmp() instead of strtolower() would eliminate a lot of string conversions and small string allocations, but transferring 80K domains for the site selection list would still take a hit.

FYI showSitesSelection is set to true in several places:


I'd like to propose adding a config option (e.g., threshhold) to accommodate larger installations like yours.

@mattab commented on January 14th 2009 Owner

Fixed in [880]

fix #495 Adding option in configuration file: show_website_selector_in_user_interface

; if set to true, the website selector will be displayed in the Piwik UI
; if your Piwik installation has thousands of websites, you may disable the website selector
; as it slows down the loading of the Piwik UI by setting this value to false

following vipsoft suggestion

This Issue was closed on January 14th 2009
Powered by GitHub Issue Mirror