Help tune this view | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Help tune this view

CREATE VIEW [dbo].[M_CaseMaster] AS
SELECT CM.*
From CaseMaster CM
where CM.EmployeeNo in
(select E.EmployeeNo
from Employee E,CaseMaster CM2, Med_Sec_Defn M
where E.EmployeeNo = CM2.EmployeeNo
and
( e.geographiclocation = m.geographiclocation
or cm2.geographiclocation = m.geographiclocation
or m.geographiclocation = ‘%’ )
AND
( e.department = m.department
Or cm2.department = m.department
or m.department = ‘%’)
and
( e.division = m.division
or cm2.division = m.division
or m.division = ‘%’)
and
( e.location = m.location
or cm2.location = m.location
or m.location = ‘%’)
and
( e.organization = m.organization
or cm2.organization = m.organization
or m.organization = ‘%’)
)
——————
Bug explorer/finder/seeker/locator
——————
Have you places nesseray indexes for your tables —————————————-
Contributing Editor, Writer & Forums Moderator
http://www.SQL-Server-Performance.Com Visit my Blog at
http://dineshasanka.spaces.live.com/

You could take help of indexed views too. Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
Yes, necessary indexes are there. I just want to rewrite the query to make it simpler. thanks ——————
Bug explorer/finder/seeker/locator
——————
Have you checked the execution plan for this view?
What is the rowcount on the involved tables? Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
]]>