下面是我的查询和执行计划。我希望提高性能昨天我提出了一个问题,目前尚不清楚。所以我在这里加上适当的查询和执行计划
INSERT INTO #FinalResultTable
(
[Disclosure Category]
, [Line #]
, [AllocationProcessId]
, [Line Description (Long)]
, [Line Description (Short)]
, [Segment Start Date]
, [Segment End Date]
, [Tag Group1]
, [Tag Group2]
, [Tag Group3]
, [Tag Group4]
, [UniqueTransactionId]
, [TransactionName]
, InvestmentNumber
)
SELECT
WSS.Name ,
SS.SortSequence AS [LineNo],
AD.AllocationProcessId,
SS.UnformattedQuestionText AS [LineDescriptionLong],
SS.ShortDescription AS [LineDescriptionShort],
[SegmentStartDate],
[SegmentEndDate],
[TagDescription1],
[TagDescription2],
[TagDescription3],
[TagDescription4],
[UniqueTransactionId],
[TransactionName],
InvestmentNumber
FROM [#AllocationData] AD
JOIN [#SupplementalSection] SS ON
(SS.Code = AD.Code AND AD.SupplementalSectionQnId IS NULL) or
AD.SupplementalSectionQnId = SS.SupplementalSectionQnId
JOIN Workpaper.SupplementalSection WSS WITH(NOLOCK)
ON SS.SupplementalSectionId = WSS.Id
WHERE WSS.IsActive = 1 AND WSS.IsDeleted = 0 AND WSS.formTypeId = @formTypeId
根据执行计划表的插入成本为75%,总成本为29%。对于AllocationData,我具有SupplementalSectionQnId,Code
的非聚集索引