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

class Largo_Related is a query monster and needs to use fewer resources #671

Closed
benlk opened this issue Apr 24, 2015 · 4 comments
Closed
Assignees

Comments

@benlk
Copy link
Collaborator

benlk commented Apr 24, 2015

The "Related Posts" widget query queries for posts in a list of post IDs. That list of post IDs is created by Largo_Related.

Largo_Related:

If the series query returns fewer than the requested number of posts, it proceeds to query infinite posts for each category the post is in.

If there are still insufficient posts, it runs a query for recent posts by date, but fortunately not infinite posts. It only queries one more post than the number of posts needed.

In order to add posts to the list of post ids that have been returned, the recent posts method creates and advances over a Loop of the returned posts. This could probably be an array function instead of a Loop.

I mean, it's great at getting related posts, and it's actually pretty good about returning ones that are actually related. But it's also like a bulldozer: good for moving things around, but not good for moving furniture in your house to vacuum. Do we really need to query for infinite posts?


Posted because I'm getting PHP out of memory errors with a related_posts widget on Vagrant with NPQ.

@aschweigert
Copy link

Yeah...i've been thinking about this recently too and talked with @rnagle a bit about it. I want to revisit how it's working and make sure the logic is correct. Then we definitely need to figure out how to cache things or do something the minimizes the impact of this thing because right now it's pretty ugly.

@benlk
Copy link
Collaborator Author

benlk commented Apr 24, 2015

At the very least, we should be querying for the number of posts that are requested instead of infinite posts.

@benlk
Copy link
Collaborator Author

benlk commented Apr 27, 2015

Does Largo use transients anywhere for caching? It sounds like it would be a good idea in many places (like the homepage functions), but especially here. http://www.wpbeginner.com/wp-tutorials/speed-up-your-wordpress-by-caching-custom-queries-using-transients-api/

@aschweigert
Copy link

Not that I can recall, although it's probably something we could/should do in some places

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

No branches or pull requests

3 participants