Apr
7
2009

WordPress Optimizing – DB Cache Plugin Performance Review

Share
Email

DB Cache is a new WordPress plugin that is aimed at increasing site performance by caching queries sent to the database.

The concept is great, however the WordPress blogs that will benefit from this plugin are of a very slim margin. Which is why I’m shocked its being rated so highly on WordPress.org.

A Common Complaint

It slows page load time down. Its been mentioned more than a few times on the Wordpress support thread.

The cause of this is because each query result is stored as a serialized chunk of data in a file. If you have an average blog (10-15 plugins installed) You’re probably pushing 40-60 queries per page (though it really depends what plugins). DB Cache seems to be able to cache about 95% of those 40-60 queries.

Each time an individual query is included back into the PHP script, it has to go through a process of checks:

  • Checking to see if a file exists.
  • Create a new one if not.
  • Pull the existing one into place and unserialize the data so it can be used.

The flaw in this method of caching comes in the 3rd point (while reading the files). They can be just as expensive if not more expensive than most of the queries being sent to your database because each one is a separate request to the server.

By the time you open a file, read it, and then still have to run your code on the data provided… You might as well just used your database and had the results of your page fully up to date.

A simple SELECT statement is often quicker than sending another request to your server for a file. And, the majority of queries within the core of WordPress are not all that taxing to a database. For example, when you use something like blog_info() in your header template, it is doing a simple select on the options table.

A Use for DB Cache

DB Cache is still a useful concept, but one that I would only use if you maintain a site that has a lot of “expensive” queries. And by expensive I mean the ones that are doing multiple table JOINS, Lengthy WHERE’s and ORDERBY calls in their syntax.

How do you know if your site needs it? WP Pear Debug is a great debug tool for this. Use that to take a look at some of the queries being executed on your pages.

Another case in which it might help is if your database server and web server are separate. If your database is taking a pounding from other applications, using DB cache will take stress off of it and instead. Keep in mind, this is just transferring the workload to your local machine.

To quote Otto42 in this support thread:

“Querying a database is probably going to be faster than looking for the same query in a filesystem manner. DB’s are optimized and efficent, filesystems have all sorts of caveats to cope with.”

An Additional Issue

If your site does warrant the use of DB cache from a couple expensive queries, your performance savings will probably just cancel out. Since a large portion of your queries are still going to be simplistic.

Ideally, this kind of caching is best ONLY on those expensive queries. If there was a way to specify what kind of queries were cached, this plugin would appeal to a lot more people. For now, It cant even help some of the more advanced WordPress development I work on.

Conclusions & Responses

I haven’t tested this to the extent that I’d like to. I also haven’t loaded this onto heavily trafficked site. If you test it on a site that receives a few thousand visitors a day, let us know your results. Maybe I’d be more willing to test it out in production on my sites if someone has positive results on a massive scale. Till then, super cache pulls a single cache of a page and still allows me to have dynamic output where I specify it.

If you comment on your test results please include how many plugin’s you are using and approximately how much traffic you receive daily.

Respond: Leave A Comment | Trackback URL

Entrupeners, Subscribe for the lastest tools, tips, and tutorials.


24 Responses to WordPress Optimizing – DB Cache Plugin Performance Review

  1. yeh DB cache is important but only for a small number of wordpress sites . According to me 90% of them don’t have much complicated queries

  2. I’d say they all have a few complex queries because everyone uses plugins. WordPress.org should have a rating for “plugin efficiency”. Out of the box, wordpress is pretty efficient. It just does a lot of simple queries.

    At some point, rolling up a lot of small queries into one larger one is good to limit the amount of connections going to the DB. But, we trade that for flexibility of the app.

  3. My only concern here is that I’ve heard these cause trouble with ads you place on your site. Does this PURELY cache the posts or the entire page?

  4. It depends how the plugin works. Both caching systems could mess things up.

    DB Cache might display the same set(s) of ads from page to page if the display is query based for the adsoftware. If its javascript or php based, then it wont.

    Super Cache will cache the entire page unless you tell it to omit certain plugins. This is easier said than done since documentation is a bit lacking on it last time I checked. Its also not easily done unless you’re willing to learn a bit of PHP. Thus its not common, but is possible. For me, its my ideal solution right now.

  5. Awxus

    A few complex queries, wordpress works fine for me, It just does a lot of small queries into one larger one is good to limit the amount of connections going to the Data Base, I’ve heard these cause trouble with ads you place on your site

  6. oh..that cashe..i had many problems with it…then just to avoid to apply it

  7. Rob, how much does this plugin show down the load time?

  8. I’m with rufman. Can you go into any details as to how this affects your load times? I want to make sure it’s worth the investment before trying it out.

  9. I also wanted to know about plugin load time

  10. It is really expensive, but it so worth it if the owner really needs DBCache.

  11. I’d think that only a small percentage of sites would need this, right?

    I mean the average blogger with less than a hundred visitors a day is hardly going to run into database overload problems, are they?

  12. DB cache really helps! but sometimes it would always depend on your plugins and how it works!

  13. @remote data backup – Correct. Based on my findings, its pretty rare that anyone would gain benefit from DB Cache.

  14. DB Cache seems to be a good plug in, but as you mentioned the real problem comes when reading the files.

  15. Vito Botta

    Quickly testing it right now, and have my doubts about its usefulness.

    When I read the descriptions given for these two plugins by their authors, after having tried both, I couldn’t stress enough my surprise.

    The author of Super Cache says: “Very fast caching plugin for WordPress”.
    The author of DB Cache says: “The fastest cache engine for WordPress”.

    So if one has already been happily using Super Cache for a while, would think: “wow! I gotta try this right now!”
    Unfortunately, my first impressions are that many would be disappointed quite a lot.

    I just ran a few quick tests on a new blog I am working on, and while – with DB Cache on, Super Cache off – the website already seemed to run slower, it is the Apache Bench results that concern me.

    I tried a simple “ab -n 1000″ towards the home of my blog, and these are the results:

    (please note that I am using quite many, but useful, plugins)

    with Super Cache: ~1600 requests/sec (numbers tend to grow with Super Cache, the more you try)

    with DB Cache: ~1.5 requests/sec.

    Please note that I haven’t even tried with the -c parameter! (concurrency level)

    Now, if I am missing something I would appreciate if somebody sheds a little light on this. If I am not, I would then suppose

    - that this plugin is overrated a lot and this is another confirmation that the plugin rating on WordPress’ repository is meaningless
    - that the author should have been more careful with the wording for the description..
    - that people should test everything themselves rather than believing whatever others say
    - that we’d better keep Super Cache on :D

    I wouldn’t want to run this plugin instead of Super Cache, if I think I might get dugged/slashdotted :D
    But again, if I am missing something, please let me know.

  16. Great info Vito Votta, pretty much the conclusions that I’ve reached.

    Did you by chance do a baseline test without either of them activated?
    What are your server specs?

    Wordpress ratings allow you to see what functionality people are trending after. Weather or not the plugin is efficient is another story. Being a PHP developer myself, I would agree, there are a lot of performance gains to be made in many plugins. As well as with WordPress in general. Some of it is just what to do/not to do and good practice etc.

    Wordpress 2.8 appears to be focusing partly on performance improvements. Looking forward to that.

  17. This is a tough one because there are so many different things that could be causing this. The first thing you can try is disabling some plugins, especially if you have any very complex ones (ones that connect to other sites, process extensive data etc).

  18. Slowing down? Doesn’t affect me alot actually.

  19. All plugins take away a bit from your loading speed. And while 1 or 2 are barely noticable, 40 or 50 plugins will make your site so slow that noone will even consider using it.

  20. I like this plugin. It did help with speed a lot more than I expected.

    -Jay

  21. I’ve been using the WP Super Cache plug-in on my blog for a while. I’m quite happy with it, although I doubt my website gets enough traffic to really need it.

  22. When it comes to a blog, a full page cache makes a lot more sense than a query cache. Plus, if you’re on a VPS or a dedicated server, reimplementing the query cache with a file system plugin isn’t very smart. MySQL has a query cache built in that you can enable; it’ll cache the results of those “big queries” in memory.

  23. Thanks for the great post. I have some problem with my blog and I need to find a solution to optimize it as much as possible. I will try this plugin.
    I see that you know what are you talking about so maybe you will write some article about optimizing wordpress and suggest some more plugins :)

Leave a Reply

Custom Theme by Rob Malon | Content & Design © 2010 - RobMalon.Com - Chicago, Illinois