Hi guys, thanks for traveling with me along the series of post to explore the SQL server Execution Plan Secrets. For the people those who missed out some basics, no worries here you go. limitations of execution plan, some alarming signs and complex execution plans
Really we are going to see some interesting things on this post. Most of the time, while we examine the execution plan of a query which join two or more tables, we used to saw the join operators –nested loop join, hash match and merge join operator . We often not concentrate, why it is using hast match join etc. Which was prime subject of our post today, also we will see how resolve the warnings on our execution plan.
Okay, let us see some basics about this join operators before step into details. For the people those who saw the below image and puzzled, no more such situation.
Let us move on to see some real demos on the three join types one by one. I use Adventureworks2012 database for our demo
SELECT |
P1.FirstName, |
P1.LastName, |
P2.PhoneNumber |
FROM Person.Person P1 |
INNER JOIN Person.PersonPhone P2 ON P1.BusinessEntityID = P2.BusinessEntityID |
The Query will generate a execution plan like below. Check the index used by the personphone table, it has phone number on the key column, as i explained before it was the build phase, which builds the data using this index on the hash buckets. And the second phase was the probe phase, which probes the matching records using other index on the Person table. You can mouse over the Hast Match operator to see more details on it..
Thanks for your time, and the game is not over yet. On next post we will see how we can make the optimizer to use different execution plan. Meaning you will see the same query i demonstrated above, will use nested loop and merge joins. By the end of next post, you will be able to change the execution plan by supplying some index, by which the join operator used by the optimizer will differ accordingly..
Would like to see your comments and feed backs as well
No comments:
Post a Comment