I've built a rating system for movies in MySQL, however the concern is that when my query sums up all the ratings and divides it, it might have to sum up millions and millions of records.
One solution I thought of was to basically cache the rating in memcached and only do the rating operation for items which are not used a lot. However even then for movies which are not being rated a lot if someone does go check the rating that query might take a long time if it has to calculate a lot of rows.
Another solution i thought of was to build a temporary table which is constantly updating the table, however what if the movie is being rated a lot and someone is trying to access it, INNODB i believe does row locking, so will this cause a deadlock or something in the long run?