[wp-trac] [WordPress Trac] #55909: Do WordPress feeds need pagination query SQL_CALC_FOUND_ROWS?

WordPress Trac noreply at wordpress.org
Fri Jun 3 07:40:59 UTC 2022


#55909: Do WordPress feeds need pagination query SQL_CALC_FOUND_ROWS?
-------------------------+-----------------------------
 Reporter:  ovidiul      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Feeds        |    Version:  6.0
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 It seems that by default, WordPress feeds endpoints generate an extra
 SQL_CALC_FOUND_ROWS query, because the `no_found_rows` query parameter
 [https://github.com/WordPress/wordpress-
 develop/blob/2c06c9afd5ba32a0f55a9f8313e636fbcb698cab/src/wp-includes
 /class-wp-query.php#L1943 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
 <?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?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55909>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list