#613 ✓resolved
Lawrence Pit

post.comments.count performs 2 queries instead of 1

Reported by Lawrence Pit | October 24th, 2008 @ 06:55 AM

When I try post.comments.count it executes two queries:

 ~ SELECT `id`, `created_at`, `updated_at`, `description`, `post_id`, `user_id` FROM `comments` WHERE (`post_id` IN (1)) ORDER BY `id`

 ~ SELECT COUNT(*) FROM `comments` WHERE (`post_id` = 1) AND (`id` IN (1,2,3,4))

=> 4

It's one too many imho, and the count is a bit weird as well. I expect only this query:

  SELECT COUNT(*) FROM comments WHERE post_id = 1

PS. Comment is :remixable, and Post remix n, :comments

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket