<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Physical Join Operators in SQL Server &#8211; Hash Operator</title>
	<atom:link href="http://www.sql-server-performance.com/2010/physical-join-operators-hash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sql-server-performance.com/2010/physical-join-operators-hash/</link>
	<description>SQL Server Performance Tuning</description>
	<lastBuildDate>Fri, 14 Jun 2013 19:09:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Ami Levin</title>
		<link>http://www.sql-server-performance.com/2010/physical-join-operators-hash/#comment-602</link>
		<dc:creator>Ami Levin</dc:creator>
		<pubDate>Tue, 13 Sep 2011 13:24:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?=1867#comment-602</guid>
		<description><![CDATA[Hi Reece,
Very good question, and like all good questions, the answer is simple :-)
You are correct that the ProductID is not needed for this query.
The only thing that is needed from the SalesOrderDetail table is a list of all SaleOrderIDs. The optimizer has several options to get it:
1. Scan the entire table using a clustered index scan = retrieving huge amount of unnecessary data = unnecessary IO and unnecessary memory usage.
2. Get the IDs by scanning a non-clustered index. Since SalesOrderID is part of the clustered index (that supports the primary key), it is included in every non-clustered index and used as the row pointer.
There are two non-clustered indexes on the table, one on ProductID and one on RowGUID. ProductID is a 4 byte INT, RowGUID is a 16 byte unique identifier.
Which index would you scan?
The optimizer chose the smaller one and simply discarded the ProductID.
You can see this in the execution plan if you look at the properties of the index scan operator, you will see that the output list consists only of SaleOrderID.
Try to create a non-clustered index just on SalesOrderID and see how that changes the plan.
Ami]]></description>
		<content:encoded><![CDATA[<p>Hi Reece,<br />
Very good question, and like all good questions, the answer is simple <img src='http://www.sql-server-performance.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
You are correct that the ProductID is not needed for this query.<br />
The only thing that is needed from the SalesOrderDetail table is a list of all SaleOrderIDs. The optimizer has several options to get it:<br />
1. Scan the entire table using a clustered index scan = retrieving huge amount of unnecessary data = unnecessary IO and unnecessary memory usage.<br />
2. Get the IDs by scanning a non-clustered index. Since SalesOrderID is part of the clustered index (that supports the primary key), it is included in every non-clustered index and used as the row pointer.<br />
There are two non-clustered indexes on the table, one on ProductID and one on RowGUID. ProductID is a 4 byte INT, RowGUID is a 16 byte unique identifier.<br />
Which index would you scan?<br />
The optimizer chose the smaller one and simply discarded the ProductID.<br />
You can see this in the execution plan if you look at the properties of the index scan operator, you will see that the output list consists only of SaleOrderID.<br />
Try to create a non-clustered index just on SalesOrderID and see how that changes the plan. </p>
<p>Ami</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reece</title>
		<link>http://www.sql-server-performance.com/2010/physical-join-operators-hash/#comment-566</link>
		<dc:creator>Reece</dc:creator>
		<pubDate>Tue, 30 Aug 2011 14:28:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?=1867#comment-566</guid>
		<description><![CDATA[First, I want to say I am a developer. Second, I am trying to understand Query 8. Why did the Optimizer choose IX_SalesOrderDetail_ProductID when that field isn&#039;t being used or returned? Does it have to do with the way the secret sauce of the HASH function? Meaning, it saw that was the best index to use for hashing?]]></description>
		<content:encoded><![CDATA[<p>First, I want to say I am a developer. Second, I am trying to understand Query 8. Why did the Optimizer choose IX_SalesOrderDetail_ProductID when that field isn&#8217;t being used or returned? Does it have to do with the way the secret sauce of the HASH function? Meaning, it saw that was the best index to use for hashing?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
