We found that file gallery and file browser browsing works exceedingly slow with a database with more than 6500 nodes (we are using Drupal 6.13 with MySql running on Ubuntu 9.10 server)
To navigate between folders can take up to several seconds (the same apply when we try to expand a file browser tree). A folder consisting of more than 100 nodes/files can already behave quite slowly.
We found a temporary solution to fix it:
first thing we commented the next line in "file_gallery.module"
$term = _file_browser_term_nodes($term, $term, NULL);
//$count_files = array_sum(array_map(create_function('$node', 'return is_object($node) && is_object($node->file) ? 1 : 0;'), $term->nodes));
$query = isset($module) ? module_invoke($module, 'file_gallery', 'query') : NULL;
We think is save our process time.
The second thing , we are not going deep into folders which we don't need. The trick is in finding just folder and files but not searching the subdirectory files an directories. For this reason we changed next in file "file_gallery.modul"
function _file_gallery_term($term, $options = array(), $filter = NULL, $module = NULL) {
//$folders = 0;
$childterms = taxonomy_get_tree($term->vid, isset($term->tid) ? $term->tid : 0, -1, NULL);
foreach ($childterms as $childterm) {
if (is_object($childterm)) {
$folders++;
if ($folders > 1) // we add this 2 lines
break; //
$term = _file_browser_term_nodes($term, $childterm, NULL);
}
}
These changes decreased our page download time from 24 second to 3secs.
Is this an acceptable solution or are you going to release a different patch?
Comments
Comment #1
korgx commentedComment #2
korgx commentedPlease notice, the above is not really a patch but a workaround we introduced to have an acceptable performance. It will disable the counter so it does not solve the issue but at the moment it allow us to have a navigation in an acceptable time for the user.
Comment #3
miglius commentedI'd be surprised that first change considerably speeds up the page load. Counting is just an iteration trough an array with additional check.
However, second change should increase the speed as you stop iterating down the next level of the folder tree.
The behavior depends on the requirements. While writing this code I had a requirement to list the number of all files which are below the given taxonomy term (folder), not just the ones directly attached to the taxonomy term.
At some point I was thinking about implementing the caching of the taxonomy tree, but then even a small change - tagging a file with other term would require rebuilding of this cache, which would mean slow page loads on the file edit pages, which was not acceptable for us.
Comment #4
johanneshahn commentedclosed
moved to #1494738: Rewrite File- Gallery & Browser