<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tips, Tricks, and Advice from the SQL Server Query Processing Team : Star Join</title><link>http://blogs.msdn.com/sqlqueryprocessing/archive/tags/Star+Join/default.aspx</link><description>Tags: Star Join</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How to Check Whether the Final Query Plan is Optimized for Star Join Queries?</title><link>http://blogs.msdn.com/sqlqueryprocessing/archive/2007/04/09/how-to-check-whether-the-final-query-plan-is-optimized-for-star-join.aspx</link><pubDate>Mon, 09 Apr 2007 21:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2063180</guid><dc:creator>queryproc</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/sqlqueryprocessing/comments/2063180.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlqueryprocessing/commentrss.aspx?PostID=2063180</wfw:commentRss><description>&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Arial','sans-serif'"&gt;The star join optimization technique is an index based optimization designed for data warehousing scenarios to make optimal use of non-clustered indexes on the huge fact tables. The general idea is to use the non-clustered indexes on the fact table to limit the number of rows scanned from it. More details of index based star join optimization can be found at &lt;A href="http://blogs.msdn.com/bi_systems/pages/164502.aspx" mce_href="http://blogs.msdn.com/bi_systems/pages/164502.aspx"&gt;&lt;FONT color=#800080&gt;http://blogs.msdn.com/bi_systems/pages/164502.aspx&lt;/FONT&gt;&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Arial','sans-serif'"&gt;The following discussion is based on SQL Server 2005 query plans.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Arial','sans-serif'"&gt;In SQL Server 2005, we put "&lt;B&gt;StarJoinInfo&lt;/B&gt;" element in &lt;A href="http://blogs.msdn.com/sqlqueryprocessing/archive/2006/10/06/Viewing-and-Interpreting-Showplan-XML.aspx" mce_href="http://blogs.msdn.com/sqlqueryprocessing/archive/2006/10/06/Viewing-and-Interpreting-Showplan-XML.aspx"&gt;Showplan XML&lt;/A&gt; to highlight star join optimization. If the query plan contains the “&lt;B&gt;StarJoinInfo&lt;/B&gt;” element, then SQL Server has identified this plan as a star join plan and it definitely is one. &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Arial','sans-serif'"&gt;However, the query optimizer may not detect all star join plans due to star join detection restrictions. Hence there are some star join plans that won’t have the &lt;B&gt;StarJoinInfo&lt;/B&gt;. This post will shed some light on how to manually detect if a given query plan is&amp;nbsp;a star join plan.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Arial','sans-serif'"&gt;These steps can help you identify what’s &lt;B&gt;NOT&lt;/B&gt; a star join plan:&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: #333333; tab-stops: list .5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;First identify your fact table.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt; &lt;/SPAN&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: #333333; tab-stops: list .5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;If you see clustered index scan (or table scan) on fact table, then it’s not an index-based star join plan (however, this is a valid multi-table join plan, which can benefit from multiple-&lt;A href="http://blogs.msdn.com/sqlqueryprocessing/archive/2006/10/27/query-execution-bitmaps.aspx" mce_href="http://blogs.msdn.com/sqlqueryprocessing/archive/2006/10/27/query-execution-bitmaps.aspx"&gt;bitmap filter&lt;/A&gt; pushdown).&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Arial','sans-serif'"&gt;To identify a star join plan, you should:&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: #333333; tab-stops: list .5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Again, first identify your fact table&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt; &lt;/SPAN&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: #333333; tab-stops: list .5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;You&lt;B&gt; &lt;/B&gt;should have a &lt;B&gt;single&lt;/B&gt; RID lookup or clustered index seek on the fact table&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt; &lt;/SPAN&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: #333333; tab-stops: list .5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Restrictive dimensions (dimension tables with restrictive filters in the query) should be processed before processing the clustered index seek or RID lookup on the fact table. You should find either:&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt; &lt;/SPAN&gt;&lt;/LI&gt;
&lt;UL style="MARGIN-TOP: 0in" type=circle&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: #333333; tab-stops: list 1.0in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;A Cartesian product between the dimensions joined with a multi-column index on the fact table.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt; &lt;/SPAN&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: #333333; tab-stops: list 1.0in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Or a semi-join of the dimensions with some non-clustered indexes on the fact table.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt; &lt;/SPAN&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: #333333; tab-stops: list 1.0in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Or a join between multiple dimensions.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: #333333; tab-stops: list 1.0in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #333333; FONT-FAMILY: 'Arial','sans-serif'"&gt;Non-restrictive dimensions are joined later with the fact table.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Times New Roman','serif'"&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #333333; FONT-FAMILY: 'Arial','sans-serif'"&gt;So the rule of thumb is: to detect whether a given plan is using index-based star join optimization, you should always look for a &lt;STRONG&gt;seek&lt;/STRONG&gt; on a &lt;STRONG&gt;fact&lt;/STRONG&gt; table that is based on some joins of some dimension tables.&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2063180" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlqueryprocessing/archive/tags/Showplan_5F00_XML/default.aspx">Showplan_XML</category><category domain="http://blogs.msdn.com/sqlqueryprocessing/archive/tags/Showplan/default.aspx">Showplan</category><category domain="http://blogs.msdn.com/sqlqueryprocessing/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category><category domain="http://blogs.msdn.com/sqlqueryprocessing/archive/tags/Star+Join/default.aspx">Star Join</category></item></channel></rss>