socialmeta
socialmeta copied to clipboard
db request increase loading time
Hi, first of all I want to say thanks for this extension and the time you're giving to the community.
I'm using the last version of socialmeta from GitHub ( from this week...). I also did some tests on WAMP with a fresh Joomla 3.5.1 installation.
My Website load normally around in 0.8 second https://gtmetrix.com/reports/www.laboitelibre.ca/VS0iIfrV
When Socialmeta plugin is activated, the Website will load in 2.2 seconds. I did some more tests with Gtmetrix just to avoid false positive.
https://gtmetrix.com/reports/www.laboitelibre.ca/83RlcgbP
On WAMP php 7.0 with Joomla! Debug Console :
My Profile Information : Time: 13.55 ms / 760.09 ms Memory: 0.600 MB / 10.79 MB Application: afterRender Time: 5.27 ms / 478.82 ms Memory: 0.097 MB / 10.06 MB Application: afterRender (without the plugin) Database queries total: 478.95 ms Database queries total: 159.06 ms (without the plugin)
6 duplicate found :
Duplicate queries: #11
SELECT *
FROM lwlc1_content
WHERE `id` = '24'
Duplicate queries: #15
SELECT `m`.`tag_id`,`t`.*
FROM `lwlc1_contentitem_tag_map` AS m
INNER JOIN `lwlc1_tags` AS t
ON `m`.`tag_id` = `t`.`id`
WHERE `m`.`type_alias` = 'com_content.article'
AND `m`.`content_item_id` = 24
AND `t`.`published` = 1
AND t.access IN (1,1,2,3,6)
Explain
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE m NULL ALL idx_tag_type NO INDEX KEY COULD BE USED NULL NULL 7 14
Duplicate queries: #25
SELECT params
FROM `lwlc1_contact_details`
WHERE `user_id` = '700'
Explain
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE lwlc1_contact_details NULL ALL NULL NO INDEX KEY COULD BE USED NULL NULL 8 12.50 Using where
Hope I gave enough information to reduce this database consuming. I can do some more tests if asked!
Cya :D
We don't care much for a specific query that is duplicated 2-3 times (unless the SPECIFIC query is reported to be 10+ or more duplicated) e.g.
SELECT params
FROM `lwlc1_contact_details`
WHERE `user_id` = '700'
- should be about 0 or 1 milliseconds
So instead of duplicates, more interesting, is which queries are shown to be slow, and you don't say this above,
- please find which queries are slow and reply here with specific milliseconds for a specific query
e.g. the plugin calls Joomla core code (helper) for tags: https://github.com/vistamedia/socialmeta/blob/master/socialmeta.php#L290 which in large sites is known to be slow
- i think if web-site does not use tags, there is some parameter to check and avoid
Hi @ggppdk
I think It's getObjectContent who is causing the majority of my trouble.
From GT Metrix score Loading my index.php take : without my Social Meta : 469ms With Social Meta : 1.72ms With Social Meta and the above lines commented : 570ms ( I've done several tests)
On line 250 I have commented : /$article = $this->getObjectContent($id);/ /$category = $this->getObjectContent($article->catid, 'category');/
https://github.com/vistamedia/socialmeta/blob/master/socialmeta.php#L250
// Handle values of the content table
if ( ( $option == 'com_content' && $view == 'article') || ( $option == 'com_flexicontent' && $view == 'item') ) {
/*$article = $this->getObjectContent($id);*/
$article->tags = new JHelperTags;
/*$category = $this->getObjectContent($article->catid, 'category');*/
$images = json_decode($article->images);
$facebookmeta_image = '';
And I also commented the line 664 to 673 : https://github.com/vistamedia/socialmeta/blob/master/socialmeta.php#L664
* Method to retrieve the main data object of a component.
*
* @param int $id
* @param string $table
* @return object.
*
* @since 1.0
*/
private function getObjectContent($id, $table = 'content')
{
$db = JFactory::getDbo ();
$dataobject = JTable::getInstance($table);
$dataobject->load($id);
return $dataobject;
}
So, does it make sens?