I’ve been working with a plugin that was mentioned on the wp-hackers list last week, called debug queries , to optimize the performance on some of my sites, including this one. The plugin was pretty easy to use, and I’ve improved a bit on it. I’ve sent the patch to Frank, who authored the original plugin, and he was kind enough to immediately update the plugin. When you’re logged in as an admin, this plugin now shows the following info in an HTML comment tag in the footer of your pages: the query that was executed the time it took to execute that query the function path that led to this query, with the last function being the most likely to have created the query I’ve written down some of the things I encountered that you may encounter as well are the following: Empty options A lot of WordPress internal settings and plugin settings are stored in the options table. Values in this table take two forms: those which are autoloaded (which is the default) and those which are not. One of the first queries to the database that WordPress does once it starts loading a page, is the query that loads all options with autoload set to “yes”. Hence, any call the an option after that, that happens on multiple pages, is weird. So when I saw this type of query happen a lot: SELECT option_value FROM wp_options WHERE option_name = ‘headspace_global’ LIMIT 1 I was wondering what was happening. It turned out that that headspace_global option simply didn’t exist, so it can’t be autoloaded. This wasn’t happening with just this option, but with several options. The solution is pretty simple: just add the option as an empty option to your database. This might break some plugins though, and if it does, you should contact the plugin author… This is actually something plugin authors have to take note of: doing a get_option to check whether a certain option is set or not, is actually more expensive than just setting the option and leaving it empty… Adding an option to the database is done like this in your MySQL database: INSERT INTO wp_options ( option_id ,

View post:
Optimizing WordPress database performance



blog9192




April 4, 2009
I haven’t used this plugin for optimization, however I wonder how much, percentage-wise, WP calls the DB when using something like WP Supercache. Would “most users” need to optimize the DB in such a way?
April 4, 2009
I hadn’t played much with database. Last time I had terrible performance issues I thought that was DB-related. Turned out one “wise” plugin developer completely disabled Magpie cache for some obscure reason.
Pulling four feeds on each page load shot performance dead.
April 4, 2009
Thanks for the hints and tips. I also use YARPP and can see it being quite resource intensive, but it also does a great job.
I’d be interested in hearing of any other “related posts” plugins you find that do an equally good job but use less resources.
How many plugins are too many? No doubt the more plugins you use, the slower your performance will be.. and of course we can’t guarantee the code quality or optimisation of most of them.