No doubt that Akismet is one of the best anti spam plugin for WordPress. But it's not as good as I thought. The problem appear a few months ago when I noticed that my blog (Deluxe Blog Tips) ran too slow. People couldn't comment or post new thread at support forum (which was a bbPress forum). Some kind people also sent me emails warning me and complaining me about that, because they really need support for some of my plugins. That forced me to dig into the problem and find a solution. Unfortunately, I found that Akismet is one of them, which made me really surprised as I always think any product from Automatic is well-tested and verified by the community.
The starting point - Database
One of the first thoughts in my head at that moment is optimizing database. I needed to remove redundant tables left by removed plugins, cleanup some orphan options, etc. I noticed a problem when I backed up my database before doing anything related to it. The size of the database is 27 MB (zipped) and 247 MB (unzipped), which is very high for a small blog with less than 200 article like Deluxe Blog Tips.
Looking to the table size I found this:
Do you believe these numbers? More than 100k records with 170 MB? Are you kidding me?
What did Akismet do with my database
commentmeta table, I found the answer:
Akismet simply logs its data. In my case, after running this query:
select count(*) from dbt_commentmeta where meta_key='akismet_as_submitted' or meta_key='akismet_history' or meta_key='akismet_rechecking' or meta_key='akismet_result' or meta_key='akismet_user' or meta_key='akismet_user_result';
106680. These records accounted most size of the
commentmeta table, because each record was large.
My decision was removing these records and uninstalling Akismet. This is my query:
delete from dbt_commentmeta where meta_key='akismet_as_submitted' or meta_key='akismet_history' or meta_key='akismet_rechecking' or meta_key='akismet_result' or meta_key='akismet_user' or meta_key='akismet_user_result';
And after repairing and optimizing table, I got the size of 157 KB. Do you see the difference?
Instead of Akismet, I picked another plugin for anti spamming, which is simple and doesn't log or write too much in the database: Block Spam By Math Reloaded. Basically this plugin checks spam by force people answer a simple math question. It doesn't block spam by the comment content, so it can't blog spam by human. But in my case, that's good enough. I also modified it a bit to match my design.
It's not the end
When I write this post, I looked into the code of Akismet, and I find one interesting: Akismet do remove its logs in
commentmeta table! It uses WP Cron to run a removal query every day. But for some reason the cron doesn't run in my blog! I'm still on the way finding the right answer.