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

T-Sql Query Expand / Collapse
Author
Message
Posted Thursday, May 29, 2014 11:22 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:06 PM
Points: 36,786, Visits: 31,243
ramana3327 (5/29/2014)
Actually I tried with Outer Apply but it increased the execution time. Actually that SP is not taking that much time from SSMS but from the application it is little longer.
The dev is saying that we can still implement that query by avoiding that joins. I am in a way to find that


That's all a part of the reason why I'm suggesting that the company get some professional help.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1575713
Posted Thursday, May 29, 2014 11:41 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:18 AM
Points: 42,479, Visits: 35,546
ramana3327 (5/29/2014)
The dev is saying that we can still implement that query by avoiding that joins.


So go to that dev and ask him to please show you the magic join without a join that he knows.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1575725
Posted Thursday, May 29, 2014 11:43 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:18 AM
Points: 42,479, Visits: 35,546
ramana3327 (5/29/2014)
They want to me create the a temptable or table variable for the main query output and then try to avoid the left outer join.


They want you to add additional overhead and still have to use a left join to the temp table in order to degrade performance further? Sounds legit.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1575726
Posted Thursday, May 29, 2014 11:46 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:18 AM
Points: 42,479, Visits: 35,546
TheSQLGuru (5/27/2014)
GilaMonster (5/27/2014)
TheSQLGuru (5/27/2014)
You also have the dreaded IS NULL OR construct


How did I miss that....


Because you have seen it so much you just don't see it any more?!?


Pretty much. On the other hand, I look like Scotty when I add two words and two brackets to a query and suddenly it's running in a fraction of the time.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1575731
Posted Thursday, May 29, 2014 6:00 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 1:05 PM
Points: 435, Visits: 443
Thanks for you replies.

I am thinking about applying union and exists. I have to see the columns & data types. If it works, I will check the time difference.

Actually his plan is To use a table variable to avoid LEFT OUTER JOIN.

What I understand is that, we have to put all the values from the left table to the table variable, first. Then we have to UPDATE the table variable with the right table values. Then select from the table variable.

This is his his plan.
Post #1575914
Posted Friday, May 30, 2014 1:09 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:18 AM
Points: 42,479, Visits: 35,546
ramana3327 (5/29/2014)
What I understand is that, we have to put all the values from the left table to the table variable, first. Then we have to UPDATE the table variable with the right table values. Then select from the table variable..


An insert and update (with joins) and a select to replace a select. Does that sound like an efficient option?

You still haven't answered the question. Are the left joins a problem (not does someone say they are)? Have you tested and determined that the LEFT keyword is causing such major performance problems?
If you haven't, you're wasting your time looking for a solution to what may well not be a problem



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1576253
Posted Friday, May 30, 2014 4:05 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 1:05 PM
Points: 435, Visits: 443
I haven't tested yet. But there are some temp tables in the SP. It is also causing for recompile
Post #1576300
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse