[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 Oct 17 20:20:06 UTC 2014
#24093: WP_Meta_Query is inefficient when referencing the same keys in "OR" query
----------------------------------+---------------------------
Reporter: sc0ttkclark | Owner: boonebgorges
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 4.1
Component: Query | Version: 3.5.1
Severity: normal | Resolution:
Keywords: meta-query has-patch | Focuses: performance
----------------------------------+---------------------------
Comment (by boonebgorges):
In [changeset:"29940"]:
{{{
#!CommitTicketReference repository="" revision="29940"
Overhaul SQL generating logic in WP_Meta_Query to avoid unnecessary table
joins.
The logic used to generate clause SQL in `WP_Meta_Query` is somewhat
arcane,
stemming mostly from an ongoing effort to eliminate costly table joins
when
they are not necessary. By systematizing the process of looking for
shareable
joins - as was done in `WP_Tax_Query` [29902] - it becomes possible to
simplify
the construction of SQL queries in `get_sql_for_clause()`. Moreover, the
simplified logic is actually considerably better at identifying shareable
joins, such that certain uses of `WP_Meta_Query` will see joins reduced by
50%
or more.
Includes integration tests for a representative cross-section of the query
clause combinations that result in shared table aliases.
Props boonebgorges, sc0ttkclark.
See #24093.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/24093#comment:37>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list