Hello guys.

In the method [1] `ids_reader` at 
`ActiveRecord::Associations::CollectionAssociation` I think we can do a 
performance improvement when we are dealing with has_many through 
associations.

class User < ActiveRecord::Base
>   has_many :badge_items
>   has_many :badges, through: :badge_items
> end


In the scenario above when we do something like `User#badge_ids` the query 
called is:

SELECT "badges".id 
> FROM   "badges" 
>        inner join "badge_items" 
>                ON "badges"."id" = "badge_items"."badge_id" 
> WHERE  "badge_items"."user_id" = 1


But would be great if we have this instead:

SELECT "badge_items"."badge_id" 
> FROM   "badge_items" 
> WHERE  "badge_items"."user_id" = 1


Is this in your plans already? Can I help with anything about it?


[1] 
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/collection_association.rb#L59

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to