View Full Version : Efficient ways to make Rating scripts?

03-21-2010, 04:57 AM
So this has been bobbled up in my head for quite some time: What other ways are there to create an efficient rating script?

So here are the only ways I've thought of, visavi MySQL:
1) Constantly summing the ratings and dividing it by the total amount of ratings available in a table. This is, in my opinion, the slowest way to do things.
2) Have two fields in a table called ratingSum and totalRaters, where you can just do ratingSum/totalRaters. This is the faster way, but I think that it isn't as "nice"

What would be more efficient than #2?

03-21-2010, 05:39 AM
It depends on what you're rating.

I think #2 is the best way for something like books, or videos ...
Say you have a database full of books. Each row is one book.
If people were rating the books, it would be easiest to add the user's
rating to one field (sum), and then increment another field (qty - how many votes).

Now if you're comparing ratings between a whole table of items, instead of
rating each item separately, that might change things.

So, I guess you would have to analyze each situation differently, and you didn't
specify exacty what you're rating ... so I guess we'll never know.