Besoin d'aide pour optimiser une petite query sql
Salut tout le monde,
Quelqu'un saurait-il comment optimiser cette requête ? ^^
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
UPDATE #temp1
SET #temp2.mainarea_listindex = (SELECT area_listindex
FROM #temp1 t1
WHERE continent_IdCountryGroup IS NOT NULL
AND country_IdCountry IS NOT NULL
AND region1_IdCountryRegionAllGroup IS NOT NULL
AND region2_IdRegion_CountryRegionAll IS NULL
AND t1.continent_IdCountryGroup = #temp2.continent_IdCountryGroup
AND t1.country_IdCountry = #temp2.country_IdCountry
AND t1.region1_IdCountryRegionAllGroup = #temp2.region1_IdCountryRegionAllGroup)
WHERE continent_IdCountryGroup IS NOT NULL
AND country_IdCountry IS NOT NULL
AND region1_IdCountryRegionAllGroup IS NOT NULL
AND region2_IdRegion_CountryRegionAll IS NOT NULL
AND EXISTS (SELECT 1
FROM #temp1 t1
WHERE continent_IdCountryGroup IS NOT NULL
AND country_IdCountry IS NOT NULL
AND region1_IdCountryRegionAllGroup IS NOT NULL
AND region2_IdRegion_CountryRegionAll IS NULL
AND t1.continent_IdCountryGroup = #temp1.continent_IdCountryGroup
AND t1.country_IdCountry = #temp1.country_IdCountry
AND t1.region1_IdCountryRegionAllGroup = #temp1.region1_IdCountryRegionAllGroup) |