I still had quite a lot of database calls with the query
SELECT `catid` FROM `jos_content` WHERE `id` = '{id}'
So I extended a bit the class I developed and managed to reduce it drastically, again with only one more core code change.
As I noticed that throughout the core code it is common to see a plan B if the normal behavior fails I’ve also included the normal database call to the class, that will be made in case the static variable does not have the required value.
So summing up the 2 changes that need to be done (the one I posted last week + this new one)
File: components/com_sef/sef.ext.php
Line: 81
Find lines:
$query = "SELECT * FROM `#__sefurls` WHERE `origurl` = '" . $origurl . "'" . $where . ' LIMIT 2';$db->setQuery($query);$sefurls = $db->loadObjectList('Itemid');echo '<pre>'; print_r($sefurls);
Replace With:
/* [RG] reduce databse calls
$query = "SELECT * FROM `#__sefurls` WHERE `origurl` = '" . $origurl . "'" . $where . ' LIMIT 2';
$db->setQuery($query);
$sefurls = $db->loadObjectList('Itemid');
*/
include_once(JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef.table.php');
$sefurls = SefUrlsTable::getSefUrl($origurl, $Itemid, $where);
File: /components/com_sef/sef_ext/com_content.php
Line: 226
Find:
$query = "SELECT `catid` FROM `#__content` WHERE `id` = '{$id}'";
$db->setQuery($query);
$catid = $db->loadResult();
Replace by:
/* [RG] reduce database calls
$query = "SELECT `catid` FROM `#__content` WHERE `id` = '{$id}'";
$db->setQuery($query);
$catid = $db->loadResult();
*/
include_once(JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef.table.php');
$catid = SefUrlsTable::getCatid($id);
The attached files should be placed in: /componenets/com_sef/sef.table.php
With the 2 changes I suggesting in this topic I was able to reduce the number of database calls from 636 (most of them SEF related) to just 35, and the Application afterRender time from an average of 0.8 seconds to 0.609 seconds which is a 25% improvement!
Of course these numbers will depend greatly of each of your websites, but I think that some work around this can make joomSEf an even better tool.
Attachment sef-20100628.zip not found