Reputation: 613
I have such a query:
SELECT city.id, city.country_id, localization.lang , localization.name, ... some other fields ...
FROM city city
LEFT OUTER JOIN city_localization localization ON ( localization.city_id = city.id )
WHERE city.country_id = '196' AND localization.lang = 'en'
ORDER BY localization.name
"city" table schema:
"city_localization" table schema:
Explain output:
How can I avoid using filesort and temporary?
Upvotes: 0
Views: 300
Reputation: 1357
You'll need to create an index for localization.city_id
and another one for localization.name
(you currently have one that also includes localization.lang
).
If you are retrieving a lot of rows you might want to remove city.country_id
and localization.lang
from your select, after all you already have those values.
Upvotes: 1