Tengo esta consulta ... 214 Ejecución / min, 44.42 Promedio de CPU (ms) ¿Hay alguna manera de hacerlo mucho más rápido?
SELECT P.Id id0,
P.ProgramId ProgramId1,
P.ProgramName ProgramName2,
P.ProgramLevel ProgramLevel3,
P.Department Department4,
P.Track Track5,
P.AcademicYear AcademicYear6,
P.StartTerm StartTerm7,
P.Delivery Delivery8,
P.Fee Fee9,
P.City City10,
P.STATE State11,
P.StartDate StartDate12,
P.Deadline Deadline13,
P.DeadlineDisplay DeadlineDisplay14,
P.ProgramType ProgramType15,
O.Id as OrganizationId16,
O.NAME OrganizationName17,
P.ApplicationType ApplicationType18,
P.Concentration Concentration19,
P.ZipCode ZipCode20,
P.Campus Campus21,
P.WADisplayName WADisplayName22,
P.UpdatedDate updateDate23,
AF.Id InstanceId24,
RD.Id stateId33
INTO #TempGetFullProgramSelectionInfo
FROM unicas_config..applicationForm AF
INNER JOIN UNICAS_CONFIG.. AcademicInstitution AI
ON AF.casid=AI.casid
INNER JOIN UNICAS_CONFIG..Organization O
ON O.academicInstitutionid=AI.id
INNER JOIN UNICAS_CONFIG..AssociationOrg asOrg
ON asOrg.FormId=AF.id
INNER JOIN UNICAS_CONFIG..Program P
ON P.AssociationOrgId=asOrg.Id and asOrg.OrganizationId=O.id AND AF.Id = 6286
INNER JOIN unicas_config..ReferenceData RD
ON P.STATE = RD.ValueId AND RD.ValueAbbr ='US'
INNER JOIN unicas_config..ReferenceDataSet RS
ON RD.ReferenceSetId = RS.SetId AND RS.NAME = 'LK_States'
Ahora esto si me divido en 2 consultas
select RD.ValueId, RD.id into #temp1
from unicas_config..ReferenceData RD
INNER JOIN unicas_config..ReferenceDataSet RS ON RD.ReferenceSetId= RS.SetId AND RS.NAME= 'LK_States'
where RD.ValueAbbr='US';
SELECT P.Id id0,
P.ProgramId ProgramId1,
P.ProgramName ProgramName2,
P.ProgramLevel ProgramLevel3,
P.Department Department4,
P.Track Track5,
P.AcademicYear AcademicYear6,
P.StartTerm StartTerm7,
P.Delivery Delivery8,
P.Fee Fee9,
P.City City10,
P.STATE State11,
P.StartDate StartDate12,
P.Deadline Deadline13,
P.DeadlineDisplay DeadlineDisplay14,
P.ProgramType ProgramType15,
O.Id as OrganizationId16,
O.NAME OrganizationName17,
P.ApplicationType ApplicationType18,
P.Concentration Concentration19,
P.ZipCode ZipCode20,
P.Campus Campus21,
P.WADisplayName WADisplayName22,
P.UpdatedDate updateDate23,
AF.Id InstanceId24,
RD.Id stateId33
INTO #TempGetFullProgramSelectionInfo
FROM unicas_config..applicationForm AF
INNER JOIN UNICAS_CONFIG.. AcademicInstitution AI
ON AF.casid=AI.casid
INNER JOIN UNICAS_CONFIG..Organization O
ON O.academicInstitutionid=AI.id
INNER JOIN UNICAS_CONFIG..AssociationOrg asOrg
ON asOrg.FormId=AF.id
INNER JOIN UNICAS_CONFIG..Program P
ON P.AssociationOrgId=asOrg.Id and asOrg.OrganizationId=O.id AND AF.Id = 6286
INNER JOIN #temp1 RD ON P.STATE= RD.ValueId;
utilizando la consulta recomendada por Frisbee
Utilizando Hash join