Add Limit to Query in Article Model

Discussion regarding Joomla! 3.x Performance issues.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
MarketingPDX
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Mar 08, 2012 8:48 pm
Location: Portland, OR
Contact:

Add Limit to Query in Article Model

Postby MarketingPDX » Tue Dec 05, 2017 5:34 pm

I have a site with about 27,000 articles in it...When I go to Content -> Articles, it takes about 10 seconds to render the whole list w/ pagination, etc. I was thinking that an easy-ish solution to speed things up (albeit artificially) would be to add a parameter to the administrator page that lists articles like so:

[my site] / administrator / index.php?option=com_content&addlimit=100

I'm just not sure where in the code to receive that param and change the query to add a limit. I tried it in the articles model by simply adding a $query->setLimit(), but that didn't take, as the getListQuery() really just builds the query that gets fired from elsewhere. Anyone know know where in the code that gets fired off? Or, possibly some other way I can accomplish what I'm trying to do (which is really to speed up the page by considering fewer articles)?

Any thoughts appreciated.
-JD

User avatar
wwhite
Joomla! Explorer
Joomla! Explorer
Posts: 433
Joined: Wed Jul 30, 2008 4:40 am
Location: SC USA

Re: Add Limit to Query in Article Model

Postby wwhite » Mon Dec 11, 2017 4:13 pm

@itoctopus have you ever tried this? https://gruz.ml/en/extensions/mvcoverride.html
Joomla - K2
Funeral Director - Every Day Above Ground is a Good Day!
Saying - This old world keeps spinning round, it a wonder tall trees aint laying down https://www.[youtube].com/watch?v=c_W9aaQ1Apo

itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4004
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: Add Limit to Query in Article Model

Postby itoctopus » Mon Dec 11, 2017 5:59 pm

All core overrides using plugins lead to a lot of stability issues. Additionally, there are many core files that you just cannot override using a plugin, because of the loading sequence of files (the whole Joomla framework must be loaded before reaching the point of loading plugins).
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter

MarketingPDX
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Mar 08, 2012 8:48 pm
Location: Portland, OR
Contact:

Re: Add Limit to Query in Article Model

Postby MarketingPDX » Mon Dec 11, 2017 6:35 pm

Hey Fadi-

Thanks for the reply. Yeah, what you're suggesting is exactly what I was trying... I tried adding a

$query->setLimit(50);

... to the getListQuery(), but that didn't seem to take, I suspect because that function just builds the query; it doesn't actually fire it off. I was wondering if anyone knew where the query gets executed, as I figured adding a limit there might be better. But, I could be going about this wrong.

A decent (but not optimal) workaround for this issue is to simply use the recent articles list module in the cpanel, as it *is* actually limited to however many articles one wants to have listed. Thus, for a giant site, it's still a quick query. But, of course, you lose all of the bells & whistles of the main articles page (listing, filtering, etc.).

Ahh the wonders of large-site Joomla installs... really wish the devs would add in some advanced capabilities for larger sites to help alleviate slow and/or overly complex queries in these situations.

itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4004
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: Add Limit to Query in Article Model

Postby itoctopus » Mon Dec 11, 2017 7:24 pm

The real bottleneck comes from the fact that 27,000 rows must be examined in order to return the data - this is where you should do your optimization.
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter


Return to “Performance - Joomla! 3.x”

Who is online

Users browsing this forum: No registered users and 4 guests