Subscribe via Feedburner Flickr Images Youtube Profile LinkedIn Profile
HostGator

GD Star Rating 1.5.1

Thumbnail for GD Star Rating 1.5.1

And now for something completely different. New version of GD Star Rating. I have finally completed very difficult task on optimizing the plugin and number of SQL queries executed. I wanted to include this in 1.5.0, but I needed few more days.

Depending on the theme, number of loops and other things, during the forming of the page, plugin makes a number of calls to the database. But that was not always done the best possible way. In many cases there were duplicate calls for getting the same templates, same check for the recorded votes and few more things that needed to be dealt with. Last 2 weeks I have been testing  all that, and I have found all the problems and I decided that best way to solve them is to use two methods: cache and prefetch.

Cache is used for templates, posts, comments and log checks. Prefetch is used for posts, comments and logs. So, if you have a front page with 10 posts, and you show standard rating for each post there, typically you need 4 queries per post: 2 for template, one to get rating data and one to check log for duplicated vote. For 10 posts that’s 40 queries on top of only 20 that WP needs for the whole page. Comments are in the similar state, but usually you can have 30-40 comments per page. Since (by default) all posts will use same template, instead for 20 queries for templates with need only 2, we save them to cache and use from there. And that cuts queries in half. Prefetch is done once the loop starts, and in one query we get data for all 10 posts at once, and in second query all 10 logs for these posts, cutting number of queries from starting 40 to 4 for the whole front page, making less then half a query per post. And saving over 90% on database access.

On single post you still need to execute all 4 queries, so nothing is gained, but single post has comments, and again with them we get 90% savings. When it comes to multi ratings they need an extra query for multi elements, but I have cleaned up some of the code, removing number of queries used for multi ratings. When I complete tests, in a typical situation, 1.5.1 executes up to 70% (yes, seventy percents) less queries than 1.5.0 and previous versions. Also, having to execute less SQL queries, this change reduced used memory for about 1MB.

As an interesting comparison, GD Star Rating now needs less queries for 10 posts than WP-PostRatings plugin. A lot of people didn’t want to replace WP-PostRatings with GD Star Rating because it was simpler, and that also caused that plugin to need less queries per page. Now that’s no longer case, and in most cases with all the features GD Star Rating has, it now needs very few queries to work.

If you use multiple loops and with them you show ratings in different places, than savings in your case can be even bigger. Anyway, there is not much to say, you simply need to upgrade to 1.5.1. It is very, very fast, with minimal impact to page loading performance and due to the all previous bug fixes during 1.4.x release history, very stable. But, if you find any problem you can safely go back to 1.5.0, and please report any problem you find.

GD Star Rating
loading...

Share this:

del.icio.us DiGG Google StumbleUpon Google Buzz Microsoft Live MiXX RSS PDF
GD Star Rating 1.5.1, 8.1 out of 10 based on 25 ratings

44 Responses to “GD Star Rating 1.5.1”

  1. Erin M. | July 13, 2009 at 8:10 PM

    Thank you SO VERY MUCH for this wonderful plugin. I know you’ve taken a lot of time to develop it and I wanted to let you know how much your effort is valued.

    GD Star Rating
    loading...
  2. Rash | July 16, 2009 at 11:35 AM

    Any chance the Multi Ratings will be able to be automatically be inserted in all posts? Like the standard ratings? I believe this is not currently possible is that right?

    and also an option to auto insert into comments?

    GD Star Rating
    loading...
    • MillaN | July 16, 2009 at 11:56 AM

      Well it is possible. Edit your multi set and set where you want it auto inserted. You can auto insert for all posts or on category basis. Multi ratings are only for posts not comments. Adding to comment form is possible, but multi rating added that way will be for the post, it’s for reviewing of the post contents. And even that integration must be done manually (WordPress restriction).

      GD Star Rating
      loading...
  3. Rash | July 16, 2009 at 12:11 PM

    Thanks for the quick response, how does one edit the multiset for auto insert in all posts?

    GD Star Rating
    loading...

Trackbacks/Pingbacks

  1. WordPress Plugin Releases for 07/08 | BlogBroker24-7 - July 8, 2009

    [...] GD Star Rating [...]

  2. EasySeo | WordPress Plugin Releases for 07/08 | SEO2Blog - July 8, 2009

    [...] GD Star Rating [...]

  3. WordPress Plugin Releases for 07/08 | The Cliffmaster - July 8, 2009

    [...] GD Star Rating [...]

Comments are closed.