Archive for July 4th, 2010
So after my little fiasco with plug-ins and CPU throttling, I’ve been looking for ways to make WordPress at least a little lighter and faster. I’m not going to cover disabling plug-ins, I’m going to go over a few other ways, starting with …
Every time a post is edited and/or published, a new revision is created. These stick around in the database (never deleted) and can not only grow the database, but can also lengthen query times for information. So, per WordPress codex, here’s the quick-and-dirty:and the
…simply add the following line of code to wp-config.php file located in the root or home directory of WordPress blog.
If you would rather limit the number of revisions to something small, say 2 for example, just use the number instead of
It should be added somewhere before the
require_once(ABSPATH . 'wp-settings.php'); line. That’s it. Revisions will no longer be created. If you want to delete previously created revisions, read on…
So now that you’ve disabled revisions, how do you delete all the old cruft laying around?has the answer on this one too.
…and then issue the following [SQL] command (it’s also recommended to backup the database before performing the deletion SQL statements):
DELETE FROM wp_posts WHERE post_type = "revision";
All revisions should now be deleted from the database.
Caching is a hot button for sites that could potentially see high amounts of traffic (and since we would all like to be in that category…) The caching plug-in that I use and recommend is WP Super Cache. The UI is easy enough to work around, though it does require editing of the .htaccess file.
Shared hosting providers get real upset when applications and scripts perform excessive and unoptimized database queries. Heavy themes, excessive numbers of widgets, and badly-written plug-ins all contribute to this. Fortunately, a post on CravingTech points to an easy method to check the number of queries happening on a single page load.
You can insert this snippet of code on your Footer.php file (or anywhere) to make it display the number of queries:
<?php echo $wpdb->num_queries; ?> <?php _e(‘queries’); ?>
After looking at the number of queries occurring on a page load, try changing themes, disabling plug-ins, and/or reducing the number of widgets on a page to reduce the number of queries. SQL Monitor looks like a useful plug-in for further examining SQL queries, but I haven’t used it, so I can’t comment on it’s usefulness (or lack thereof).
I’ve stumbled on some additional information while researching, and apparently the “WordPress should correct invalidly nested XHTML automatically” setting (under Settings > Writing) can not only increase the load when a post is saved, but can also break some plug-ins. If you’re familiar enough with (X)HTML to handle correctly closing tags, you might actually be better turning this off.
You can also find other settings for wp-config.php on the WordPress Codex page.
Are you a WordPress user? Do you have any experience optimizing your WordPress installation? Have you tried any of the methods listed above? Did they work for you? Have any methods other than the above that you’ve tried?