Skip to content

Instantly share code, notes, and snippets.

@klochner
Created November 16, 2011 19:11
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 klochner/1371018 to your computer and use it in GitHub Desktop.
Save klochner/1371018 to your computer and use it in GitHub Desktop.
mysql> select count(*) from residents;
+----------+
| count(*) |
+----------+
| 601087 |
+----------+
1 row in set (0.21 sec)
mysql> select count(*) from users;
+----------+
| count(*) |
+----------+
| 48144 |
+----------+
1 row in set (0.03 sec)
mysql> explain SELECT `residents`.* FROM `residents` INNER JOIN `users` ON `users`.`id` = `residents`.`user_id` WHERE (users.id = 50713) LIMIT 1 ;
+----+-------------+-----------+-------+-------------------+-------------------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+-------+-------------------+-------------------+---------+-------+------+-------------+
| 1 | SIMPLE | users | const | PRIMARY | PRIMARY | 4 | const | 1 | Using index |
| 1 | SIMPLE | residents | ref | residents_by_user | residents_by_user | 5 | const | 1 | Using where |
+----+-------------+-----------+-------+-------------------+-------------------+---------+-------+------+-------------+
2 rows in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment