-
Notifications
You must be signed in to change notification settings - Fork 799
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
Sitemap: Make sitemap storing more efficient by not querying the full post content before saving #39572
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
…ntent when storing the sitemap This update tries to remediate a problem where the persistent object cache gets huge with data that we will not use in the end. We just need to get the id of the current sitemap post and if it exists, we update it. Before, we were using get_post and this polluted the cache running into OOM situations
cc2349f
to
a98842e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests well for me! 🚢
); | ||
|
||
$query = new WP_Query( $args ); | ||
return $query->posts ? $query->posts[0] : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one question about this. Should we use the WP_Query
for checking if it has posts instead, like $query->has_posts()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is simple enough with the have_posts check. Looking at the source for have_posts, I don't see any benefits to use that than a simple check of the posts property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well 👍
This update tries to remediate a problem where the persistent object cache gets big with data that we will not use in the end.
We just need to get the id of the current sitemap post and if it exists, we update it.
Before, we were using
get_post()
and this polluted the cache running into OOM situationsIn p9F6qB-g4Y-p2#comment-62552 it's noted that the current behavior is not efficient.
Note: this PR may need a follow-up cause there's further investigation in p9F6qB-g4Y-p2#comment-62583
Proposed changes:
get_current_sitemap_post_id()
store_sitemap_data()
to useget_current_sitemap_post_id()
.Jetpack product discussion
p9F6qB-g4Y-p2#comment-62552
Does this pull request change what data or activity we track or use?
No
Testing instructions:
git checkout update/sitemap-store-more-efficiently