0

My Wordpress website is often going down with the error message "error establishing a database connection" and when I contacted my hosting server, they replied that the query takes a long time(more than 25 sec) and killed the database connection. So that they asked to optimize the wp_option table. Kindly guide me to optimize wp_option table and improve the site performance.

    Killed queries for the database(s):-
----------------------------
vn_wp3

Also, the following error message regarding the database(s):-

------
2018-04-18 12:34:01 +0000 [info] killed_thread_id:30117883 user:vn_wp3 host:localhost db:vn_wp3 command:Query time:25 query:SELECT option_value FROM wp_options WHERE option_name = '_transient_timeout_srcmnt_notices' LIMIT 1
2018-04-18 12:34:11 +0000 [info] killed_thread_id:30118047 user:vn_wp3 host:localhost db:vn_wp3 command:Query time:25 query:SELECT option_value FROM wp_options WHERE option_name = '_transient_timeout_srcmnt_notices' LIMIT 1
------
------

I checked the wp_option table size, it's around 21 MB.

  • That's quite large. How to optimize it? Check your plugins and themes. Double check, triple check. Which do you really need, check one by one which influences that table how much and decide if it is worth keeping – kero Apr 18 '18 at 16:51
0

If you Google for "wp_options optimize" you'll find some suggestions how to search for performance problems in wp_options.

It makes sense to check which option values are very big, using the following query. Then check if you really need the plugin that wrote this setting (or remove the setting(s), if the plugin already is installed). In some cases you can also fix that by changing a plugin's (or theme's) configuration:

SELECT *, LENGTH(option_value) option_size 
FROM wp_options 
ORDER BY option_size DESC;

It might be necessary to do a mysqloptimize on the table after removing the values.

0

Surely, it must be annoying when your website show that error message frequently. Please try these 2 possible solutions that you can try.

  1. Transient values: Some times transient values in the database increase the size of the database significantly. You can read about that in the link below. Also check how you can delete them and optimize your website : https://www.wpbeginner.com/plugins/how-to-manage-and-delete-transients-in-wordpress/

  2. Check for autoloaded data in the wp_option table. For which you can read more here: https://kinsta.com/knowledgebase/wp-options-autoloaded-data/

New contributor
made2popular is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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