Hi everyone,

While trying out Rails 3 for one of my applications, I have been bitten by the 
following.

When doing a calculation such as .count on has_many associations that use 
:include => some_model, it appears column definitions are not cached. It's not 
cached when config.cache_classes = true, or even in the same request. This 
causes pretty serious performance issues, because retrieving column definitions 
this often is expensive.

A short example:

class Article < ActiveRecord::Base
  has_many :comments, :include => :author
end

class Comment < ActiveRecord::Base
  belongs_to :author
end

class Author < ActiveRecord::Base
end

Article.last.comments.count # Retrieves column definitions from db every single 
time.


Attached to this e-mail is a patch with a failing test. I don't know if there 
are other kinds of queries that suffer from the same problem.

I would also be happy to write a patch that fixes the problem, but so far I'm 
having trouble understanding where the responsibility of caching the column 
definitions should be exactly (or even figuring out where the column 
definitions are cached right now). Any help or suggestions on how to tackle 
this problem are most welcome.

Thank you!

Kind regards,

Rolf Timmermans

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Attachment: 0001-Added-failing-test-for-caching-of-column-information.patch
Description: Binary data

Reply via email to