Archive

Posts Tagged ‘MySQL’

How to Setup a Basic WordPress Development Environment

May 7th, 2011 No comments


One of the most common things I get asked about when talking about developing WordPress plugins is my tools and development environment. Now, developers have all kind of tools and setups that they feel is the ‘Best’ way to do things. It’s all a matter of opinion really. It all boils down to needing a few things though, an Integrated Development Environment (IDE) that you are comfortable with, an LAMP, MAMP, WAMP stack (Apache, MySQL, PHP), SVN, and a download of WordPress. I’ll go through these 1 by 1 and show you how to get setup.

First off, a good book on development with your desired platform is NEVER a bad thing to have. I recommend Professional WordPress Plugin Development. They just released a new version of it and it’s a fantastic resource.
Continue reading “How to Setup a Basic WordPress Development Environment” »

A Clean Database is a Happy Database

November 15th, 2010 No comments

Recently I posted about how to clean house on your tag taxonomy in WordPress. I thought I might also suggest two plugins that will help you keep your WordPress MySQL database a little cleaner and a little faster. With the introduction of WordPress’ revision system, each time you edit a post or page, an entry is made into the database. While this can be helpful during the editing/revision process, after the post is live and no longer in review, the list of rows in the database can grow to the 100′s for each post depending on how many time it was edited. This leaves us with what is called ‘Overhead’.  Here’s what the fine people over at Stackoverflow had to say about overhead:

Every database will, over time, require some form of maintenance to keep it at an optimalperformance level. Purging deleted rows, resequencing, compressing, managing index paths, defragmenting, etc. is what is known as OPTIMIZATION in mysql and other terms in other databases. For example, IBM DB2/400 calls it REORGANIZE PHYSICAL FILE MEMBER.

It’s kind of like changing the oil in your car or getting a tune-up. You may think you really don’t have to, but by doing so your car runs much better, you get better gas mileage, etc. A car that gets lots of mileage requires tune-ups more often. A database that gets heavy use requires the same. If you are doing a lot of UPDATE and/or DELETE operations, and especially if your tables have variable length columns (VARCHAR, TEXT, etc), you need to keep ‘er tuned up.

So how can we keep this to a minimum? There two plugins I recommend and use to keep my overhead to a minimum.

Delete-Revision – Download

Alright, apart from a little translation issue in some of the buttons, this plugin has done it’s job for me. Heck, even in the less than 30 minutes I’ve spent writing this, I already have 2 revisions just for this post.

Delete Pesky and unwanted revisions from old posts.

I’m not going to delete these revisions just yet, I would never delete a revision from an article I’m currently working on. But just yesterday I removed about 100 revisions from the database. That’s 100 rows in the posts table I don’t have to worry about. I strongly recomend that if you are going to be deleting things from the database, that you make a backup. I use a Cron script to optimize and backup. If you are a multi-author blog with quite a few posts going on at the same time, I might suggest that you coordinate a time for this action, when no one is in the middle of authoring. Just setup a time of about 20 minutes each week that you can go in and clean house on revisions. After you delete them, I then recommend the next plugin.

Optimize DB – Download

This plugin shows up in your ‘Tools’ menu and gives you a snapshot of the size of your database, as well as the amount of overhead that currently exists. With the click of a button that says ‘Optimize’ you can reduce the overhead and clean up those nasty bits of data left over.

The main screen of Optimize DB

You might be saying at this point that 7.1 KB of overhead isn’t that bad right? Well keep in mind that I run a few automated Cron scripts to optimize my databases every Sunday evening. At times, depending on the work I’ve done throughout the week, this can be an overhead of up to 512kb which in the scheme of things, is about 1/3 of my total database in overhead. Yikes!

Hopefully these two plugins will give you a little more control over the mess that can become your WordPress database. I wish you happy optimization and low overheads ;) .

Cheers!

How To: Bulk remove sparsly used tags in WordPress

November 2nd, 2010 No comments

If you have been using WordPress for quite some time, no doubt that you have built up quite a collection of tags and categories. If you’ve ever wanted to clean a little house with your tags, you can do it quick and easy if given access to your MySQL command line interface. The following command will remove all tags that have a post count of “0″ (meaning no posts are using these tags).

DELETE t.*, tx.*
FROM wp_terms t, wp_term_taxonomy tx
WHERE t.term_id = tx.term_id
AND tx.taxonomy = "post_tag"
AND tx.count = "0";

Want to remove any tags that are only being used in 1 post or less? Simple, use the following:

DELETE t.*, tx.*
FROM wp_terms t, wp_term_taxonomy tx
WHERE t.term_id = tx.term_id
AND tx.taxonomy = "post_tag"
AND tx.count < "2";

Now go to your Post Tags management screen and look on in amazement as you now have a manageable number of tags. Keep in mind that this is irreversible, once you run this query...those tags are long gone and will have to be recreated.

Categories: Tips Tags: , , ,

Change your WordPress domain quickly with Linux, MySQL, and sed

August 15th, 2010 3 comments

You have no idea how hard it was to refrain from using the command ‘sed’ in a totally ridiculous homophoned title. Have you found yourself wanting to change the domain on an established WordPress installation, or even trying to replicate many times over the same exact WordPress database on a different domain? Yeah, me too. I’ve found while doing plug-in development, it helps to have the same database information copied over when I start with a new branch. Luckily, Linux comes to the rescue with the sed command. It’s a 3 step process. Export your source/current database. Search and replace with sed, and then import the database. Here’s a step by step for you.
Continue reading “Change your WordPress domain quickly with Linux, MySQL, and sed” »

Categories: Tips Tags: , , , ,

Updated today, release 2.2!

April 21st, 2010 No comments

Could it be that the Updated Today plugin for WordPress has been updated to version 2.2 only a day later!? You better believe it.

I’ve added some more options to this one. You now can choose if post, pages, or both trigger the banner. You can also choose between the original post date or the modified date (or both) affect the banner. I hope you like the updates.

Cheers!