What would be the best index(es) to add to the tables in order to make this query as fast as possible. The sd.incidents tables is about 2.5M records, problems about 8K, and changes about 120K.
select
--bunch of fields
from
sd.incidents a
left join sd.problems b on a.pr_number = b.pr_number
left join sd.problems c on b.pr_number = c.parent_pr_number and c.is_root_cause = 1
left join sd.changes d on b.caused_by_change_number_clean = d.change_number
where
a.severity in (1,2,3) and
(a.pr_number is not null or a.parent_number is null)
a.pr_number,b.br_numberandc.pr_number(if appropriate). It can speed lookups. – ta.speot.is Jul 19 '11 at 22:13SELECT * FROM sd.incidents WHERE severity IN (1, 2, 3)? What is the minimum edition of SQL Server you have to code against? Which fields are actually selected (it makes a difference)? – Jon Seigel Jul 19 '11 at 23:29