Very slow query on wp_postmeta
-
Hi, I have a website with over 1.000.000 wp_postmeta rows. When I add (in homepage) an elementor Brand or Products object I have insanely slow queries around 0.5s that slow down the page to 20″ or more.
The query is this (and similar one) and it’s generated from the theme Brand shortcode or Products grid shortcode.
SELECT post_id, meta_value
FROM wpva_postmeta
WHERE meta_key = ‘_wp_attached_file’
AND meta_value = ‘2020/03/logo_vitakraft_2014.png’
If i select all row
SELECT * FROM wp_postmeta
I get 0.0005s
meta_value is the only column that isn’t indexed
Hello,
This query is the simplest SQL query that takes two fields based on two basic conditions. If you have problems with such requests then it is something with your hosting server or it doesn’t have enough resources to handle this. But we don’t see any problems with the query itself and it shouldn’t take much time to complete. Also, it is generated by the WordPress core function, it is not directly sent by our theme’s code.
Kind Regards