EXPLAIN SELECT City.Name,Country.Name,City.Population FROM City, Country
WHERE City.CountryCode = Country.Code AND City.Population > 8000000
ORDER BY City.Population;
+---------+--------+---------------+---------+---------+------------------+------+-----------------------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +---------+--------+---------------+---------+---------+------------------+------+-----------------------------+ | City | ALL | NULL | NULL | NULL | NULL | 4079 | Using where; Using filesort | | Country | eq_ref | PRIMARY | PRIMARY | 3 | City.CountryCode | 1 | | +---------+--------+---------------+---------+---------+------------------+------+-----------------------------+
ALTER TABLE City ADD INDEX (population);
+---------+--------+---------------+------------+---------+------------------+------+-------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +---------+--------+---------------+------------+---------+------------------+------+-------------+ | City | range | Population | Population | 4 | NULL | 78 | Using where | | Country | eq_ref | PRIMARY | PRIMARY | 3 | City.CountryCode | 1 | | +---------+--------+---------------+------------+---------+------------------+------+-------------+