所以我有以下代码 - 由第三方供应商编写。任何人都可以建议应该使用哪些索引来防止书签查找?您是否也需要UDF的内容?
SELECT reportTbl.ReportDBID,
case when reportTbl.ResultStatus = 'P' then 'PRELIMINARY'
when reportTbl.ResultStatus = 'I' then 'INTERIM'
else reportTbl.ResultStatus end As Status, 1 as isAccessible,
dbo.repAb(reportTbl.ReportDBID) As Abnormality,
dbo.repAb(reportTbl.ReportDBID) As Importance,
reportTbl.UniversalServiceDescription as Title,
reportTbl.DiagnosticServSectID as ServiceDescription,
case when ResultStatus='X' then 'Cancelled' when ResultStatus='C' OR dbo.inferStatus(reportTbl.ReportDBID) = 'C' then 'Amended'
else reportTbl.DiagnosticServSectID end AS subCategory,
reportTbl.DiagnosticServSectID as subCategoryAlt,
case when cdrOth.FamilyName is not null then cdrOth.FamilyName else cdrOth.IDNumber end As Author,
reportTbl.ObservationDateTime
FROM reportTbl WITH (NOLOCK)
INNER JOIN patientTbl WITH (NOLOCK) ON reportTbl.patID = patientTbl.patID
LEFT OUTER JOIN cdrOth WITH (NOLOCK) ON reportTbl.ordID = cdrOth.SegCrossReferenceDBID
WHERE
patientTbl.recNumber ='111111111'
and reportTbl.ResultStatus IN ('G', 'H','I', 'J')
and reportTbl.DiagnosticServSectID IN ('E', 'F')
and reportTbl.UniversalServiceCode NOT IN ('A', 'B', 'C', 'D') -- there are roughly 750 options so using NOT IN is easier
ORDER BY ReportDBID