<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Seeking suggestions/recommendations on alternatives to a SQL view in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360544#M10850</link>
    <description>&lt;P&gt;Instead of view, I&amp;nbsp;would rather create a table and run the table creating process daily or whenever it is required&lt;/P&gt;</description>
    <pubDate>Mon, 22 May 2017 20:06:14 GMT</pubDate>
    <dc:creator>kiranv_</dc:creator>
    <dc:date>2017-05-22T20:06:14Z</dc:date>
    <item>
      <title>Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360541#M10849</link>
      <description>&lt;P&gt;Good day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Due to a need to have data from several tables be available for querying by our business users, I created a view which left&amp;nbsp;joins 10 tables and unions the results to perform the full dataset. The problem here is that the view underperforms in a significant way. In light of this I would be grateful if more sensible alternatives to my crazy view can be suggested that I can try them&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 20:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360541#M10849</guid>
      <dc:creator>genelle_lake</dc:creator>
      <dc:date>2017-05-22T20:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360544#M10850</link>
      <description>&lt;P&gt;Instead of view, I&amp;nbsp;would rather create a table and run the table creating process daily or whenever it is required&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 20:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360544#M10850</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-05-22T20:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360549#M10851</link>
      <description>&lt;P&gt;What are the reasons for doing an SQL view in the first place? If you replace it with a table and refresh it daily does that satisfy your requirements?&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 20:17:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360549#M10851</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-05-22T20:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360562#M10852</link>
      <description>&lt;P&gt;Complex joins often have bad performance in SAS SQL. Depending on the structure of the joins (many-to-many vs. one-to-many), using a series of data and sort steps may be better suited for your task.&lt;/P&gt;
&lt;P&gt;Only if you need a cartesian result in a many-to-many situation will SQL be unavoidable.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 21:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360562#M10852</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-22T21:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360591#M10853</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134787"&gt;@genelle_lake&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Like already suggested nothing will perform as good as replicating the data by implementing a new physical table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't want to replicate the data then what you could try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Option 1: SQL View&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;- Create indexes on the columns used for joining.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Should this be a case of adding dimensional information to a fact table then also try the ROLE= data set option&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;A href="http://support.sas.com/documentation/cdl/en/ledsoptsref/69751/HTML/default/viewer.htm#n1lwir1q8t4uj4n1wsls1vcm3zsl.htm&amp;nbsp;" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/ledsoptsref/69751/HTML/default/viewer.htm#n1lwir1q8t4uj4n1wsls1vcm3zsl.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'd assume this option instructs the SQL compiler do use a hash lookup and you eventually don't even need indexes anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- And last but not least: I'd assume the main time in your SQL is spent for sorting. IF your lookup tables are not too big then you could increase the value for &lt;EM&gt;ubufsize&lt;/EM&gt; (&lt;EM&gt;buffersize&lt;/EM&gt; prior SAS 9.4). The bigger this value the more memory will be consumed but the higher the chance that your lookups will happen in memory (hash) and not physically by sorting.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/69822/HTML/default/viewer.htm#p12ohgh32ffm6un13s7l2d5p9c8y.htm&amp;nbsp;" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/sqlproc/69822/HTML/default/viewer.htm#p12ohgh32ffm6un13s7l2d5p9c8y.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This quite dated but very interesting article explains how things work: &amp;nbsp;&lt;A href="https://support.sas.com/techsup/technote/ts553.html&amp;nbsp;" target="_blank"&gt;https://support.sas.com/techsup/technote/ts553.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Option 2: Datastep View&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you're joining a big table to multiple rather small lookup tables using different keys then you could also go for a data step view and use SAS data step hash lookups. This would avoid the need to sort the big table multiple times which could save quite a bit of time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 00:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360591#M10853</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-05-23T00:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360774#M10855</link>
      <description>&lt;P&gt;Thanks for this... I dont know why I never thought to just pull the data into a table.&amp;nbsp; Its up and running and being evaluated as we speak.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 15:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360774#M10855</guid>
      <dc:creator>genelle_lake</dc:creator>
      <dc:date>2017-05-23T15:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360776#M10856</link>
      <description>When the idea first came about it was thought to be a small view but as the requirements were gathered in full and implemented it became one behemoth of a view. In its defense it did work well for a while before it slowed to a crawl.&lt;BR /&gt;&lt;BR /&gt;I pulled the data into a table.&amp;nbsp; Its up and running and being evaluated as we speak.&lt;BR /&gt;&lt;BR /&gt;Thank you for the suggestion..</description>
      <pubDate>Tue, 23 May 2017 15:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360776#M10856</guid>
      <dc:creator>genelle_lake</dc:creator>
      <dc:date>2017-05-23T15:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360778#M10857</link>
      <description>I sure can attest to this. There were far too many joins. We are evaluating the use of a replica table instead of the view.</description>
      <pubDate>Tue, 23 May 2017 15:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360778#M10857</guid>
      <dc:creator>genelle_lake</dc:creator>
      <dc:date>2017-05-23T15:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360780#M10858</link>
      <description>Thank you for your very thorough and thoughtful response on this. A replica table has been built and is currently being evaluated.</description>
      <pubDate>Tue, 23 May 2017 15:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360780#M10858</guid>
      <dc:creator>genelle_lake</dc:creator>
      <dc:date>2017-05-23T15:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360784#M10859</link>
      <description>&lt;P&gt;When I left join tables, I try to always join to a common table. e.g.&lt;/P&gt;&lt;P&gt;select ...&lt;/P&gt;&lt;P&gt;from a&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;b&lt;/P&gt;&lt;P&gt;on a.id = b.id&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;c&lt;/P&gt;&lt;P&gt;on a.id = c.id&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;d&lt;/P&gt;&lt;P&gt;on a.id = d.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rather than this equally correct, but sometimes dangerous approach.&lt;/P&gt;&lt;P&gt;select ...&lt;/P&gt;&lt;P&gt;from a&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;b&lt;/P&gt;&lt;P&gt;on a.id = b.id&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;c&lt;/P&gt;&lt;P&gt;on b.id = c.id&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;d&lt;/P&gt;&lt;P&gt;on c.id = d.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wasn't sure what you were doing with the Unions. I have often used a Common Table Expression to get all of the values I need for the join. e.g. (not sure I have the syntax exactly right here)&lt;/P&gt;&lt;P&gt;;with All_IDs as&lt;/P&gt;&lt;P&gt;(select ID from&lt;/P&gt;&lt;P&gt;(select distinct ID from a&lt;/P&gt;&lt;P&gt;union&lt;/P&gt;&lt;P&gt;select distinct ID from b&lt;/P&gt;&lt;P&gt;union&lt;/P&gt;&lt;P&gt;select distinct ID from c))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select ...&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;All_IDs&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;&lt;P&gt;on All_IDs.ID = a.ID&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;b&lt;/P&gt;&lt;P&gt;on All_IDs.ID = b.ID&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;c&lt;/P&gt;&lt;P&gt;on All_IDs.ID = c.ID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also like to break down the query to its subcomponents to see which part is particularly running slow. This helps focus my optimization work.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 15:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/360784#M10859</guid>
      <dc:creator>sschleede</dc:creator>
      <dc:date>2017-05-23T15:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking suggestions/recommendations on alternatives to a SQL view</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/361227#M10872</link>
      <description>I'll have to take this approach into future use when I have joins to perform. It seems to be a moresensible version of my approach.</description>
      <pubDate>Wed, 24 May 2017 14:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Seeking-suggestions-recommendations-on-alternatives-to-a-SQL/m-p/361227#M10872</guid>
      <dc:creator>genelle_lake</dc:creator>
      <dc:date>2017-05-24T14:34:36Z</dc:date>
    </item>
  </channel>
</rss>

