0
我發現,當我把下面的表的訂單,它導致查詢從0秒到3.5秒(這隻有100,000行)任何人都可以幫助我優化這個?優化SQL查詢 - 訂單造成緩慢
SELECT offer_id,
offer_cheapest_rental,
offer_cashback,
offer_offertext,
network_name,
merchant_image,
network_image,
tariff_contractlength,
offer_link,
tariff_freemins,
tariff_freetxts,
tariff_dataallowance,
offer_phonecost,
offer_offerental,
offer_monthlycost,
tariff_rental,
tariff_nicename,
tariff_name,
model_imagelarge,
model_popularity,
model_make,
model_name,
model_colour,
offer_freegift,
offer_clearance,
model_basename,
p.model_id as model_id,
type
FROM deals_temp d
INNER JOIN phones p ON d.model_id = p.model_id
INNER JOIN tariffs t ON d.tariff_id = t.tariff_id
INNER JOIN networks n ON d.network_id = n.network_id
INNER JOIN free_gift fg ON d.freegift_id = fg.freegift_id
INNER JOIN merchants m ON d.merchant_id = m.merchant_id
INNER JOIN type ty ON ty.type_id = d.type_id
ORDER BY deal_popularity DESC LIMIT 0,10
你對deal_popularity的指數?如果不是,那就是你的答案,儘管你當然應該期望排序後的查詢花費的時間比未排序的要長。 –
http://www.sitepoint.com/using-explain-to-write-better-mysql-queries/ –
在InnoDB中使用索引。 –