Follow us on Twitter
Notice
  • The administrator has disabled public write access.
  • Only logged-in/registered users are allowed to contribute to the forum.
Collapse
Welcome, Guest
Please Login or Register.    Lost Password?
JoomAce Support
AceSEF
Hacks, Tricks and Tips

Hack to speed up AceSEF in the administration area
(2 viewing) AlisaPrekrasnaya, (1) Guest
Go to bottomPage: 1
TOPIC: Hack to speed up AceSEF in the administration area
#6738
Hack to speed up AceSEF in the administration area 7 Months, 1 Week ago  
Recently I had complaints of AceSEF being slow when going into the SefURLs admin area. Well in this case there were over 35,000 Urls and it was indeed slow (around 1 minute 45 seconds).

I traced it down to getTotal records and poor indexes on the database table. The easy fix is to modify the getTotal() method and include another method. To do this do the following:

- Open ~/administrator/components/com_acesef/models/sefurls.php
- Find the _buildViewQuery function
- Add the following function above it

Code: - Code: - Forums Func View Catid 54

Support Forums includes Forums Section View Category 54 Id 12453



function _buildCountViewQuery() {
global $mainframe, $option;
$type = $mainframe->getUserStateFromRequest($option.'.sefurls.type', 'type', 1);

$where = $this->_buildViewWhere();

if ($type == 5) {
// Duplicated URLs
return 'SELECT DISTINCT COUNT(*) as numRecords FROM jos_acesef_urls AS t1, jos_acesef_urls AS t2 '.$where;
} else {
// All URLs
return 'SELECT COUNT(*) as numRecords FROM jos_acesef_urls '.$where;
}
}



- Modify the getTotal method in the same file to look kind of like:
Code:


if (empty($this->_total)) {
$database = JFactory::getDBO();
$database->setQuery($this->_buildCountViewQuery());
$result = $database->loadObjectList();
$this->_total = $result[0]->numRecords;
}
return $this->_total;



- Give it a go.


Why does this work? Because the built in method _getListCount from Joomla does an execute on the query and then gets the rows. Well if a Select * happens on a large number of rows it will take a long time. So I just modified this to move the work to the database server. We could have also just returned one column and it would have been much faster.

DISCLAIMER: Please do this at your own risk. Adding in this patch makes it tougher to upgrade and will probably annoying the AceSEF devs since you are meddling in their code. But given that it was over the top slow and it obviously hadn't been tested on a large number of records I figured I would bring it to everyone's attention.

-Mike
Michael de Libero
No photo available
VIP Customer
Posts: 8
graphgraph
Click here to see the profile of this user
The administrator has disabled public write access.
 
#12453
Hack to speed up AceSEF in the administration area 7 Months, 1 Week ago  
Recently I had complaints of AceSEF being slow when going into the SefURLs admin area. Well in this case there were over 35,000 Urls and it was indeed slow (around 1 minute 45 seconds).

I traced it down to getTotal records and poor indexes on the database table. The easy fix is to modify the getTotal() method and include another method. To do this do the following:

- Open ~/administrator/components/com_acesef/models/sefurls.php
- Find the _buildViewQuery function
- Add the following function above it
Code:


function _buildCountViewQuery() {
global $mainframe, $option;
$type = $mainframe->getUserStateFromRequest($option.'.sefurls.type', 'type', 1);

$where = $this->_buildViewWhere();

if ($type == 5) {
// Duplicated URLs
return 'SELECT DISTINCT COUNT(*) as numRecords FROM jos_acesef_urls AS t1, jos_acesef_urls AS t2 '.$where;
} else {
// All URLs
return 'SELECT COUNT(*) as numRecords FROM jos_acesef_urls '.$where;
}
}



- Modify the getTotal method in the same file to look kind of like:
Code:


if (empty($this->_total)) {
$database = JFactory::getDBO();
$database->setQuery($this->_buildCountViewQuery());
$result = $database->loadObjectList();
$this->_total = $result[0]->numRecords;
}
return $this->_total;



- Give it a go.


Why does this work? Because the built in method _getListCount from Joomla does an execute on the query and then gets the rows. Well if a Select * happens on a large number of rows it will take a long time. So I just modified this to move the work to the database server. We could have also just returned one column and it would have been much faster.

DISCLAIMER: Please do this at your own risk. Adding in this patch makes it tougher to upgrade and will probably annoying the AceSEF devs since you are meddling in their code. But given that it was over the top slow and it obviously hadn't been tested on a large number of records I figured I would bring it to everyone's attention.

-Mike
Michael de Libero
No photo available
VIP Customer
Posts: 8
graphgraph
Click here to see the profile of this user
The administrator has disabled public write access.
 
#12495
Hack to speed up AceSEF in the administration area 7 Months, 1 Week ago  
Thanks for this patch, to be honest I've not checked the _getListCount function of Joomla because I thought it just COUNT not SELECT without recognizing that I send a SELECT query

Anyway, I've made some final modifications and have applied it to AceSEF 1.5

Code:

function _buildCountViewQuery() {
    global $mainframe, $option;
    $type = $mainframe->getUserStateFromRequest($option.'.sefurls.type', 'type', 1);
    $where = $this->_buildViewWhere();

    if ($type == 5) {
        // Duplicated URLs
        return 'SELECT DISTINCT COUNT(*) AS numRecords FROM #__acesef_urls AS t1, #__acesef_urls AS t2 '.$where;
    } else {
        // All URLs
        return 'SELECT COUNT(*) AS numRecords FROM #__acesef_urls '.$where;
    }
}



Code:

if (empty($this->_total)) {
    $database = JFactory::getDBO();
    $database->setQuery($this->_buildCountViewQuery());
    $this->_total = $database->loadResult();
}
return $this->_total;

Denis Dulici
Forum avatar
Administrator
Administrator rank
Posts: 2683
graph
Click here to see the profile of this user
Gender: Male
If you use AceSEF, please support us by posting a rating and a review at the Joomla! Extensions Directory
The administrator has disabled public write access.
 
Go to topPage: 1
JoomAce Support
AceSEF
Hacks, Tricks and Tips
Powered by Kunenaget the latest posts directly to your desktop