search for: total_vot

Displaying 2 results from an estimated 2 matches for "total_vot".

Did you mean: total_vqs
2007 Nov 30
2
find_by_sql preformance problems when ordering data
...process to sort and publish on the top 10 items in rails, which has gotten the delay down to about 5-8 seconds. Video.find_by_sql("select videos.*, (select count(*) from votes where video_id = videos.id and value = 1) - (select count(*) from votes where video_id = videos.id and value = -1) AS total_votes from videos ORDER BY total_votes DESC LIMIT 10") Is there some better way to order these results that wouldn''t be more resource intensive. I was looking around to see if maybe my total_votes alias could be clearly defined as an integer, which I though might help speed up the orde...
2009 Mar 11
12
Eager loading comments associated with user submissions.
Hey everyone, I am working on an application that allows users to submit articles, and also comment on those articles. Pretty much exactly like Digg. Everything works fine except that when there are a lot of comments there are a lot of database queries to both fetch the comments and the users who posted those comments. I have used eager loading in other parts of my application to reduce the