I find this query and that takes 20 seconds for few rows…
SELECT DISTINCT(BINARY `meta_key`) as meta_key_binary, `meta_key`
FROM wp_postmeta
ORDER BY `meta_key` ASC
Is that deprecated in mysql 8? How to change it for mysql 8 than?
Or any idea why that is so slow?
I cant find something nearly same for mysql 8
2
Answers
Using the
BINARY
conversion operator is probably preventing use of an index for your query.You could add a virtual column to the table with the binary value of
meta_key
and index that.Replace
(100)
with the correct length ofmeta_key
from the original table schema.See Barmar’s Comment on parentheses
For improved performance of WP, especially when using
postmeta
: WP Index Improvements