Opened 2 years ago
Last modified 2 years ago
#55909 new enhancement
Do WordPress feeds need pagination query SQL_CALC_FOUND_ROWS?
Reported by: | ovidiul | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.0 |
Component: | Feeds | Keywords: | |
Focuses: | performance | Cc: |
Description
It seems that by default, WordPress feeds endpoints generate an extra SQL_CALC_FOUND_ROWS query, because the no_found_rows
query parameter defaults to false.
On large sites with ten of thousands of posts, this can create slow queries which overall can affect the database performance.
While checking the docs and expected functionality of feeds https://wordpress.org/support/article/wordpress-feeds/ , I don't see any mention for pagination, so my question is:
Are feeds supposed to have pagination enabled and if NOT, does it make sense to set the no_found_rows => true
for the default WP_Query when feeds are triggered?
So far, I've managed to fix it with
<?php function feed_filter($query) { if( $query->is_feed && $query->is_main_query() ) { $query->set('no_found_rows', true); } } add_action( 'pre_get_posts', 'feed_filter' );
but curious if there might be other implications to this?
Hi there, welcome back to WordPress Trac! Thanks for the ticket.
I believe you're right about pagination not currently being required for the default feeds, though there is a related ticket that makes a case for adding standard pagination links there: #49321.