July 13, 2012 at 12:57 pm
Im trying to figure out how to further performance tune a query. A look at the execution plan shows that the Stream Aggregate is trying to pull 18.7 billion rows which is not good as this qurey should only generate about half a million.
any advice would be helpful
thanks
SELECT d.Company, d.TRXDATE, l.ACTINDX, SUM(l.CRDTAMNT) AS CRDTAMNT, SUM(l.DEBITAMT) AS DEBITAMT, MAX(l.RowIn) AS LastModified
FROM (SELECT DISTINCT Company, TRXDATE
FROM dbo.tblGeneralLedger
WHERE (RowOut IS NULL)) AS d INNER JOIN
dbo.tblGeneralLedger AS l ON l.Company = d.Company AND l.TRXDATE <= d.TRXDATE AND l.RowOut IS NULL INNER JOIN
dbo.tblGeneralLedgerAccounts AS a ON a.Company = d.Company AND a.ACTINDX = l.ACTINDX AND a.RowOut IS NULL INNER JOIN
dbo.tblGeneralLedgerAccountCategories AS c ON c.Company = d.Company AND c.ACCATNUM = a.ACCATNUM AND c.RowOut IS NULL
WHERE (c.IsBalanceSheet = 1) AND (c.IsIncluded = 1)
GROUP BY d.Company, d.TRXDATE, l.ACTINDX
July 13, 2012 at 1:09 pm
Take a look at this article. It explains what to post for performance issues.
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply