<?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 Performance SQL vs MERGE in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Performance-SQL-vs-MERGE/m-p/117358#M32370</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I've made some tests for merging 2 tables (inner join), one having around 13 million observations, and the other one with 300.000, and I have received the following time results, within the 3 different scenarios:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1) PROC SQL&amp;nbsp;&amp;nbsp; -&amp;gt; 20 minutes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2) MERGE with sort on BY variable -&amp;gt; 1h and a half including sorting on tables;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3) MERGE with indexes on BY variable (no sorting) -&amp;gt; 30 hours. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; So my questions are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; - Why PROC SQL is more efficient than MERGE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; - Why MERGE without a previous sort is 30 times more time consuming than MERGE with sort. I know that sorting is reccomended before merge, but the performance decrease is really significant in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would appreciate your answers very much, thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Aug 2013 14:11:33 GMT</pubDate>
    <dc:creator>wildcat</dc:creator>
    <dc:date>2013-08-21T14:11:33Z</dc:date>
    <item>
      <title>Performance SQL vs MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Performance-SQL-vs-MERGE/m-p/117358#M32370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I've made some tests for merging 2 tables (inner join), one having around 13 million observations, and the other one with 300.000, and I have received the following time results, within the 3 different scenarios:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1) PROC SQL&amp;nbsp;&amp;nbsp; -&amp;gt; 20 minutes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2) MERGE with sort on BY variable -&amp;gt; 1h and a half including sorting on tables;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3) MERGE with indexes on BY variable (no sorting) -&amp;gt; 30 hours. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; So my questions are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; - Why PROC SQL is more efficient than MERGE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; - Why MERGE without a previous sort is 30 times more time consuming than MERGE with sort. I know that sorting is reccomended before merge, but the performance decrease is really significant in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would appreciate your answers very much, thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 14:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Performance-SQL-vs-MERGE/m-p/117358#M32370</guid>
      <dc:creator>wildcat</dc:creator>
      <dc:date>2013-08-21T14:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Performance SQL vs MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Performance-SQL-vs-MERGE/m-p/117359#M32371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you performing proc sql join as in-database query. Cause if at all thats the case then it makes whole lot of difference as the db engine will handle the execution of sql as opposed to sas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 14:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Performance-SQL-vs-MERGE/m-p/117359#M32371</guid>
      <dc:creator>sascom10</dc:creator>
      <dc:date>2013-08-21T14:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Performance SQL vs MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Performance-SQL-vs-MERGE/m-p/117360#M32372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One key issue:&amp;nbsp; did you run the PROC SORT before running SQL?&amp;nbsp; If so, it's not really a fair comparison.&amp;nbsp; SQL will change its joining method to take advantage of the sorted order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding outcome #3, you have to picture how SAS extracts observations.&amp;nbsp; It moves an entire page of data into memory, then extracts the observations from memory.&amp;nbsp; When you use an index, most of the work is swapping pages into memory to get the right page that contains the next observation.&amp;nbsp; Don't use an index to read every observation!&amp;nbsp; Ian Whitlock once wrote a short, related paper called something like "Why Did This Code Take 24 Hours to Run?" &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 14:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Performance-SQL-vs-MERGE/m-p/117360#M32372</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-08-21T14:45:11Z</dc:date>
    </item>
  </channel>
</rss>

