How To Quickly Clean Up Your WordPress Database

I’m putting this post on my site because I’m tired of search for the commands.

There are plugins that will clean up your WordPress wp_posts table, but if you have access to the database you can do this yourself.

Backup the Database

You should always make a backup copy of your database just in case something goes wrong. This is a “duh” but it happens and things can go wrong. You’ll be deleting records from a table so before you do, make a backup.

Run the DELETE Query

Run the following command on your database. If you have a shared host with a cPanel you probably have phpmyadmin which is your user interface to your MySQL database. WordPress usually installs in MySQL as wrdp. You want click on the right database for your WordPress install. Once you are in the right database you can run this query:

DELETE FROM wp_posts WHERE post_type = "revision";

This will delete all the revisions from WordPress. Just out of curiousity you might take a note of how much space the wp_posts table was taking up before and after running this query. That will tell you how much room you recovered.

Optionally, You Can OPTIMIZE

This step is optional. If you are sweating bullets right now after deleting 20,000 revision posts, you can skip this step.

Optimization “releases” the data you deleted from memory thus freeing memory. Its like delete puts data in the trashcan and optimize empties the trash. To optimize the wp_posts table run the following query:

OPTIMIZE TABLE wp_posts;

Check to see the size of this table. In the YIW database, the “wp_posts” is only 3,4 Mb in size, as you can see in the photo below. It’s a lot of space saved, don’t you think?

My Numbers

I’ve run this query several times over the years. It’s like cleaning up your computer’s hard drive – the more you use it the more you should clean it up. There were my numbers.

Start 407 rows | 792.1 KB

Deleted 61 rows | 96.1 KB

Finish 346 rows | 695.4 KB

Hope this works for you. I know it works for me and I use it about once a year or so.

OpenDNS Denies Gravatars, WordPress Blogs Full of Broken Images [UPDATED]

(This incident occurred on March 3, 2011. OpenDNS released its block of Gravatar within a week.)

This is huge: OpenDNS is denying access to gravatar.com. When I saw that avatars on my blog were broken I tried to look at the image on gravatar.com and got the following message page:

This site was blocked by OpenDNS in response to either the Conficker virus, the Microsoft IE zero-day vulnerability, or some equally serious vulnerability.

If you think this shouldn’t be blocked, please email us at contact@opendns.com.

This is huge because WordPress has avatars built in to the code. They link to images from gravatar.com. So every blog that uses avatar just got a lot of broken images. According to WordPress they have encouraged the use of Gravatars since WordPress 2.5:

WordPress 2.5 marries theme authors and casual WordPress users together with support for Gravatars in the WordPress Administration Panels. Theme authors have an option to include Gravatars in their designs, and are recommended to do so. WordPress users can easily control their Gravatar usage in the Settings > Discussion Administration Panel. via Using Gravatars « WordPress Codex.

My personal experience with OpenDNS is not a good one. They’ve basically hijacked my “broken” Google search results at home. Let me explain. I have suddenlink internet service (no trolls please). I used to have Google as my default search-in-the-url-box search engine. Back then – about three years ago – if I typed in a URL that didn’t exist, Google would return search results for what I typed. NOW, OpenDNS takes over the search from Google and displays their results which are not the same as Google. It’s basically hijacking and extortion. OpenDNS is paid or sells links to paying customers to display their results were Google gets paid to display a few results at the top but everything else (free) is displayed below.

I did a check of forums, and OpenDNS doesn’t have a clear cut or openly viewable documentation on it’s practices. It appears as though they deny domains at random on a daily basis. In that way – read the above message – it appears they are extorting domain owners to contact them (and possibly pay) to get removed from their blacklist. If that’s the case, that’s bad. How could one company hold that much control of the Internet?

UPDATE:

OpenDNS Twitter reply

After I wrote this and posted a couple tweets I guess I got noticed. I got a comment on this blog and OpenDNS responded with a tweet.

Thanks. I guess all of us can turn on avatars in WordPress again.

Woo Themes

I installed this new theme from Woo Themes, and it appears that they leave off a lot of web elements I took for granted. In the SEO section an admin has to specify a lot of things like title, description, keywords, and what to index. They say they support two of the most commonly used SEO plugins – All-in-One SEO and Headspace 2, but those seem like even more work.

Just in case I change themes again and loose my keywords I listed them here. I used the following keywords for my home page:

Siems, Chris, teamsiems, team siems, web, website, development, developer, Economics, Education, Europe, Nature, Odd, OIT, Personal, Politics, Religion, Social Media, Technology

I used the WordPress default for the title and description. The indexing I left on categories.

UWEB Lightning Talk Notes 09-04-2009

What little I wrote down is here. There is a couple good links.

Robert: who makes user experience design

Stephanie: WordPress content import plugin.

Also see: wordoff.org

Rob: SVG

Plain text (XML). It can be manipulated by JavaScript (DOM).

Monty: Standard module format

Also see: Yahoo Theather

At the end we had an open discussion where we talked about good resources to learn technologies of the web.

One byproduct of the talk was a resource for handling javascript in IE7 at http://dean.edwards.name/IE7/

For more information about the Lightning Talks or other topics the uWeb group talks about go to http://uweb.tamu.edu/