Derived Table Merge Optimization
Background
SELECT *
FROM
(SELECT * FROM City WHERE Population > 10*1000) AS big_city
WHERE
big_city.Country='DEU'mysql> EXPLAIN SELECT * FROM (SELECT * FROM City WHERE Population > 1*1000)
AS big_city WHERE big_city.Country='DEU' ;
+----+-------------+------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+------+---------------+------+---------+------+------+-------------+
| 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 4068 | Using where |
| 2 | DERIVED | City | ALL | Population | NULL | NULL | NULL | 4079 | Using where |
+----+-------------+------------+------+---------------+------+---------+------+------+-------------+
2 rows in set (0.60 sec)
Derived table merge in action
Factsheet
See Also
Last updated
Was this helpful?

