Press "Enter" to skip to content

Excellerating WordPress

While optimizing my databases and such I noticed that I had been making a fatal mistake with my WordPress database; marking comments as ‘spam’ through the comments moderation panel. This only marks the comment_approved feild in the row for that comment in the wp_comments table from ‘0’ to ‘spam’.

In over a year I’d accumilated over 12K rows just for spam that needed to be parsed each time a particular post/page was to be displayed, and dragging down the performance of my blog. Instead of marking spam as such, deleting them completely seems to be the route to take.

A quick query to run against your database in a utility such as phpMyAdmin follows to purge the tables of those entries for you;

[code]
DELETE
FROM `wp_comments`
WHERE `comment_approved` = CONVERT( _utf8 ‘spam’
USING latin1 ) ;
[/code]

Some tweaking may be needed far your particular setup, I’ll be submitting this as a feature request to the kind folks at WordPress or if time permits creating a quick and dirty plugin.