Skip to content

Instantly share code, notes, and snippets.

@cchandler
Created September 23, 2009 08:06
Show Gist options
  • Save cchandler/191823 to your computer and use it in GitHub Desktop.
Save cchandler/191823 to your computer and use it in GitHub Desktop.
mysql> explain SELECT `groups`.* FROM `groups` INNER JOIN `memberships` ON `groups`.id = `memberships`.group_id WHERE ((`memberships`.user_id = 653));
+----+-------------+-------------+--------+------------------------+------------+---------+----------------------------------------------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+------------------------+------------+---------+----------------------------------------------+------+--------------------------+
| 1 | SIMPLE | memberships | ref | test_index,test_index1 | test_index | 5 | const | 1 | Using where; Using index |
| 1 | SIMPLE | groups | eq_ref | PRIMARY | PRIMARY | 4 | simplewants_development.memberships.group_id | 1 | |
+----+-------------+-------------+--------+------------------------+------------+---------+----------------------------------------------+------+--------------------------+
2 rows in set (0.00 sec)
mysql> explain SELECT `users`.* FROM `users` INNER JOIN `memberships` ON `users`.id = `memberships`.user_id WHERE ((`memberships`.group_id = 449));
+----+-------------+-------------+--------+------------------------+-------------+---------+---------------------------------------------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+------------------------+-------------+---------+---------------------------------------------+------+--------------------------+
| 1 | SIMPLE | memberships | ref | test_index,test_index1 | test_index1 | 5 | const | 2 | Using where; Using index |
| 1 | SIMPLE | users | eq_ref | PRIMARY | PRIMARY | 4 | simplewants_development.memberships.user_id | 1 | |
+----+-------------+-------------+--------+------------------------+-------------+---------+---------------------------------------------+------+--------------------------+
2 rows in set (0.01 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment