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.