Make WordPress Core

Opened 9 years ago

Last modified 6 years ago

#36670 new enhancement

Move CAST to right-hand side of comparison in meta query

Reported by: ericlewis's profile ericlewis Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Query Keywords:
Focuses: Cc:

Description

The SQL clause created by a meta query 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 MySQL's type conversion will work the same as it did previously.

#36649 would need to be completed before this.

Related: #27272, #36625

Change History (0)

Note: See TracTickets for help on using tickets.