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
class Comment < ActiveRecord::Base
class Author < ActiveRecord::Base
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.