激起許多事情值得嘗試優化一個MySQL查詢連接7臺時?MySQL查詢優化
select trips.tripid as tripid
, stops.stopdescrption as "perron"
, DATE_FORMAT(segments.segmentstart, "%H:%i") as "time"
, DATE_FORMAT(trips.tripend, "%H:%i") as "arrival"
, UPPER(routes.routepublicidentifier) as "lijn"
, plcend.placedescrption as "destination"
from calendar
join trips on calendar.vsid=trips.vsid
join routes on routes.routeid=trips.routeid
join places plcstart on plcstart.placeid=trips.placeidstart
join places plcend on plcend.placeid=trips.placeidend
join segments on segments.tripid = trips.tripid
join stops on segments.stopid = stops.stopid
where (stops.stopid = :perrons0
OR stops.stopid = :perrons1 OR stops.stopid = :perrons2
OR stops.stopid = :perrons3 OR stops.stopid = :perrons4
OR stops.stopid = :perrons5 OR stops.stopid = :perrons6
OR stops.stopid = :perrons7 OR stops.stopid = :perrons8
OR stops.stopid = :perrons9 OR stops.stopid = :perrons10
OR stops.stopid = :perrons11 OR stops.stopid = :perrons12
OR stops.stopid = :perrons13 OR stops.stopid = :perrons14
)
AND calendar.vscdate = DATE(DATE_ADD(now(), INTERVAL "07:00" HOUR_MINUTE))
AND segments.segmentstart >= TIME(DATE_ADD(now(), INTERVAL "07:00" HOUR_MINUTE))
AND routes.routeservicetype = 0
AND segments.segmentstart > "00:00:00"
ORDER BY segments.segmentstart
有查詢,我似乎無法想到的任何事情去改變那將優化這...這超時....
任何提示的歡迎!
你有什麼指標? –
'EXPLAIN'計劃展示了什麼? –