Avatar of grogo21
grogo21

asked on 

Optimize Query

Hello, this query executes really slowly and will get slower as more records are inserted:

Select      SUM(
Case DisplayFormat
WHEN 1 THEN 1
ELSE 0
END),
count(Distinct DomainID)
From Displayed
Where(SnapID = 1000)
and dDisplay > '17-JUN-2008'

Any Ideas on how to improve query  speed? I think the issue lies with the Case DisplayFormat. Does this run through every record in the table or do the where restrictions also apply to the case statment?

Thanks
Microsoft SQL ServerMicrosoft SQL Server 2005SQL

Avatar of undefined
Last Comment
Mike Eghtebas

8/22/2022 - Mon