What is peformance gain of using counter_cache?

Hi,

I am wondering what is the peformance gain for using counter_cache?

Simple counter_cache setup:

class Comment
belongs_to :post, :counter_cache => true
end

class Post
has_many :commments
end

So, the ‘post’ table will have a column called ‘comments_count’.

I’m trying to see if using counter_cache is worth it given the extra
table or even column and extra inserts.

Thanks.

Truong-An.

counter_cache can make a big performance difference when you have a lot
of rows.

Joe