Gabe Hollombe wrote:
> This arel query:
>
> Membership.where(:id => (Membership.select(:id).where(:user_id =>
> 1).project))
>
> Gives me this SQL:
>
> Membership Load (0.2ms) SELECT "memberships".* FROM "memberships" WHERE
> ("memberships"."id" IN (SELECT id FROM "memberships" WHERE
This is awesome. However, be careful using it with MySQL - you can get
some pretty funky (in a bad way) performance when mixing the IN operator
with a sub-select.
See http://bugs.mysql.com/bug.php?id=9090
-- James Healy <[email protected]> Fri, 22 Oct 2010 17:39:23 +1100
--
You received this message because you are subscribed to the Google Groups "Ruby
or Rails Oceania" 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/rails-oceania?hl=en.