0
我有這樣一個查詢:MySQL的提高查詢性能
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_localization」 表模式:
說明輸出:
如何避免使用filesort和臨時?
我不知道關於filesort和臨時的,但我注意到你過濾左連接的右側,用內連接取代它。應該在連接本身中過濾'city_localization':'LEFT OUTER JOIN city_localization localization ON(localization.city_id = city.id and localization.lang ='en')'。 – 2012-04-08 20:13:05