Click here to Skip to main content
15,885,189 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a query which is like this:

SELECT distinct 
A.col1,
A.col2,
B.col3,
B.col4,
C.col5,
Left(C.col5, 8) AS GLAccount,
D.col6,
E.col7,
D.col8 as LineItemTotal
FROM dbo.TABLE1 A LEFT OUTER JOIN dbo.TABLE2 B
ON A.col1=B.col1
LEFT OUTER JOIN dbo.TABLE3 C
ON A.col1 = C.col1 LEFT OUTER JOIN TABLE4 D
ON B.col2 = D.col2 LEFT OUTER JOIN TABLE5 E
ON D.col3=E.col3
ORDER BY A.col2 ASC


This retrives appx aabout 60 lakh rows...and takes about 7 mins....I have to optimize it, I tried taking half of them into the view and then using the view, but that could only bring down the execution time to 3 and a half mins.....could someone please give me a solution for this?
Posted
Updated 7-Dec-09 2:55am
v3

Hi ;

Try to With Cte that one is useful for reterving the bulk records;

to check out this ;

By;
A.Faijurrahuman
 
Share this answer
 
Do you normalized those tables like not null columns, default constraints, etc. i guess so. Just think selecting all columns instead of particular, i'm sure it will take more time. Then decide do you need really to display all the records.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900