[wp-trac] [WordPress Trac] #57296: Force split queries in WP_Query in object caching is enabled.

WordPress Trac noreply at wordpress.org
Tue Sep 5 12:21:42 UTC 2023


#57296: Force split queries in WP_Query in object caching is enabled.
-------------------------------------------------+-------------------------
 Reporter:  spacedmonkey                         |       Owner:
                                                 |  spacedmonkey
     Type:  enhancement                          |      Status:  closed
 Priority:  normal                               |   Milestone:  6.4
Component:  Query                                |     Version:  3.0
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  testing                                        |  performance
-------------------------------------------------+-------------------------
Changes (by spacedmonkey):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"56513" 56513]:
 {{{
 #!CommitTicketReference repository="" revision="56513"
 Query: Use split queries in WP_Query if persistent object caching is
 enabled.

 Prior to this commit, the `WP_Query` class split the query for posts into
 two database queries. First, it initiated an ID-based query to retrieve
 post IDs, followed by a call to _prime_post_caches to fetch post objects
 if they weren't already in memory. This splitting of queries was limited
 to cases where fewer than 500 posts were being requested, to prevent a
 potentially large database query within the IN statement in
 _prime_post_caches.

 However, this limitation becomes unnecessary when a persistent object
 cache is enabled, as the post objects can be efficiently retrieved from
 the fast object cache. This commit transfers the responsibility of
 fetching posts to the object cache, which not only speeds up the process
 but also reduces the strain on the database server.

 Props peterwilsoncc, spacedmonkey, SergeyBiryukov.
 Fixes #57296.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57296#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list