GD Star Rating 1.5.1

Mon, Jul 6, 2009

Release News

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.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Reddit
  • Technorati
  • Twitter
  • Sphinn
  • Blogosphere News
  • Netvibes
  • DZone
  • Fleck
  • E-mail this story to a friend!
, , , , , , ,

40 Responses to “GD Star Rating 1.5.1”

  1. Cruelty Says:

    Hope this will work for me, man. And yeah, first Post! :p

    Reply

  2. Cruelty Says:

    Unfortunally it does not work. The Problem:

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/kunden/webs/mircdevil/koelnblogger/wp-content/plugins/gd-star-rating/code/t2/render.php on line 495

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/kunden/webs/mircdevil/koelnblogger/wp-content/plugins/gd-star-rating/code/t2/render.php on line 500

    Any Ideas? Wordpress MU with Buddypress trying to install the Plugin in the Mainblog.

    Reply

    • MillaN Says:

      WPMU/BuddyPress are not supported at the moment, and I can’t help you with this problem right now. I know that some people managed to use it, but I myself haven’t tried it once with WPMU. If you check the latest development roadmap you can see that I plan to add full WPMU support in the next few months.

      Reply

  3. Melissa Says:

    I can’t wait to try this out. Thank you for your hard work.

    Reply

  4. Cruelty Says:

    Oh man, that’s … yeah, however, Thanks anyway. But see? This people did manage it, and they don’t tell us how… How can some be so selfish?

    Okay, as I said, thanks anyway.

    Reply

    • MillaN Says:

      As far as I know making plugin work on WPMU requires some small changes to plugin, but I don’t know exactly what. I will start to work on that very soon, but I am guessing that it will take some time do solve all the problems. Good news is that WPMU will soon be gone and merged with regular WP, and that will make things much easier to handle.

      Reply

  5. Melissa Says:

    WOW excellent job! You weren’t kidding that it’s easy to integrate. I will be passing this plugin on to others.

    Thank you again for all your hard work.

    Even the user guide is easy to follow.

    Reply

  6. Melissa Says:

    Really quick question…I added the ratings to my post and i can hover over them and see them add/subtract stars, but when I click on it it won’t register…

    Reply

  7. MillaN Says:

    Here are results from testing plugin on my Dev4Press website:

    Single post with 18 comments, using standard comment rating. Without GD Star Rating 135 queries executed. With GD Star Rating 1.5.0, number of queries was 207. And now with GD Star Rating 1.5.1 only 142 queries are executed. So, initially plugin added 72 queries, with new version needs only 7, and that’s 90% reduction.

    If you have post with 100 comments, with old version of the plugin you would need some 450 additional queries, with new version, again only 7. All data is prefetched and cached no matter how many comments are to be rendered.

    Reply

  8. darren Says:

    I’m running the plugin on MU and it works fine!

    Reply

  9. r4ibOm Says:

    An error appeared when I upgrade :Warning: Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/veryhardplayer/www/wp-content/plugins/gd-star-rating/gd-star-rating.php on line 1587. what can be? help. pls

    Reply

  10. Scorpio84 Says:

    Hi Milan
    - Deleting a comment still doesn’t delete the corresponding star rating.
    - Secondly, in your category management post screenshot – below the table there is articles setting pane and below that comment setting pane. But for me it just shows article setting pane. (In settings – comment rating is unchecked but comment review rating is checked)so am not sure if the behavior is correct

    Reply

  11. Gabriel Yap Says:

    I am getting this shown on my post when i upgraded to 1.5.1
    Please help:

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') group by p.comment_ID' at line 1]
    select p.comment_ID as ID, count(l.record_id) as counter from wp_comments p left join wp_gdsr_moderate l on l.id = p.comment_ID and l.vote_type = ‘comment’ and l.user_id = 1 where p.comment_ID in () group by p.comment_ID

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') group by p.comment_ID' at line 1]
    select p.comment_ID as ID, count(l.record_id) as counter from wp_comments p left join wp_gdsr_votes_log l on l.id = p.comment_ID and l.vote_type = ‘comment’ and l.user_id = 1 where p.comment_ID in () group by p.comment_ID

    Reply

  12. Wolfgang M. Says:

    Hi,

    there seems to be an incompatibility with IE 8. Rating doesn’t work in standard neither in “compatibility”-Mode on my blog. With Firefox, everything works fine.

    Reply

    • MillaN Says:

      In most cases everything is fine in all browsers. Your problem is most likely caused by your theme. No matter how hard I try to make CSS isolated, there is always something in the theme CSS that can interfear.

      Reply

  13. MillaN Says:

    All error reports will be checked, and I will fix these errors ASAP. New version either tonight or tomorrow.

    Reply

  14. Wolfgang M. Says:

    Thx for your immediate answer!! Great plugin and great support, too!! So I will check theme-issues.

    Reply

  15. dennis Says:

    Im going to complain about this again, because I think your answer isn’t reasonable.

    If a post has a review, I don’t see any reason why when you edit the post the code can’t be smart enough to say “hey, this has a restaurant review, use that template instead of the last one!”

    I understand that you can’t know what a new post is, or why you display the “last” review template if the current post has no review, but its easy enough to see if a post has an existing entry. This is what happens:

    I create a review with the “hotel” template.
    I edit an existing restaurant review. It displays the hotel template.
    I then have to change the dropdown, and publish again to gain access to the rest review.
    If I only edit the text and fail to reset the template, I get a blank hotel review in the database.

    Its just wrong.

    Reply

    • MillaN Says:

      As I said before, this is very complicated to be generalized like that, and in most cases is not as simple as you say it is.

      I know that it can be done better, and at one point all that will be replaced with ajax but that will require some 2-3 days of my time, a time I simply don’t have. And since you are so far the only one who had problems with that, this is not high on my priorities list.

      Reply

  16. Gabriel Yap Says:

    Do we know how do we revert back to the older version? which files must I keep or replace?

    Reply

  17. Diozilla Says:

    In GD Star Rating options –> Multi i have this error after creation of a multi’s vote:

    Warning: cannot yet handle MBCS in html_entity_decode()! in mysite/wordpress/wp-content/plugins/gd-star-rating/options/multis/editor.php on line 35

    The multi funcion works but i can’t modify name and others values after creation.

    Anyway, amazing plugin.

    Reply

  18. Tim Southernwood Says:

    Hey MillaN,

    Just wanted to post a great big THANK YOU>!

    I just updated to the latest version, and everything works fine. The export function performs exactly as required!

    It’s a great addition to our awards blog, just the thing we needed to collect and track votes, and we might even use it on the comments section.
    We love blogging..and this is a tremendous (AND FREE) tool for all bloggers!

    THANK YOU THANK YOU!

    Tim
    Awarding the best Blogs online
    Blognetawards.com

    Reply

  19. J. Millington Says:

    ok, so i tried installing this thru WP plugin manager but just hung there upon extract, so i manually dl’d and installed, but im getting a “500 Internal server error” with no other details except “…try again later” so i tried deleting and installing 1.4.7- no luck there either. on top of that the “500 error” message now appears in a new, blank page instead of within the plugin manager (im using WP2.8) as it did upon first install (of 1.5.1).

    also, when i hit the “edit” link in the plugin manager for the gd-star-rating, nothing happens; the link seems to stop halfway through and leaves a half blank page instead of the plugin’s code.

    Reply

  20. Alex Says:

    Hi, MillaN

    I have a quick question :

    How can I get the Stars and Rating text in the same line (rating text after Stars)

    Thanks

    Reply

Trackbacks/Pingbacks

Leave a Reply