Created
February 16, 2010 16:00
-
-
Save dstrelau/305616 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> EXPLAIN SELECT count(DISTINCT `competition_entries`.id) AS count_all FROM `competition_entries` LEFT OUTER JOIN `videos` ON `videos`.attachable_id = `competition_entries`.id AND `videos`.attachable_type = 'CompetitionEntry' LEFT OUTER JOIN `moderations` ON `moderations`.moderated_id = `competition_entries`.id AND `moderations`.moderated_type = 'CompetitionEntry' LEFT OUTER JOIN `users` ON `users`.id = `competition_entries`.user_id INNER JOIN `images` ON `images`.attachable_id = `competition_entries`.id AND `images`.attachable_type = 'CompetitionEntry' WHERE (moderations.state = 0) ; | |
+----+-------------+---------------------+--------+-----------------------------------------------------------------------+-----------------------------------+---------+--------------------------------------------------+------+-------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
+----+-------------+---------------------+--------+-----------------------------------------------------------------------+-----------------------------------+---------+--------------------------------------------------+------+-------------+ | |
| 1 | SIMPLE | images | ref | index_images_on_attachable_id,index_images_on_attachable_type | index_images_on_attachable_type | 768 | const | 13 | Using where | | |
| 1 | SIMPLE | moderations | ref | index_moderations_on_moderated_type,index_moderations_on_moderated_id | index_moderations_on_moderated_id | 5 | benetton_development.images.attachable_id | 1 | Using where | | |
| 1 | SIMPLE | competition_entries | eq_ref | PRIMARY | PRIMARY | 4 | benetton_development.images.attachable_id | 1 | | | |
| 1 | SIMPLE | videos | ref | index_videos_on_attachable_id,index_videos_on_attachable_type | index_videos_on_attachable_id | 5 | benetton_development.moderations.moderated_id | 1 | | | |
| 1 | SIMPLE | users | eq_ref | PRIMARY | PRIMARY | 4 | benetton_development.competition_entries.user_id | 1 | Using index | | |
+----+-------------+---------------------+--------+-----------------------------------------------------------------------+-----------------------------------+---------+--------------------------------------------------+------+-------------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> EXPLAIN SELECT count(DISTINCT `competition_entries`.id) AS count_all FROM `competition_entries` LEFT OUTER JOIN `videos` ON `videos`.attachable_id = `competition_entries`.id AND `videos`.attachable_type = 'CompetitionEntry' LEFT OUTER JOIN `moderations` ON `moderations`.moderated_id = `competition_entries`.id AND `moderations`.moderated_type = 'CompetitionEntry' LEFT OUTER JOIN `users` ON `users`.id = `competition_entries`.user_id INNER JOIN `images` ON `images`.attachable_id = `competition_entries`.id AND `images`.attachable_type = 'CompetitionEntry' WHERE (moderations.state = 0) ; | |
+----+-------------+---------------------+--------+--------------------------------------------------------------------------------------------------+-----------------------------------+---------+-------------------------------------------------+-------+-------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
+----+-------------+---------------------+--------+--------------------------------------------------------------------------------------------------+-----------------------------------+---------+-------------------------------------------------+-------+-------------+ | |
| 1 | SIMPLE | images | ref | index_images_on_attachable_id,index_images_on_attachable_type | index_images_on_attachable_type | 768 | const | 57460 | Using where | | |
| 1 | SIMPLE | moderations | ref | index_moderations_on_moderated_type,index_moderations_on_moderated_id,index_moderations_on_state | index_moderations_on_moderated_id | 5 | benetton_production.images.attachable_id | 1 | Using where | | |
| 1 | SIMPLE | competition_entries | eq_ref | PRIMARY | PRIMARY | 4 | benetton_production.images.attachable_id | 1 | | | |
| 1 | SIMPLE | videos | ref | index_videos_on_attachable_id,index_videos_on_attachable_type | index_videos_on_attachable_id | 5 | benetton_production.images.attachable_id | 1 | | | |
| 1 | SIMPLE | users | eq_ref | PRIMARY | PRIMARY | 4 | benetton_production.competition_entries.user_id | 1 | Using index | | |
+----+-------------+---------------------+--------+--------------------------------------------------------------------------------------------------+-----------------------------------+---------+-------------------------------------------------+-------+-------------+ | |
5 rows in set (0.01 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment