[wp-trac] [WordPress Trac] #36670: Move CAST to right-hand side of comparison in meta query
WordPress Trac
noreply at wordpress.org
Tue Apr 26 04:40:43 UTC 2016
#36670: Move CAST to right-hand side of comparison in meta query
-------------------------+-----------------------------
Reporter: ericlewis | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 3.1
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
The SQL clause created by a meta query
[https://github.com/WordPress/WordPress/blob/4.5/wp-includes/class-wp-
meta-query.php#L634 CASTs the column value] `postmeta.meta_value` and
compares it to the value provided in the meta query, a la
`CAST(postmeta.meta_value AS CHAR) = 'some-value'`.
Casting a column value instead of a constant means that MySQL will ignore
an index for that column if one exists. Although core does not define an
index for the `meta_value` column, a user could create one for perf
reasons.
Switching the side of the CAST would result in the same two types, just on
different sides
`postmeta.meta_value = CAST('some-value' AS CHAR)`
That means [http://dev.mysql.com/doc/refman/5.7/en/type-conversion.html
MySQL's type conversion] will work the same as it did previously.
#36649 would need to be completed before this.
Related: #27272, #36625
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36670>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list