[wp-trac] [WordPress Trac] #49278: Improve meta query
WordPress Trac
noreply at wordpress.org
Tue Jan 3 19:44:46 UTC 2023
#49278: Improve meta query
-------------------------------------------------+-------------------------
Reporter: jillebehm | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future
| Release
Component: Query | Version: 5.3.2
Severity: normal | Resolution:
Keywords: has-patch dev-feedback early early- | Focuses:
like-actually-early has-unit-tests | performance
-------------------------------------------------+-------------------------
Comment (by rjasdfiii):
> CAST(mt1.meta_value AS DATE) = '2020-01-23'
For MySQL and for DATE or DATETIME, that can be simplified to
mt1.meta_value = '2020-01-23'
This change will allow an index, even `INDEX(32)` to be of some use for
optimization. Cf, the plugin: https://wordpress.org/plugins/index-wp-
mysql-for-speed/
Caveat, if `meta_value` is actually a DATETIME and the intent is to
truncate to DATE, then the `CAST` (or equivalent) is needed. The
following would be better, but probably not worth considering:
mt1.meta_value LIKE '2020-01-23%'
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49278#comment:28>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list