Database Bloat by Transients

When I set up this blog on the production server, I thought I was going to be able to eliminate some of the database bloat by removing all of the default themes and installing my custom theme before running the install. My theme has some code in the functions.php file that removes all of the admin dashboard feeds. It didn’t work. WordPress expects there to be an activated theme, and isn’t smart enough to use the only one there is in the themes directory. I probably could have accessed the database and changed the theme before doing the install, but I’m not sure I would have achieved what I set out to do.

Following installation of WordPress, if you check your database you will find a bunch of bloat by WordPress transients. I waited until today to remove the transients, which was only after 10 posts, and it cut my database size down nearly 75%! This percentage would have been even higher immediately following the install. Transients are merely cached data, so according to what I find to be true, all transient data can be safely deleted from the options table.*

DELETE FROM `wp_options` WHERE `option_name` LIKE "%_transient_%"

I ran this SQL in phpMyAdmin. I had to change the table prefix, because I am using a custom one, but it worked. It basically went through my entire options table and deleted all rows where “transient” was part of the option name. All this is probably meaningless if you haven’t disabled the admin dashboard feeds, and I do that by putting the following in my functions.php file:

function remove_dashboard_crapola()
  global $wp_meta_boxes;

add_action('wp_dashboard_setup', 'remove_dashboard_crapola' );

My total database size went from 359KB to 91KB. Look around online and you will find people saying they saved a lot more space. I understand that anyone can make a plugin that stores transients, but the major offense here seems to be that of WordPress itself. I want my database to be as lean as possible, and I don’t believe that 75% of my database should be bloat.

* Always make a backup of your database before doing anything like this. If something goes wrong, you may have no way to get things back to normal without a backup.

3 thoughts on “Database Bloat by Transients”

  • Jorge Cordoba says:

    Its amazing that WordPress has not removed this stuff a long time ago, but then it isnt exactly the most professionally made application.

    • Jorge, I know how you feel, but WordPress certainly has a lot to offer, especially for the client with a tight budget.

  • Yeah, transients NEVER get old. You might want to check this plugin: Artiss Transient Cleaner Works flawlessly in my tests.

    It is embarrassing non-available feature of WordPress. Pretty sure it IS even acknowledged by core devs. Wait for hmm WordPress 3.8 or something.

    Just stupid issue but WordPress owns 17% of the internet so… 😉

    Next. Uninstall of plugins using custom post types. Content is not removed! Which can be argued for, perhaps. Some plugins clean up after them self (“delete data”), others not – they only do “files”. I think official view is they should not, as to protect users against messing about and risk losing data. Hmm.

    Seems like trick could be to increase information level but implies increasing “demands” to end users – and then kiss good bye to 17%, heh. Decisions not options hell.

Comments are closed.