Yavor Nikolov
2014-May-01 17:27 UTC
can preloading use just a single query per table (even if referenced multiple times)
Hi,
Let's take a look at the following example:
Visitor.preload(
{allowed_meals: [:meal]}
{meal_availabilities: [:meal]}
)
What happens is that Rails (I'm using version 4.1) is issuing several
queries to meals:
Meals Load ... SELECT * from meals where id in (1, 2, 3, 4, 5) # using
list of ids relevant for "allowed_meals"
Meals Load ... SELECT * from meals where id in (3, 4, 5, 6) # using
list of ids relevant for "meal_availabilities"
For performance reasons - it would be nice to issue just a single query
instead of above two, e.g.:
Meals Load ... SELECT * from meals where id in (1, 2, 3, 4, 5, 6)
Is that possible?
Regards,
Yavor
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/127a7594-4179-4e38-aaa5-47983496e3e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.