SELECT
CountryCode, CountryName, CountryEName, FirstShow, iseTicketFirstShow
FROM
Tristar.dbo.COMCountry
WHERE
ContinentName = 'Continent Name' AND iseTicket = 1
and CountryCode in
(select Distinct CountryCode
from eTicketSubAirport
where AirportCode in
(select DISTINCT eTDestinationAirport
from eTicketMain
where eTChecked=1 and eTDepartAirport='TPE')
)
ORDER BY
iseTicketFirstShow DESC, FirstShow,CountryEName
上面的代码花了 3 秒....这是不可接受的。2个内部选择自己执行得非常快。
如果我拿走了一个内部选择,例如....
SELECT
CountryCode, CountryName, CountryEName, FirstShow, iseTicketFirstShow
FROM
Tristar.dbo.COMCountry
WHERE
ContinentName = 'continent name' AND iseTicket = 1
and CountryCode in
(select Distinct CountryCode
from eTicketSubAirport)
ORDER BY
iseTicketFirstShow DESC, FirstShow,CountryEName
这也执行得非常快。
哈希匹配太 79% 的处理。[eTicketSubAirport]
我不能删除选择的任何部分,因为它们都是必需的......