Search code examples
sqlruby-on-railsruby-on-rails-3votingreddit

How does Reddit sort query their database for "what's hot"?


I want to implement something similar on my site.

Submissions have up_votes and down_votes. I'd imagine reddit does some sort of database query that takes into account the up_votes vs. total_votes and maybe factors in # of views and # of comments and limits it all by a specified time period.

What sort of query do you imagine they use to determine this?

Thanks!


Solution

    • For links, they use a formula based on upvotes minus downvotes combined with age of the post.
    • For comments, they use a confidence sort based on a Wilson score interval.

    This blog post describes both formulas in greater detail.