My WordPress site has wp-cache installed and it never runs slowly. However, lately it took me more than 15 minutes to log on WordPress as admin. I was very puzzled. If you have the same experience, here’s the solution for you.
After much observation, I found out that my blog had tons of spam comments. Akismet was good enough to catch them and put them into the trash bin. My blog has accumulated over 65,000 those junk. Spammers are amazingly persistent.
I have WP-DBManager plug-in installed which allows me to managed my database from inside WordPress. My wp-comments table is a staggering 40MB, see image below.
Apparently, when I log in as admin, WordPress dashboard tries to sieve through the comments to give me a stats of the number of pending comments. That caused WordPress to hang.
Now, here’s the solution.
- Delete the trash comments by clicking “Empty Trash”. On my setup, WordPress can delete about 3000 trash comments at one shot, then gives me a blank page due to http connection time-out. You’ll need to click “Back” on your browser to get back to WordPress dashboard to run another delete.
- Once all trash comments are cleared, go to WP-DBManager option page, run “Optimize DB”, see image below. This will clean up the dead entries in the wp-comments table.
After these, my WordPress blog responds to login request in 10~15 seconds.
Some people spam WordPress sites for a living. To prevent your blog from being filled with trash comments again, you need to instruct WordPress to clean the trash regularly or don’t keep trash at all. You need to edit your wp-config.php file in the root directory of your WordPress and add one of the following lines:
define(‘EMPTY_TRASH_DAYS’, 3 ); // empty every 3 days
define(‘EMPTY_TRASH_DAYS’, 0 ); // don’t keep trash
Good luck and happy blogging.