We have a WordPress installation with many plugins installed. The site is not that highly frequented (maybe 10-20 concurrent users). I know the amount of plugins comes at a cost of performance. However, the performance drain was so great we investigated and had the database log the queries for a certain amount of time, because the database thread was always exceeding 100% system resources in our system monitors, which should not be the case with 8x Cores, 16GB Ram, 100GB SSD etc.

After loggin 5 minutes we had more than 220k queries. More than 90% were pretty much the same query (except the user ID changed) in the form of:

SELECT user_id, meta_key, meta_value FROM usermeta WHERE user_id IN (1548) ORDER BY umeta_id ASC

This is obviously not correct and explains the bottleneck issue we are experiencing right now with our DB-Server. We are trying to find the culprit for this, but do not know how to find out what is causing these many user_meta queries.

With the help of the WordPress Plugins DebugBar and Query Monitor I was able to isolate the plugins causing the issue.

They are material-wp (selects from usermeta) and to some sort advanced-custom-fields-pro (selects from postmeta). https://i.stack.imgur.com/JP0u0.png (usermeta) https://i.stack.imgur.com/gzrLc.png (postmeta)

They main issue lies within the get get_metadata function and there with the update_meta_cache function.

After contacting the author of the material-wp plugin he probided a quick bugfix which seems to have solved the issue for the massive amounts of usermeta queries.

However, I still would like to improve the database performance.

Any help would be highly appreciated. (Is there a way to disable the update_meta_cache function globaly?

  • Could you post results of A) SHOW INDEX FROM usermeta; and B) SHOW CREATE TABLE usermeta; and C) EXPLAIN SELECT .....(your query) for analysis? May 30, 2019 at 13:18

1 Answer 1


I'm sure there are more sophisticated ways to debug the queries, but I'm not aware of them. So usually when I need to debug WP queries I use either Query Monitor or Debug Bar (with Slow Actions addon) plugin, which can be found on the wordpress.org plugin repository. These plugins help you trace which functions / plugins are slowing the site down. At least for me these plugins have been great help.

I'm not affiliated to any of these plugins and my apologies for giving just a plugin recommendation answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.