我有这个查询.. 214执行/分钟,平均44.42 CPU(ms)有没有办法使它更快
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'
现在这如果我拆分为2个查询
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;
使用飞盘推荐的查询
使用哈希联接
查询现在需要运行多少时间?为何每分钟执行200次?您能解释一下如此频繁地将结果保存到临时表中的必要性吗?
—
ypercubeᵀᴹ
此查询在SP中,而临时表在下一个查询中使用。每分钟大约有20 K个请求。
—
sebeid 2015年