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