Ruby on Rails
Thursday, May 1, 2014
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
-- 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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment