May 30, 2018 at 7:21 am
Can any one explain me what is inner loop join and left outer loop join .. I tried to search but I dint find good answer any where.
Below is the sample of it.
inner join Person as emp1 on ( emp1.PersonPK = VU__PKS.p1)
inner loop join PersonDomain on emp1.PersonPK = PersonDomain.PersonFK and isprimary = 1
Thanks in Advance,
Prasanna.
May 30, 2018 at 7:23 am
prasannaj 13253 - Wednesday, May 30, 2018 7:20 AMCan any one explain me what is inner loop join and left outer loop join .. I tried to search but I dint find good answer any where.
Below is the sample of it.
inner join Person as emp1 on ( emp1.PersonPK = VU__PKS.p1)
inner loop join PersonDomain on emp1.PersonPK = PersonDomain.PersonFK and isprimary = 1Thanks in Advance,
Prasanna.
Are you referring to INNER JOIN and LEFT OUTER JOIN in the T-SQL syntax?
π
May 30, 2018 at 7:37 am
i found this. never heard of it before, though.
May 30, 2018 at 7:59 am
Eirikur Eiriksson - Wednesday, May 30, 2018 7:23 AMprasannaj 13253 - Wednesday, May 30, 2018 7:20 AMCan any one explain me what is inner loop join and left outer loop join .. I tried to search but I dint find good answer any where.
Below is the sample of it.
inner join Person as emp1 on ( emp1.PersonPK = VU__PKS.p1)
inner loop join PersonDomain on emp1.PersonPK = PersonDomain.PersonFK and isprimary = 1Thanks in Advance,
Prasanna.Are you referring to INNER JOIN and LEFT OUTER JOIN in the T-SQL syntax?
π
No, I I am referring to Inner loop join and Left outer loop join
May 30, 2018 at 7:59 am
davidandrews13 - Wednesday, May 30, 2018 7:37 AMi found this. never heard of it before, though.
Thank you π I will try to understand this
May 30, 2018 at 8:31 am
LOOP, HASH & MERGE are JOIN hints to tell the SQL Server engine what physical operation should use for that specific JOIN. Usually, the engine will choose the best operation based on statistics of the tables. This is a way to force them when it's constantly failing to choose the correct one.
You should not use them frequently and they should be a last resource.
More info on:
https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-join?view=sql-server-2017
https://blogs.msdn.microsoft.com/bradchen/2016/11/06/sql-server-physical-joins/
May 30, 2018 at 8:35 am
Luis Cazares - Wednesday, May 30, 2018 8:31 AMYou should not use them frequently and they should be a last resource.
In general, unless you are very advanced at tuning and have specific reasons, you shouldn't use them at all. Your default position should be that you don't know more than the optimizer.
May 30, 2018 at 8:47 am
Steve Jones - SSC Editor - Wednesday, May 30, 2018 8:35 AMLuis Cazares - Wednesday, May 30, 2018 8:31 AMYou should not use them frequently and they should be a last resource.In general, unless you are very advanced at tuning and have specific reasons, you shouldn't use them at all. Your default position should be that you don't know more than the optimizer.
And the warning applies to all kind of query hints.
May 30, 2018 at 9:18 am
Luis Cazares - Wednesday, May 30, 2018 8:31 AMLOOP, HASH & MERGE are JOIN hints to tell the SQL Server engine what physical operation should use for that specific JOIN. Usually, the engine will choose the best operation based on statistics of the tables. This is a way to force them when it's constantly failing to choose the correct one.
You should not use them frequently and they should be a last resource.
More info on:
https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-join?view=sql-server-2017
https://blogs.msdn.microsoft.com/bradchen/2016/11/06/sql-server-physical-joins/
Also the join direction:
FROM TableA a
INNER LOOP JOIN TableB b
= for each row in a, return any matches in b.
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
May 30, 2018 at 11:35 am
It sounds like some clarification may be in order here...
There are the joins that we specify when writing T-SQL and there are the joins that SQL Server uses in the background to actually execute the query.
These are two very different things.
The joins we specify when writing T-SQL (JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN & CROSS JOIN) all provide information about how one table relates to the other. They say noting about the specific algorithms to be used when the query is executed.
When your query is sent off to to the optimizer, it gets parsed and it decides, based on several factors, how best to execute your query and creates an execution plan. In that plan, your joins are represented as loop joins, merge joins & hash joins. These represent the specific join algorithms SQL Server has deemed most appropriate based on the information it has available.
As stated in previous posts, YES, you can can force SQL Server to use a specific algorithm using join hints BUT, you'd be well advised to steer well clear of them until you have a solid understanding of how each of the algorithms works and why one is more advantageous than another and under what circumstances. Even then they should only be used when you can clearly demonstrate that SQL Server is choosing the wrong algorithm when left to it's own devises... and probably not even then...
May 31, 2018 at 8:28 am
prasannaj 13253 - Wednesday, May 30, 2018 7:59 AMEirikur Eiriksson - Wednesday, May 30, 2018 7:23 AMprasannaj 13253 - Wednesday, May 30, 2018 7:20 AMCan any one explain me what is inner loop join and left outer loop join .. I tried to search but I dint find good answer any where.
Below is the sample of it.
inner join Person as emp1 on ( emp1.PersonPK = VU__PKS.p1)
inner loop join PersonDomain on emp1.PersonPK = PersonDomain.PersonFK and isprimary = 1Thanks in Advance,
Prasanna.Are you referring to INNER JOIN and LEFT OUTER JOIN in the T-SQL syntax?
πNo, I I am referring to Inner loop join and Left outer loop join
So just to clarify, you're question is on the join hints?
π
May 31, 2018 at 8:34 am
Eirikur Eiriksson - Thursday, May 31, 2018 8:28 AMprasannaj 13253 - Wednesday, May 30, 2018 7:59 AMEirikur Eiriksson - Wednesday, May 30, 2018 7:23 AMprasannaj 13253 - Wednesday, May 30, 2018 7:20 AMCan any one explain me what is inner loop join and left outer loop join .. I tried to search but I dint find good answer any where.
Below is the sample of it.
inner join Person as emp1 on ( emp1.PersonPK = VU__PKS.p1)
inner loop join PersonDomain on emp1.PersonPK = PersonDomain.PersonFK and isprimary = 1Thanks in Advance,
Prasanna.Are you referring to INNER JOIN and LEFT OUTER JOIN in the T-SQL syntax?
πNo, I I am referring to Inner loop join and Left outer loop join
So just to clarify, you're question is on the join hints?
π
... or trying to read an execution plan...
October 10, 2022 at 11:53 am
Very good, thanks for the explanation
October 10, 2022 at 11:54 am
This was removed by the editor as SPAM
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply