Created
August 1, 2014 17:22
-
-
Save spetrunia/25335f227ffa2c6dee0c 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
BAD: | |
MariaDB [csc435]> explain extended SELECT ( SELECT t2.start FROM t2 WHERE t1.t1_id = t2.t1_id ORDER BY t2.t2_id LIMIT 1 ) AS first_start FROM t1; | |
+------+--------------------+-------+-------+---------------+---------+---------+------+------+----------+-------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | | |
+------+--------------------+-------+-------+---------------+---------+---------+------+------+----------+-------------+ | |
| 1 | PRIMARY | t1 | index | NULL | PRIMARY | 4 | NULL | 9999 | 100.00 | Using index | | |
| 2 | DEPENDENT SUBQUERY | t2 | index | t1_id | PRIMARY | 4 | NULL | 1 | 100.00 | Using where | | |
+------+--------------------+-------+-------+---------------+---------+---------+------+------+----------+-------------+ | |
2 rows in set, 2 warnings (0.01 sec) | |
GOOD: | |
MariaDB [csc435]> explain extended SELECT ( SELECT t2.start FROM t2 WHERE t1.t1_id = t2.t1_id ORDER BY t2.t2_id LIMIT 1 ) AS first_start FROM t1; | |
+------+--------------------+-------+-------+---------------+---------+---------+-----------------+------+----------+-------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | | |
+------+--------------------+-------+-------+---------------+---------+---------+-----------------+------+----------+-------------+ | |
| 1 | PRIMARY | t1 | index | NULL | PRIMARY | 4 | NULL | 9999 | 100.00 | Using index | | |
| 2 | DEPENDENT SUBQUERY | t2 | ref | t1_id | t1_id | 5 | csc435.t1.t1_id | 1 | 100.00 | Using where | | |
+------+--------------------+-------+-------+---------------+---------+---------+-----------------+------+----------+-------------+ | |
2 rows in set, 2 warnings (0.00 sec) | |
GOOD is: rows[2].key=t1_id. | |
BAD is: rows[2].key=PRIMARY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment