Simple UTW Performance Boost

The Ultimate Tag Warrior plugin for WordPress is a great plugin. It does the job of handling tags rather well. I’ve noticed many hits from Google searches that go to a tag page instead of a category page of the same name so there’s something there that Google likes. I love it! Christine Davis did a super job filling a niche with the “ultimate” tool that anyone could want.
Unfortunately what isn’t so good is what goes on behind the scenes:

  1. UTW ignores your default category when saving your posts. Why ignore the default category when that is probably the subject you care most about? On my photoblog, In my default category is “photos” and I certainly want people to find my images.
  2. UTW does an expensive SQL JOIN when it can’t find any tags for a post. Remember what I said about the default category? If you primarily post to your default category then every time someone sends you a request your server will get bogged down trying to find a non-existant record. It’s really bad when you have several years of posts and thousands of records in there.
  3. If you’re not going to use the fancy AJAX tag search then don’t load the associated Javascript. It saves an extra request on the first page load, and the browser doesn’t have to process the file.

Here is a patch that addresses those issues. It needs to be edited before you use it because you have to add a default tag. Here’s how to install it:

  1. Decide on a useful default tag. For this blog I use “holy-shmoly”. Open your WordPress database with phpmyadmin and look in wp_post2tag (the name may be different depending on your prefix). If you have already used the tag then find it and note down the tag_id of that tag. Otherwise, add your tag and note the new tag_id.
  2. Edit utw-patch.diff and look for the strings DEFAULT_TAG_NAME and DEFAULT_TAG_ID and replace with the name and id you picked out in the last step.
  3. To apply the patch, copy it into your wp-content/plugins/UltimateTagWarrior/ directory and run the following command.

    patch -p0 < utw-patch.diff

  4. If you don’t have access to patch, then open utw-patch.diff in your favourite editor and make as much sense of it as you can. It’s not hard once you have the source files open as well.

I’ve noticed a significant drop in server spikes since I made those changes. It takes a while for the default tag to be populated as it’s done when posts are visited but once it’s finished you should see a marked improvement. Oh, and install WP-Cache 2.0 as well. That’ll help you ride out the occasional digg!

Download the patch: utw-patch.diff for UTW 3.14159 for WordPress 2.0

By request, here are the modified files. Rename .txt to .php and copy them into your plugins/UltimateTagWarrior/ directory, overwrite the originals:

  1. ultimate-tag-warrior-actions-wordpress2.txt
  2. ultimate-tag-warrior-actions.txt
  3. ultimate-tag-warrior-core.txt

29 thoughts on “Simple UTW Performance Boost

  1. nice.

    i spied that AJAX tag search being loaded on every page myself. And I always wondered why “asides” never showed up in my tag cloud. i think i’m one of the few who the “no default tag” actually benefits.

  2. Nice speed boost on this, as I brought a LOT of content over from an older non-tagged blog into my new site, I had a lot of posts with no tag, the default tag feature of this patch is really nice for that. Also, glad to finally get rid of that AJAX. Thanks Donncha!

  3. Would you consider releasing the patched files? I’ve got patch on my system, but keep getting HUNK errors when I try to patch a brand-new 3.14159 of UTW. Very perplexing.

  4. Good idea Drew and I’ve added them to the post. Did you copy and paste the text of the patch? It needs to be downloaded because there are tabs in the file.

  5. I have to admit, I’m really happy with the way this server is performing now. I thought I’d have to move and even took out a $15 account on Tektonic to compare performance in case I needed to move this blog to new VPS.

    Tektonic sucked, I’ll have to post a comparision some day soon. Granted this is on a linode server that costs twice as much but you get twice the memory with Tektonic so I was expecting good things.

    No need to move now however, things are going swimmingly!

  6. Greg – yes you do. You have to create a default tag and change the source files. You reminded me that I hadn’t changed the files to include the DEFAULT_TAG_NAME and ID but I’ve done that now.

  7. Donncha: thanks for the reply. I downloaded the new files, I edited the .diff file with a tag and tag_id but I get the “default_tag_name” showing up in the UTW field in the editor. I found that the ‘default’ is different from what I thought I set.

    I did not run the patch -p0

  8. Brilliant work! Thanks for the updated files, as I couldn’t get patch to work. This is great stuff, a huge improvement. At first, I hated the idea of nailing myself down to a default tag, but really, why not? It’s optional, after all.

    Many plugins are amazing in and of themselves, and many are great but could use a lot of work. UTW is just about the most useful plugin ever, and although it didn’t actually need much improvement, your tweaks were brilliant and made it perfect.

    Thanks again!

  9. Hi,

    Thanks for the update. I cannot run the patch but have uploaded the files and located the tag ID. Where and how do I set the default tag value now?



  10. Hi again,

    I found the answer myself 🙂

    open: ultimate-tag-warrior-core.txt in your text editor and change DEFAULT_TAG_NAME and DEFAULT_TAG_ID to your own values!


  11. Hi

    I edited ultimate-tag-warrior-core.php and put in my default Id and tag. But when I look at untagged posts the new default tag isn’t showing. What am I doing wrong?


Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.