When a user of my Simple:Press Forum plugin suffered a database table ‘crash’ the other day I was reminded that in all probability the vast majority of WordPress users - and in fact users of other such systems - probably never perform any maintenance on their database and wouldn’t know where to start to do so. In fact, that same majority probably do not even know that doing so is not only a good idea but, in many cases, somewhat necessary.
WordPress and a large number of similar systems use the popular MySQL database engine which has proven, over time, to be remarkably stable and resilient. But it can get it’s knickers twisted which can lead to a slowdown in performance and, if left long enough, a database crash. And all it takes to keep it in good working condition is a few minutes of your time once every few days.
A typical problem exists around the WordPress ‘comments’ table. On a busy site a large number of comments may be received every day but because of that success an awful lot of spam comments arrive as well. Comments come in all sizes from a quick one-liner to a small novel length spam entry containing a hundred links. You’ve all seen them. And then all those unwanted entries get deleted. Because of this disparate activity, the ‘Comments’ table can become somewhat disorganised and MySQL will start to store bits and pieces in what is known as ‘overhead’. The bigger the ‘overhead’ becomes, the slower the database becomes at returning data and eventually, if left to itself, the risk grows of the table crashing and that will stop your site dead in it’s tracks with database error messages appearing all over the pages.
One way of ensuring the health of your database - and the easiest way if you do not want to learn a little of what is going on under the hood - is to use the excellent ‘Optimise DB‘ plugin from Roland Rust. Install and activate as normal and visit your manage menu once a week and this plugin will perform the necessary tasks to keep your database humming along.
If you are more curious and want to learn a little more about your database then by far the best tool is phpMyAdmin. This is usually available from your hosting control panel but there is also an excellent plugin - ‘WP-phpMyAdmin‘ also from Roland Rust and Christopher Hwang, that installs it into your ‘Manage’ menu. By visiting phpMyAdmin you will learn a lot about your database, the tables and see the size of the overheads for yourself.
In the default ‘database’ view you will see the tables with overheads shown in the right hand column and beneath the listing is a link to select those with overhead. Click that link and select ‘Optimise’ from the drop down list and all will be well.
If you have actually suffered a database table crash - then use the ‘repair’ option from the same drop down list. It is that simple.
A little database TLC goes a long way and it is quite alarming how many users will struggle on with a slowing database that can so easily be kept up to speed.
This is something that more people need to do. Keeping their databases up and running will keep some blogs from going down.