Hi, I just uploaded a Rails plugin that allows you to specify custom
SQL when doing a find with associations (AKA eager loading).
One of the problems I encountered when implementing the Chacha
Underground (http://underground.chacha.com) was being able to use
queries provided by the DBA to efficiently get all the informaion I
needed to render a page. In some cases, I needed to go two or three
associations deep in a model and the SQL generated by ActiveRecord was
either inadequate or lead to huge result sets. My solution was to
create a mixin that allowed my to specify a :finder_sql option to the
find method. In conjunction with the :column_mapping option, I could
then have full control of the queries generated and reduce the number
and overhead of the queries needed to render a page.
Please check out my blog entry on it for a fuller description:
http://kellogg-assoc.com/articles/2006/11/05/eager-finder-sql.
Gregg Kellogg