[wp-trac] [WordPress Trac] #24093: WP_Meta_Query is inefficient when referencing the same keys in "OR" query

WordPress Trac noreply at wordpress.org
Fri Sep 26 15:09:50 UTC 2014


#24093: WP_Meta_Query is inefficient when referencing the same keys in "OR" query
-------------------------------------------------+-------------------------
 Reporter:  sc0ttkclark                          |       Owner:
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Query                                |  Release
 Severity:  normal                               |     Version:  3.5.1
 Keywords:  needs-refresh meta-query needs-      |  Resolution:
  unit-tests has-patch dev-feedback              |     Focuses:
                                                 |  performance
-------------------------------------------------+-------------------------

Comment (by vprat):

 @sarukuku - "The patch doesn't seem to break anything but cases WP to show
 errors on the admin side"

 Can you please specify some steps to reproduce this? I would be happy to
 fix it.

 @boonebgorges -

 1. It is always somehow risky for a plugin author to play with SQL
 directly instead of using the WP core functions. So I feel these cases
 should be adressed by plugin authors (and this is why I submitted a patch
 to improve WP Core instead of patching my plugin with such a filter).

 2. Your workaround fixes a very tiny part of the problem. Does not work
 for anything else than = operator for instance (LIKE...)

 3. This is very easy to reproduce. You simply need to issue a WP_Query
 with at least 5 clauses in the meta query. Even if you only have a few
 posts (10/20) in the database it will blow (will not even complete). With
 the patch, the query takes a few milliseconds in all cases.

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


More information about the wp-trac mailing list