0

I have a website that has suddenly become slow. I don't know what caused the change. I haven't installed new plugins, and I don't think I recently updated any plugins. Upon inspection with Query Monitor, I can see that there are about 15,000 queries per page. Most of the queries (14K+) are repeated queries to wp_options

SELECT option_name, option_value
FROM wp_options
WHERE autoload = 'yes'

Is the cause of these queries that certain rows that are supposed to have autoload='yes' do not? How can I figure out which rows should have autoload 'yes' vs 'no'

I tried copying the autoload 'yes' values from another website, and I was able to lower the total number of queries to 8.5K like this. However the website isn't any faster.

Any advice on debugging this issue or somehow "resetting" the autoload values of the wp_options table?

6
  • autoload has nothing to do with this. There should not be 14k+ queries to wp_options for all options. The whole point of autoload is that there should only be one of these queries so that options are cached and future calls to get options do not go to the database. Something else has gone wrong. Try the usual debugging steps of disabling themes and plugins until the issue goes away. If you're using Query Monitor it should give you a trace of what's calling the query. Commented Feb 13, 2023 at 6:10
  • 1
    Are you talking about 15,000 results (Rows) or 15,000 separate SQL queries? To be honest, I don't think your page would even load if there were 15,000 separate SQL queries.
    – Fayaz
    Commented Feb 13, 2023 at 7:37
  • @Fayaz 15k separate queries - took 15s to load - many plugins are doing hundreds of wp_options queries Commented Feb 13, 2023 at 17:46
  • Ah, that's just purely sad. Something is horribly wrong there. However, I don't think this can be objectively answered here without looking into your setup - which is out of scope of WPSE. I suggest you employ an expert to investigate your WP installation.
    – Fayaz
    Commented Feb 13, 2023 at 18:26
  • @Fayaz turned out it was a leftover file wp-rocket Commented Feb 13, 2023 at 18:33

1 Answer 1

2

WP-Rocket was deactivated, but the wp-content/object-cache.php file was still present. This file redefined the wp_cache_add in such a way that the method didn't work, so all requests to get a single option value were resulting in a query to the wp_options table.

I deleted the wp-content/object-cache.php file and the page response time dropped to 2 seconds from a peak of 15 seconds, and the total number of queries to 288 from a peak of 15,000.

1
  • WP Rocket doesn't handle object cache and none of its features needs/creates object-cache.php. Commented Jul 20 at 20:12

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.