Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

query tuning (PFA, execution plan and indexed view)- need help to enhance performance Expand / Collapse
Author
Message
Posted Wednesday, February 6, 2013 8:14 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:33 AM
Points: 7,099, Visits: 13,446
saxena200 (2/6/2013)
@Chris

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


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
Post #1416529
Posted Wednesday, February 6, 2013 8:31 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:33 AM
Points: 7,099, Visits: 13,446
saxena200 (2/6/2013)
@Chris

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


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
Post #1416544
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse