ActiveRecord Changed :include Behavior?
August 12th, 2009
Just figured out that ActiveRecord 2.2 generates SQL for
Company.find(:all, :include => :people)as something like
SELECT * FROM company SELECT person.* FROM person WHERE person.id in (...)In 2.1.x, it used to generate SQL as something like
SELECT * FROM company LEFT OUTER JOIN person ON person.company_id = company.id
It seems for the sake of performance…the current statements return smaller data set. However, it could generate a very long SQL statement if you have lots of ‘people’ in this case, and thus spend longer to parse and execute.
And…WHEN did this change happen? I’m wondering…




Leave a Reply