Keyword

k2_tools - Large amoutn of queries

  • BlossomDigital
  • BlossomDigital's Avatar Topic Author
  • Offline
  • New Member
More
13 years 9 months ago #91072 by BlossomDigital
k2_tools - Large amoutn of queries was created by BlossomDigital
Hi,

 

I'd noticed on one of our site there was a large amount of queries being generated by the K2_tools module.

 

Basically we'd used the module in a menu item to dynamically list all the sub categories for a given parent category. For 5 menu items this was generating approximately 193 queries...

 

We are using 'Categories List (Menu)' and want to display the direct child items for a given root category ( only one level deep ).

 

On closer inspection of the 'treerecurse' function in the helper.php the statement

 

if (modK2ToolsHelper::hasChildren($row->id)) {

 

didn't seem quite right. ( Basically I'd set a level limit to '1' in the module, however from what I can see the 'hasChildren' function will run an additional query for every menu item (category) displayed.

 

Amending the above line to this

 

if ((is_null($end_level) || $level+1 < intval($end_level)) && (modK2ToolsHelper::hasChildren($row->id))) {

 

Seems to server our own purposes, hopefully this can be of use to someone else, or re-worked a bit to be inclulded in to the main codebase?

 

Thanks, Chris.

 

 

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum