SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


query tuning (PFA, execution plan and indexed view)- need help to enhance performance


query tuning (PFA, execution plan and indexed view)- need help to enhance performance

Author
Message
ChrisM@Work
ChrisM@Work
SSC-Forever
SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)

Group: General Forum Members
Points: 42901 Visits: 20015
saxena200 (2/6/2013)
@Chris

PFA the execution Plan...
this is not working.... Sad


You commented out the query hint. Can you run it without the query hint commented out, please?

“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
ChrisM@Work
ChrisM@Work
SSC-Forever
SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)

Group: General Forum Members
Points: 42901 Visits: 20015
saxena200 (2/6/2013)
@Chris

PFA the execution Plan...
this is not working.... Sad


Apologies, I missed a column from the GROUP BY:

SELECT      DT.MO_OF_YR_NM          [Month],
DT.MO_OF_YR [month_No],
DT.YR [Year],
DT.MIC_WK_OF_MO_NM [Week],
DT.DT [Date],
cstmr.[Organisation],
cstmr.CSTMR_KEY,
cstmr.CNTRCT_DD, -- NEW
PD.BS_LN_NM [Business Line],
ED.EMPE_NM [Sales Executive],
cstmr.[Total no of Lines],
[Total No Of Unpaid Lines] = CASE WHEN cstmr.[Total Amount Due] > 0 THEN cstmr.[Total no of Lines] ELSE 0 END,
cstmr.[Total Amount Due]
FROM DT_DIM DT

INNER JOIN (
SELECT
CDBF.FCT_DT_KEY,
[Organisation] = CD.CSTMR_NM,
cd.CSTMR_KEY,
[Total no of Lines] = COUNT(DISTINCT CDBF.CSTMR_KEY),
cdbf.ar_bhvr_key,
[Total Amount Due] = SUM(CDBF.BLNC),
CDBF.CNTRCT_DD -- NEW
FROM CSTMR_DUE_BLNC_FCT CDBF
INNER JOIN CSTMR_DIM CD
ON CD.CSTMR_KEY = CDBF.CSTMR_KEY --
GROUP BY
CDBF.FCT_DT_KEY,
CD.CSTMR_NM,
cd.CSTMR_KEY,
cdbf.AR_BHVR_KEY,
CDBF.CNTRCT_DD -- NEW
) cstmr ON DT.DT_KEY = cstmr.FCT_DT_KEY

Inner join AR_BHVR_DIM ABD
on ABD.AR_BHVR_KEY = cstmr.AR_BHVR_KEY
Inner join PD_DIM PD
on PD.PD_KEY = ABD.PD_KEY
Inner Join EMPE_DIM ED
ON ED.EMPE_KEY=ABD.EMPE_KEY

WHERE DT.DT>=@FromDate AND DT.DT<=@ToDate
/*
GROUP BY
DT.MO_OF_YR_NM,
DT.MO_OF_YR,
DT.MIC_WK_OF_MO_NM,
DT.DT,
DT.YR,
CD.CSTMR_NM,
PD.BS_LN_NM,
ED.EMPE_NM,
--CDBF.FCT_DT_KEY,
CDBF.AR_BHVR_KEY,
CDBF.CNTRCT_DD,
cd.CSTMR_KEY
*/
ORDER BY DT.MO_OF_YR
OPTION (EXPAND VIEWS)




“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search