<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.microsoft.co.il/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>Ella Maschiach&amp;#39;s BI Blog : SQL Server Management Studio, SQL</title><link>http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/SQL+Server+Management+Studio/SQL/default.aspx</link><description>Tags: SQL Server Management Studio, SQL</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>SSAS Back Engine and Named Queries in the DSV</title><link>http://blogs.microsoft.co.il/blogs/barbaro/archive/2007/07/19/SSAS-Back-Engine-and-Named-Queries-in-the-DSV.aspx</link><pubDate>Thu, 19 Jul 2007 23:35:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:20058</guid><dc:creator>Ella Maschiach</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/barbaro/rsscomments.aspx?PostID=20058</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/barbaro/archive/2007/07/19/SSAS-Back-Engine-and-Named-Queries-in-the-DSV.aspx#comments</comments><description>&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;Hi everybody,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;What’s up?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;Thought I’d share with you something strange I found while using named queries in the DSV layer in SQL Server Analysis Services.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;I have developed quite a complex layer of connected tables in my DSV. As development had &lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;mso-fareast-font-family:'Times New Roman';mso-bidi-language:AR-SA;mso-ansi-language:EN-US;mso-fareast-language:EN-US;"&gt;evolved&lt;/SPAN&gt; (with the customers demand) I found myself turning 3 of my regular tables into named queries. The named queries were basically using the same table twice in an inner join to compare the state of the entity in two different times in the table. After this change, my process time for the cube and the dimensions grew from about 5 minutes to 20 (!)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;After a while I found myself adding yet another named query to my DSV. This time, the named query included a few tables inner joined. My process time for the cube and the dimensions grew to over an hour(!) I admit I even stopped the process so I don’t know the total time, but just the cube itself demanded about 45 minutes… needless to say, quite disturbing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;So what’s left to do? Check the SQL query working in the background of the SSAS engine. Seeing the query used is easy – all you need to do is click on the dimension &amp;gt; attribute &amp;gt; sql query&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;or click on the measure group &amp;gt; partition &amp;gt; sql query. After double clicking the "select" statement under the "sql query" and you can copy the query. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;Next, you take the query and run it inside a new query in the Management Studio using the relevant database. Run the query with the Estimated Execution Plan which can show you what the engine of the SSAS is actually doing in the background while building the attribute / measure. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;I found the engine runs my named queries used a lot of scans and their order wasn't right (it started with the big tables first).&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0cm 0cm 0pt;TEXT-ALIGN:justify;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt;So what’s the solution? Well, in my project at least, the only immediate solution seemed to be to build actual tables out of the named queries. And my processing time shrunk back to 5 minutes again! &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Wingdings;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:Tahoma;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;SPAN style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Tahoma;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=20058" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/Analysis+Services/default.aspx">Analysis Services</category><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/SSAS/default.aspx">SSAS</category><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/BI/default.aspx">BI</category><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/Project+Management/default.aspx">Project Management</category><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/SQL+Server+Management+Studio/default.aspx">SQL Server Management Studio</category><category domain="http://blogs.microsoft.co.il/blogs/barbaro/archive/tags/Execution+Plan/default.aspx">Execution Plan</category></item></channel></rss>