|
I added a case statement to a view using CTE's Is there a way to diagnose and rewrite this more efficiently?
(comments are locked)
|
|
In order to troubleshoot what is occuring, you should post the execution plan of the query. Preference would be for the actual plan, but even the estimated plan would be useful. Just looking at this statement completely divorced from the rest of the query, it's just not possible to tell you why it's running slow.
(comments are locked)
|


I rewrote the case statement like this and got processing time down to 5:11 but this still is not optimal...
(CASE WHEN cdp1.PRC = 0 and cdp1.PRC_TYP_ID in (41, 43, 124) Then ssf.PRC Else cdp1.PRC END)
As Grant has mentioned the reason for this is something outside the code that you have posted. May be the way you are joining to the CTE? post the execution plan and we will be able to help a lot more...