I am trying to improve the performance of this qry which right now is taking far to long. On the only table used I already have a Primary Key and an Index. I am unsure what to do next. Here is the Qry.
SELECT
qry_tempCashValue.IssueYear,
qry_tempCashValue.LM_PLAN_CODE,
Count(distinct qry_tempCashValue.POLICY_NO) AS CountOfPOLICY_NO,
qry_tempCashValue.[Interest Rate Code]
FROM
(
SELECT
tblInsurance.POLICY_NO,
tblInsurance.IssueYear,
tblInsurance.ISSUE_DATE,
tblInsurance.LM_PLAN_CODE,
tblInsurance.AMOUNT_INFORCE,
tblInsurance.StatReserve,
tblInsurance.StatReserveX,
tblInsurance.DefPremReserve,
tblInsurance.ExcessCashValue,
tblInsurance.ExcessCashValueX,
tblInsurance.STAT2_PUA_RES,
tblInsurance.STAT2_OYT_RES,
tblInsurance.StatOYTRes2X,
qryPolyCalcParameters.[Calc Parameters Code],
qryPolyCalcParameters.[Low Issue Date],
qryPolyCalcParameters.[Interest Rate Code]
FROM tblInsurance
INNER JOIN qryPolyLifeMasterPlans
ON tblInsurance.LM_PLAN_CODE =
qryPolyLifeMasterPlans.[LifeMaster Plan Code]
INNER JOIN qryPolyNonforfeitureValues
ON qryPolyLifeMasterPlans.[Nonforfeiture Value Code] =
qryPolyNonforfeitureValues.[Nonforfeiture Value Code]
INNER JOIN qryPolyCalcParameters
ON qryPolyNonforfeitureValues.[(Cash Value) Calc Parameters Code] =
qryPolyCalcParameters.[Calc Parameters Code]
WHERE
qryPolyCalcParameters.[Low Issue Date]<[ISSUE_DATE]
AND tblInsurance.COMPANY_CODE='NL'
AND tblInsurance.LINE_OF_BUSINESS='IT'
AND tblInsurance.SchedNP='PAR'
AND tblInsurance.TERM_REASON='A'
AND tblInsurance.ProdType='PERM'
AND tblInsurance.PHASE_CODE=0
AND tblInsurance.SUB_PHASE_CODE=1
) qry_tempCashValue
GROUP BY
qry_tempCashValue.IssueYear,
qry_tempCashValue.LM_PLAN_CODE,
qry_tempCashValue.[Interest Rate Code];
SELECT
qry_tempCashValue.IssueYear,
qry_tempCashValue.LM_PLAN_CODE,
Count(distinct qry_tempCashValue.POLICY_NO) AS CountOfPOLICY_NO,
qry_tempCashValue.[Interest Rate Code]
FROM
(
SELECT
tblInsurance.POLICY_NO,
tblInsurance.IssueYear,
tblInsurance.ISSUE_DATE,
tblInsurance.LM_PLAN_CODE,
tblInsurance.AMOUNT_INFORCE,
tblInsurance.StatReserve,
tblInsurance.StatReserveX,
tblInsurance.DefPremReserve,
tblInsurance.ExcessCashValue,
tblInsurance.ExcessCashValueX,
tblInsurance.STAT2_PUA_RES,
tblInsurance.STAT2_OYT_RES,
tblInsurance.StatOYTRes2X,
qryPolyCalcParameters.[Calc Parameters Code],
qryPolyCalcParameters.[Low Issue Date],
qryPolyCalcParameters.[Interest Rate Code]
FROM tblInsurance
INNER JOIN qryPolyLifeMasterPlans
ON tblInsurance.LM_PLAN_CODE =
qryPolyLifeMasterPlans.[LifeMaster Plan Code]
INNER JOIN qryPolyNonforfeitureValues
ON qryPolyLifeMasterPlans.[Nonforfeiture Value Code] =
qryPolyNonforfeitureValues.[Nonforfeiture Value Code]
INNER JOIN qryPolyCalcParameters
ON qryPolyNonforfeitureValues.[(Cash Value) Calc Parameters Code] =
qryPolyCalcParameters.[Calc Parameters Code]
WHERE
qryPolyCalcParameters.[Low Issue Date]<[ISSUE_DATE]
AND tblInsurance.COMPANY_CODE='NL'
AND tblInsurance.LINE_OF_BUSINESS='IT'
AND tblInsurance.SchedNP='PAR'
AND tblInsurance.TERM_REASON='A'
AND tblInsurance.ProdType='PERM'
AND tblInsurance.PHASE_CODE=0
AND tblInsurance.SUB_PHASE_CODE=1
) qry_tempCashValue
GROUP BY
qry_tempCashValue.IssueYear,
qry_tempCashValue.LM_PLAN_CODE,
qry_tempCashValue.[Interest Rate Code];