Skip to content

Instantly share code, notes, and snippets.

@pacoguzman
Created December 12, 2009 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacoguzman/254993 to your computer and use it in GitHub Desktop.
Save pacoguzman/254993 to your computer and use it in GitHub Desktop.
Without using preload associations
# Dado una variable Profile profile con datos de ejemplo
profile.graffities.all(:include => [{:user => :profile}, {:replys => {:user => :profile}}])
Comment Load (0.2ms) SELECT * FROM `comments` WHERE (`comments`.commentable_id = 3 AND `comments`.commentable_type = 'Profile' AND (parent_id IS NULL)) LIMIT 1
Comment Load (0.1ms) SELECT * FROM `comments` WHERE (`comments`.parent_id = 2) ORDER BY created_at DESC
User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
Profile Load (0.2ms) SELECT `profiles`.* FROM `profiles` WHERE (`profiles`.user_id = 1)
Comment Load (0.2ms) SELECT `comments`.* FROM `comments` WHERE (`comments`.parent_id = 4) ORDER BY created_at ASC
User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` IN (1,3))
Profile Load (0.2ms) SELECT `profiles`.* FROM `profiles` WHERE (`profiles`.user_id IN (1,3))
+----+----------------+------------------+-------+---------------------+---------+---------+-----------+-----+-----+-------------------------+-------------------------+
| id | commentable_id | commentable_type | title | body | subject | user_id | parent_id | lft | rgt | created_at | updated_at |
+----+----------------+------------------+-------+---------------------+---------+---------+-----------+-----+-----+-------------------------+-------------------------+
| 4 | 3 | Profile | | Esto es un graffity | | 1 | 2 | 2 | 7 | 2009-12-12 17:35:54 UTC | 2009-12-12 17:35:54 UTC |
+----+----------------+------------------+-------+---------------------+---------+---------+-----------+-----+-----+-------------------------+-------------------------+
1 row in set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment