-
-
Notifications
You must be signed in to change notification settings - Fork 523
Description
Currently, meta_query is flagged by WordPress.DB.SlowDBQuery as being a "possible slow query".
The reality of this is more complex, as the slow part of meta queries really only kicks in when querying by the (unindexed) value column. That means that some meta queries are not slow queries, and we can detect those.
Specifically, using EXISTS or NOT EXISTS as the comparison function only hits the key column, and hence has good performance. (We often recommend developers move unique IDs into key names and query by this to improve performance; .com VIP similarly notes the issue is with meta_value rather than meta generally.)
I'm working on a replacement for SlowDBQuerySniff which checks the query more in-depth; would this be of interest to PR back to WPCS?
(I'm also looking at the same for tax_query as not all taxonomy queries are expensive.)