Slide 13
Slide 13 text
ActiveRecord::QueryMethods#preload
plays = Play.preload(:actors).limit(10)
plays.each do |play|
puts play.actors.map(&:name)
end
SELECT "plays".* FROM "plays" LIMIT 10
SELECT "play_actors".* FROM "play_actors"
WHERE "play_actors"."play_id" IN (1, 2, 3, ...)
SELECT "actors".* FROM "actors"
WHERE "actors"."id" IN (1, 2, 3, ...)
3 ͭʹ͚ΒΕͨΫΤϦ͕ൃߦ͞ΕΔ