[wp-trac] [WordPress Trac] #59492: WP_Query::generate_cache_key can create different hash for same queries leading to cache miss.

WordPress Trac noreply at wordpress.org
Fri Sep 29 09:05:06 UTC 2023


#59492: WP_Query::generate_cache_key can create different hash for same queries
leading to cache miss.
--------------------------+------------------------------
 Reporter:  thekt12       |       Owner:  thekt12
     Type:  defect (bug)  |      Status:  assigned
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Database      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  performance
--------------------------+------------------------------

Comment (by thekt12):

 Even slightest difference in args creates different cache key leading to
 cache miss

 {{{#!php
 <?php
 $query1 = new WP_Query(
                 array(
                         'cache_results' => true,
                         'fields'        => 'ids',
                         'post_type'     => 'post',
                         'post_status'     => ['publish'],
                 )
         );
 // cache key generated
 `wp_query:2e1aef1c7c1aa0228d7a7ee3a823e58a:0.99192500 1695978192`

 $query2 = new WP_Query(
                 array(
                                 'cache_results' => true,
                                 'fields'        => 'ids',
                                 'post_type'     => 'post',
                                 'post_status'     => 'publish',
                         )
         );
 // cache key generated
 `wp_query:cbed5d29eec33b81024765fa5fbdefe2:0.99192500 1695978192`



 // SQL for both
 // SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND
 wp_posts.post_type = 'post' AND ((wp_posts.post_status = 'publish')) ORDER
 BY wp_posts.post_date DESC LIMIT 0, 10


 }}}

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


More information about the wp-trac mailing list