WP_Meta_Query is inefficient when referencing the same keys in "OR" query
|Reported by:||sc0ttkclark||Owned by:|
|Component:||Query||Keywords:||needs-refresh meta-query needs-unit-tests needs-patch|
This is part of the chain of thought from #19729
I believe this fix didn't take things far enough. For example, a meta_query that does a lot of comparing on the same meta_key, will have a JOIN and a WHERE for each query array. It shouldn't have to re-join the postmeta table on each query array though, since they are based on the same meta_key.
I'll attach a suggested patch that will only join if it needs to, and use the previous alias for the first meta_key joined table if it's already been joined.
Change History (16)
comment:6 wonderboymusic — 8 months ago
- Keywords needs-refresh added; has-patch needs-testing dev-feedback removed