wp-rocket
wp-rocket copied to clipboard
Review uses of WP_Query and consider using no_found_rows , update_post_term_cache and update_post_meta_cache to speed up processing and reduce SQL workload
Context A user suggested the following through the Support:
Your query on line 245 of /inc/functions/posts.php can be made 5-10x faster with no_found_rows => true being added. Since you are no totals needed or pagination occurring you will skip the expensive SQL_CALC_FOUND_ROWS that query translates to.
Referring to this
The use of WP Query implies a few steps on top of the query requested. More details here.
To do Review our usage (at least the main ones) of WP Query and consider the use of the following option: no_found_rows, update_post_term_cache and update_post_meta_cache
Reported here. @Tabrisrp to have a second look 🙏
Adding those make sense in this case, We are doing a query to get the ID of a single post, and don't need anything else.
This is the only case where we do a direct WP_Query in the code.