Count by group optimization.

Hello RoR people,

First time here.

I have a question about calculations in rails.

For example i have two tables:

categories   id   name

and questions:   id   category_id   name

How I can count questions in each category?

Please don't give me recepies like: :include => [:questions] or something like: @categories.each { |c| c.questions.count } Because those methods is not so much optimized, to run them on a production server.

Thank you, Dmitry for Estonia.