Menu Content

Support

> Forums, FAQs & Paid Support
Welcome, Guest
Username Password: Remember me

joomSEF slows down Joomla and cache does not solve
(1 viewing) (1) Guest
Support forum for users using free edition of JoomSEF 3 (Joomla 1.5 compatible). These forums are mainly for mutual help between users.

Please note that due to our capacity limitations, we do not monitor these forums regularly.
  • Page:
  • 1
  • 2

TOPIC: joomSEF slows down Joomla and cache does not solve

joomSEF slows down Joomla and cache does not solve 13 years, 9 months ago #12852

With joomSEf enabled Joomla takes 1 full extra second to render the page. When I activated the debug I noticed that 720 more queries were being done that when SEF is disabled. 90% of these queries are as follows:
SELECT * 
FROM `jos_sefurls`
WHERE `origurl` = 'index.php?option=com_content&catid=102&id=521&view=article'
AND (`Itemid` = '1167' OR `Itemid` IS NULL)
LIMIT 2
 

Has anyone else experienced this?

I tried to activate the cache, but the number of queries didn’t reduced, not even when I lowered the Minimum cache hits count to 1!! So probably there is a problem in the way I’ve set up the cache, but I can’t figure out what:
Cache Configuration
Use cache? Yes
Maximum cache size: 1000
Minimum cache hits count: 1 (most of the links in that same page are unique)
Record hits for cached URLs: No
Display error if cache gets corrupted: No


Anyway, I don’t believe that making a request every time joomSEF needs to check if a link already has an SEF version is efficient. Therefore I would like to propose some code changes to improve its performance.
The idea is to get all the sefurls records before hand to a static variable and then we would only need to check that variable on every request.

Re:joomSEF slows down Joomla and cache does not solve 13 years, 9 months ago #12853

  • dajo
  • OFFLINE
  • Posts: 5069
Hello,

The cache is not filled automatically, but when you click on some URL and it has at least the set hits count, it is added to the cache, so it takes some time until most of the URLs make it to the cache.
And thank you for your suggestion, we already have some performance improvements in our TODO list.

Best regards,
ARTIO Support Team
ARTIO Support Team

Re:joomSEF slows down Joomla and cache does not solve 13 years, 9 months ago #12855

I tried to find a way and I was able to reduce significantly the number of database calls which also has a nice impact in the time Joomla takes to render :)

The changes are as follows

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:
include_once(JPATH_ROOT . 'components' . DS . 'com_sef' . DS . 'sef.table.php');
$sefurls = SefUrlsTable::getSefUrl($origurl, $Itemid);


It also requires a new file, with the SefUrlTable class, that you can find attached.

I've just coded it, and tested a few pages. But any feedback would be greatly appreciated

Attachment sef.zip not found

Attachments:

Re:joomSEF slows down Joomla and cache does not solve 13 years, 9 months ago #12856

Sorry only noticed you replied to my post after I submitted the changes I did.

Thanks for your reply, I’m not really a fan of the caching anyway as it just brings another set of things that can go wrong specially on very frequently updated websites.

I think I managed to achieve a nice result with the changes I just proposed, but it would be very interesting to expand the use of this new class centralizing in it all the calls to the #__sefurls table, which could then make an even bigger impact

Re:joomSEF slows down Joomla and cache does not solve 13 years, 9 months ago #12867

there is an error in the code I sugest to change,
I missed a DS

so in sef.ext.php the original lines should be replaced with

include_once(JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef.table.php');
$sefurls = SefUrlsTable::getSefUrl($origurl, $Itemid);
Last Edit: 13 years, 9 months ago by rgoncalves.

Re:joomSEF slows down Joomla and cache does not solve 13 years, 9 months ago #12904

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

Attachments:
  • Page:
  • 1
  • 2
User Login Empty