SQL 2000 DB上的建议索引 - 防止书签查找

时间:2011-03-09 09:09:44

标签: sql sql-server indexing sql-server-2000

所以我有以下代码 - 由第三方供应商编写。任何人都可以建议应该使用哪些索引来防止书签查找?您是否也需要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

1 个答案:

答案 0 :(得分:2)

通常使用覆盖索引

删除书签查找

一些great examples here

这比我想的更好。但摘要是书签查找中的列应添加到索引中。