[wp-trac] [WordPress Trac] #56991: Update to get_page_by_title in 6.1 changes WHERE clause

WordPress Trac noreply at wordpress.org
Tue Nov 8 17:01:37 UTC 2022


#56991: Update to get_page_by_title in 6.1 changes WHERE clause
--------------------------------------+---------------------------
 Reporter:  Bjorn2404                 |       Owner:  spacedmonkey
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  6.1.1
Component:  General                   |     Version:  6.1
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+---------------------------

Comment (by rjasdfiii):

 Re long list of ORs.  Consider using this syntax:

 {{{
 wp_posts.post_status IN ( 'publish', 'future', ... )
 }}}
 The performance will be the same since the optimizer turns the ORs into
 IN, but it is more concise.
 As you say, this may be cleaner:

 {{{
           wp_posts.post_status <> 'trash'
       AND wp_posts.post_status <> 'auto-draft'

 }}}
 Or, similarly

 {{{
       AND wp_posts.post_status NOT IN ('trash', 'auto-draft')
 }}}
 None of the variants should have any speed advantage.

 Please provide `EXPLAIN SELECT ...` for each variant that you try.  While
 I don't expect any performance difference, I would like to see the EXPLAIN
 in hopes that it says what is going on differently.

 There may be better indexes.

 Elsewhere I saw a similar query that AND'd to taxomony; this may need a
 slightly different treatment.

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


More information about the wp-trac mailing list