1
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%。[eTicketサブエアポート]

それらはすべて必要なので、選択の一部を取り出すことはできません....

4

1 に答える 1

2

参加してみてください。次のようになります。

SELECT DISTINCT
   Country.CountryCode, 
   Country.CountryName, 
   Country.CountryEName, 
   Country.FirstShow, 
   Country.iseTicketFirstShow 
FROM 
   Tristar.dbo.COMCountry AS Country
   INNER JOIN eTicketSubAirport ON Country.CountryCode = eTicketSubAirport.CountryCode
   INNER JOIN eTicketMain       ON eTicketSubAirport.AirportCode = eTicketMain.eTDestinationAirport
WHERE 
  Country.ContinentName = 'Continent Name' 
  AND Country.iseTicket = 1 
  AND eTicketMain.eTChecked = 1 
  AND eTicketMain.eTDepartAirport = 'TPE'
ORDER BY 
   Country.iseTicketFirstShow DESC, 
   Country.FirstShow,
   Country.CountryEName
于 2012-09-26T07:23:04.733 に答える