| Project: | Ubercart Contributions |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Hi!
I was somewhat shocked to see the number of queries that was used to generate the catalog block (and the catalog pages too I suppose). Specifically there were a large number of duplicate queries from taxonomy_get_parents() (due to the fact that that function is not cached). I tracked that down to uc_catalog_term_path() which calls taxonomy_get_parents_all() which in turn calls taxonomy_get_parents() several times.
I thought that the expensive use of uc_catalog_term_path() may not be needed when building the catalog tree (_uc_catalog_navigation), since the parents of each catalog node are already known. Hence it's possible to build the full catalog path without using uc_catalog_term_path(). This required an extra argument to _uc_catalog_navigation(): $current_path.
I tried this on a specific page and went from about 250 to 120 queries! I don't know if all use cases will gain as much as that, but it sure looks good.
Attaching the patch!
| Preview | Attachment | Size |
|---|---|---|
| uc_catalog-path_optimization.patch_.txt | 2.35 KB |

