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.sstatic.net/JP0u0.png (usermeta) https://i.sstatic.net/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?