Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the loading speed of category items #19261

Merged
merged 3 commits into from
Jan 15, 2018

Conversation

csthomas
Copy link
Contributor

@csthomas csthomas commented Jan 2, 2018

Summary of Changes

Faster loading of category items in component content view categories.
Instead of using a query with GROUP BY this PR uses DEPENDENT SUBQUERY.

Testing Instructions

Joomla works as before.

On large content sites, categories view in component content loads faster.

Test on index.php/component/content/categories.
Enable debug mode.
Look for the query that contains c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time and numitems.

Expected result

Categories load faster on view categories.

@Folamour
Copy link

Folamour commented Jan 3, 2018

Does this can help us on joomla 3.8.X timeload ? it seem to be for category view but that impact com_content, so i'm ready to test everything you can ask

@csthomas
Copy link
Contributor Author

csthomas commented Jan 3, 2018

I have read your issue and this PR is probably not directly related to your problem.
It will speed up com_content categories view.

This PR required 2 successful test to be ready to commit.

I have plan to fix your issue too, please test this one. It will help me to move forward faster.

@Folamour
Copy link

Folamour commented Jan 3, 2018

Hi csthomas, i will try to manage to test this fix too, i'm currently experiencing trouble with PhpmyAdmin on last Xampp release, so i will need a bit of time to workaround that issue, when this will be done, i'll test the patch, thank a lot to help us, we are ready to help at our best just ask us if anything is needed.

@alikon
Copy link
Contributor

alikon commented Jan 4, 2018

from a quick test on postgresql with 100 cats the query plan seems better but the performance gain are neglibile,
@csthomas with how many categories do you have measured a sensible gain ?

@csthomas
Copy link
Contributor Author

csthomas commented Jan 4, 2018

I created 400 categories and 4000 articles by modified version of sampledata blog plugin, ex https://gist.github.com/csthomas/df973e13245e6a23ed5f8cb9ecd67ce1

@csthomas
Copy link
Contributor Author

csthomas commented Jan 4, 2018

In general, if there are more articles, the difference in speed should be more visible.

Total articles should be more than 4000.

@alikon
Copy link
Contributor

alikon commented Jan 4, 2018

well i've tested with 16000 articles with 100 category, but maybe is better to test on mysql should be most impacted cause different implementation on subquery

@csthomas
Copy link
Contributor Author

csthomas commented Jan 4, 2018

@alikon Did you go to /component/content/categories and look for query with COUNT().
There should be difference. I will show my screen shots.

@alikon
Copy link
Contributor

alikon commented Jan 4, 2018

i've tested this url http://localhost/test/index.php/component/content/categories only
i'll test on mysql when com_overload finish the job....

@alikon
Copy link
Contributor

alikon commented Jan 4, 2018

as suspected on mysql:

before patch

screenshot from 2018-01-04 21-02-23

after patch

screenshot from 2018-01-04 21-03-16

@alikon
Copy link
Contributor

alikon commented Jan 4, 2018

I have tested this item ✅ successfully on 63b1a4a


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19261.

@alikon
Copy link
Contributor

alikon commented Jan 4, 2018

i've tested on MySQLi 5.7.20 not sure if in lower version the gain will be the same

@csthomas
Copy link
Contributor Author

csthomas commented Jan 4, 2018

My screen shots are similar, so I do not send them.

In general Mysql has a little problem with GROUP BY when there is a lots of columns (in SELECT).

@csthomas
Copy link
Contributor Author

csthomas commented Jan 4, 2018

The similar improvement I added at #19284. Instead of DISTINCT I use join to subquery.

}
}

// Note: i for item
if ($this->_options['countItems'] == 1)
{
$queryjoin = $db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id';
$subQuery = $db->getQuery(true)
->select('COUNT(i.' . $db->quoteName($this->_key) . ') AS numitems')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove AS numitems since its value is aliased later on.

SELECT COUNT(i.`id`) AS numitems

  FROM `ypqhy_content` AS `i`

  WHERE i.`catid` = c.id 
  AND i.state = 1) AS numitems``

@Quy
Copy link
Contributor

Quy commented Jan 5, 2018

I have tested this item ✅ successfully on 9ab2931


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19261.

@ggppdk
Copy link
Contributor

ggppdk commented Jan 5, 2018

MariaDB to 10.1.29 on SSD

11,000 articles in a single category
80 categories created ...

Before this PR
1st run 6.1 seconds
2nd run 3.7 seconds

After this PR is applied
1st run 2.8 seconds
2nd run 0.6 seconds

@csthomas
Copy link
Contributor Author

csthomas commented Jan 5, 2018

Thank you folks for testing.

@ghost
Copy link

ghost commented Jan 5, 2018

@ggppdk can you please mark your Test as succcessfully?

@Folamour
Copy link

Folamour commented Jan 5, 2018

I have granted an FTP access to ggpdk to download the akeeba archive as he seem to have issue with backup using http, i would like also to thanks you all for your time and effort to get the best CMS

f.

@csthomas
Copy link
Contributor Author

@ggppdk or @alikon Can you guys mark it as success?

The last commit, after @alikon tested, only removed alias from column. Code review will be enough.

@alikon
Copy link
Contributor

alikon commented Jan 10, 2018

I have tested this item ✅ successfully on 9ab2931


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19261.

@Quy
Copy link
Contributor

Quy commented Jan 10, 2018

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19261.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 10, 2018
@mbabker mbabker added this to the Joomla 3.8.4 milestone Jan 15, 2018
@mbabker mbabker merged commit 515790e into joomla:staging Jan 15, 2018
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jan 15, 2018
@csthomas csthomas deleted the speedup_categories branch January 15, 2018 15:05
@Folamour
Copy link

Folamour commented Jan 30, 2018

Yiannis seem busy so I update the thread he have applied PR 19261 and PR 19284 pagetime load went from 4.5sec in joomla 3.7.5 to 3.5 sec in Joomla 3.8.3 (9 sec without PR), and start display page is 2.4 sec, for user Pagespeed load is 1.7 sec !!!!!!!!!! so its a wonderdull success !!!!!, I wand to sincerelly thanks Csthomas for is fantastic work ! and of course Georgios (ggppdk) who offer me is help, and all the Joomla devs, if I can exprim myself on the internet its because I discovered Joomla 8 year ago, I want to thank you all. You have to know that there is a lot of people using your code, and you make our life better, joomla 3.8.4 update will be awesome for user, just take a look : https://www.crashdebug,fr navigate througth the site and found a page not in cache (using left menu, and navigation bar at the bottom) they are displayed quasi instantly, you made it guys !!!!! Joomla is now as fast as wordpress with 14k article !!!!

Thanks,

Guillaume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants