[wp-trac] [WordPress Trac] #41054: Use sargable date filtering where possible

WordPress Trac noreply at wordpress.org
Thu Dec 5 21:12:18 UTC 2024


#41054: Use sargable date filtering where possible
--------------------------+------------------------------
 Reporter:  ComputerGuru  |       Owner:  (none)
     Type:  enhancement   |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Database      |     Version:
 Severity:  trivial       |  Resolution:
 Keywords:  needs-patch   |     Focuses:  performance
--------------------------+------------------------------
Changes (by OllieJones):

 * severity:  normal => trivial


Comment:

 I did some analysis of how widespread queries are that could exploit this
 change. My very imperfect sample comes from uploaded query-monitoring
 sessions from Index WP MySQL For Speed. These are uploaded by users when
 asking for additional help with query performance trouble.

 It is true that making date-ranges sargeable is a good idea. What's more,
 the queries in my sample would, if this change were made, exploit an
 existing index on `(post_type, post_status, post_date)`.

 But my sample of queries shows little use of this particular suboptimal
 kind of WHERE filter.

 And, the documentation for WP_Date_Query suggests that clients use the
 YEAR() / MONTH() / DAY() sorts of filters.  So, fixing this would require
 a bunch of interesting but ultimately brittle logic to generate date
 ranges from the query terms presented.

 What's more, WP_Query results go into the object cache.

 So, I respectfully suggest the dev and test labor, and the potential
 destabilization, of this tix isn't worth the potential performance
 improvements.

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


More information about the wp-trac mailing list