Looking through the module code I noticed several places where db_result() is called multiple times to fetch values from the same table. These should likely be merged into one call to the database in order to reduce overhead.
There was also an instance where a query within a loop could be removed by performing a join in the initial query, and I was able to improve the function to get all children of a term from calling a query for each term to calling a query for each depth of the vocabulary tree.
Here is a first attempt at merging and reducing the number of database calls. I'll post a follow up patch or comment after I have time to more thoroughly test that no functionality is affected by this patch.
You can follow my git history at https://github.com/gapple/taxonomyblocks/commits/feature%2Fquery-optimiz...
| Comment | File | Size | Author |
|---|---|---|---|
| taxonomyblocks-optimize-queries.patch | 13.38 KB | gapple |
Comments
Comment #1
dizarter commentedHunk #1 failed @ 184
Hunk #3 failed @ 256
Hunk #5 failed @ 547
Hunk #8 failed @ 599
Hunk #9 failed @ 644
Hunk #12 failed @ 749
===============
6 out of 12 hunks FAILED
Comment #2
dizarter commentedAfter manually applying this patch all my Advanced Taxonomy blocks disappeared, so I have to say that this patch failed testing.
Comment #3
gappleI was able to apply the patch without issue using "git.exe am --3way --ignore-space-change"
There is an intermediary commit (available in my github repository) fixing end of line whitespace: #1103536: Coding Standards - Whitespace.
I left it out of this patch to avoid bloating it with unnecessary changes. You may find it easier to just pull in my Github branch instead of applying the patch.
----
I will test the patch further myself to make sure I didn't break any functionality.
Comment #4
gapple