Search
Other Advanced Module Manager questions
Forum

Reducing number of duplicated queries

Andrea Malalana's Avatar Andrea Malalana
Hello,

Looking at debug and duplicated queries, I noticed that every instance of a module in a page, requests Joomla\CMS\Table\Table->load(), which in turn, generates all the queries associated with that call.

An example query that happens as a result of that, for example, is:

SELECT `t`.`id`
FROM `__tags` AS `t`
INNER JOIN `__contentitem_tag_map` AS `m` ON `m`.`tag_id` = `t`.`id`
WHERE `m`.`type_alias` = :prefix AND `m`.`content_item_id` IN (:preparedArray1)

But any other query that Joomla executes from Joomla\CMS\Table\Table->load() it's executed a duplicate amount of times per as many modules that are on the page. Actually this does not just apply to modules from AMM, but also per as many ReReplacer items as well.

Is there any way that you only call Joomla\CMS\Table\Table->load() once from the 1st instance of a module/ReReplacer found on the page, and the other modules/ReReplacer items don't do it, so that queries don't get duplicated?

Let me know, thanks!
Peter van Westen's Avatar Peter van Westen ADMIN
Cannot reproduce it here.
Looks like these are queries from Joomla core, coming from:
Joomla\CMS\Helper\TagsHelper::getTagIds()


Maybe you can put something like this:
        $callers = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10);
        echo "\n\n<pre>=====[ ". __FILE__ . " : " . __LINE__ . " ]====\n-----[ ". __METHOD__ . " ]-----\n";
        print_r($callers);
        echo "\n==========================</pre>\n\n";
In file libraries/src/Helper/TagsHelper.php (line 490) to try and figure out where these calls are originating from.
Please post a rating at the Joomla! Extensions Directory
Andrea Malalana's Avatar Andrea Malalana
I already tested this and see the stack trace, here is an example:

Confidential information:
(hidden)


I see a duplicate of this one for every module on the page. Removing a module removes one duplicate. And so on. Same for ReReplacer items
Peter van Westen's Avatar Peter van Westen ADMIN
Please try the latest development version from:
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Andrea Malalana's Avatar Andrea Malalana
Nice, I confirm it now cleaned up a lot of duplicate queries!

By comparison to before the update, it now removed 7 different sets of duplicate queries (so there were 6 more sets of queries in addition to the one I sampled above)

On a sample (heavy) page, it brought the query count from 558 to 426.
Peter van Westen's Avatar Peter van Westen ADMIN
New dev should optimize a bit more (regarding article based conditions).
Please post a rating at the Joomla! Extensions Directory
Andrea Malalana's Avatar Andrea Malalana
Great!
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription