Skip to content

Instantly share code, notes, and snippets.

@kbaum
Created December 10, 2013 23:34
Show Gist options
  • Save kbaum/7902365 to your computer and use it in GitHub Desktop.
Save kbaum/7902365 to your computer and use it in GitHub Desktop.
Eager load
(15.0ms) SELECT "spaces"."property_id" FROM "spaces" INNER JOIN "properties" ON "properties"."id" = "spaces"."property_id" LEFT OUTER JOIN "user_properties" ON "user_properties"."property_id" = "properties"."id" LEFT OUTER JOIN "user_spaces" ON "user_spaces"."space_id" = "spaces"."id" WHERE ((user_spaces.user_id = 2023 and spaces.lease_type = 'sublease') or (user_properties.user_id = 2023 and spaces.lease_type = 'direct')) AND (spaces.status!='removed') ORDER BY "spaces"."status", "spaces"."id"
Property Load (9.3ms) SELECT distinct properties.* FROM "properties" LEFT OUTER JOIN "user_properties" ON "user_properties"."property_id" = "properties"."id" LEFT OUTER JOIN "spaces" ON "spaces"."property_id" = "properties"."id" AND spaces.status != 'removed' LEFT OUTER JOIN "user_spaces" ON "user_spaces"."space_id" = "spaces"."id" WHERE "properties"."id" IN (142, 143, 207, 208, 214, 304, 297, 305, 349, 351, 352, 353, 453, 454, 456, 457, 459, 461, 482, 483, 490, 508, 534, 536, 567, 596, 597, 598, 622, 621, 665, 670, 707, 710, 739, 740, 797, 801, 803, 350, 531, 659, 660, 661, 662, 667, 669, 666, 668, 858, 915, 987, 982, 983, 984, 993, 994, 995, 975, 968, 990, 989, 964, 966, 967, 997, 985, 977, 971, 1002, 1003, 1004) AND (user_properties.user_id = 2023 or user_spaces.user_id = 2023) ORDER BY "properties"."status", "properties"."id" LIMIT 10 OFFSET 0
Space Load (1.7ms) SELECT "spaces".* FROM "spaces" WHERE "spaces"."property_id" IN (142, 143, 207, 208, 214, 297, 304, 305, 349, 350) AND (spaces.status != 'removed') ORDER BY position
City Load (0.8ms) SELECT "cities".* FROM "cities" WHERE "cities"."id" IN (41598, 41811, 41613, 41620, 41712)
Submarket Load (0.3ms) SELECT "submarkets".* FROM "submarkets" WHERE "submarkets"."id" IN (59, 60)
PropertyPhoto Load (0.6ms) SELECT "photos".* FROM "photos" WHERE "photos"."type" IN ('PropertyPhoto') AND "photos"."imageable_type" = 'Property' AND "photos"."imageable_id" IN (142, 143, 207, 208, 214, 297, 304, 305, 349, 350) ORDER BY "photos"."position"
PropertyVideo Load (0.6ms) SELECT "property_videos".* FROM "property_videos" WHERE "property_videos"."property_id" IN (142, 143, 207, 208, 214, 297, 304, 305, 349, 350)
Video Load (0.4ms) SELECT "videos".* FROM "videos" WHERE "videos"."id" IN (4379, 2912, 2913, 2914, 2915, 2916, 4380, 4422, 4423, 4427, 4466, 4484, 2312, 2313, 2314, 2315, 2316, 4485)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment