Advanced Active Record: Using Subqueries in Rails
pganalyze.com