<?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: Query in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Query/m-p/188393#M265853</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is lib1.table2 a SAS or a database table?t&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With your syntax 15T passes through table2 with 20M rows are required. That's a lot of disk I/O.&lt;/P&gt;&lt;P&gt;If both tables are in SAS then I would go for a data step approach where you load the 15T table into a hash and then in a data null step have one pass through the 20M table. If there is a match with the hash delete the row(s) in the hash. At the very end write the hash table to a normal SAS table (output method).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 05 Jan 2014 08:55:11 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2014-01-05T08:55:11Z</dc:date>
    <item>
      <title>Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query/m-p/188392#M265852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below query takes a huge time to execute..&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;select * from work.table1 as t1 where not exists&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;BR /&gt; select * from lib1.table2 as t2&lt;BR /&gt; where&lt;BR /&gt; t2.column1=t1.column1 and &lt;BR /&gt; t2.column2=t1.column2 and&lt;BR /&gt; t2.column3=t1.column3 and&lt;BR /&gt; .....&lt;BR /&gt; .....&lt;BR /&gt; .....&lt;BR /&gt; t2.column14=t1.column14 and&lt;BR /&gt; t2.column15=t1.column15&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If table1 has around 15000 rows and table2 around 20000000, then it takes around 15 hours for the above query to execute.&lt;/P&gt;&lt;P&gt;What could be the cause for query taking so long?&lt;BR /&gt;Is there any way I can rewrite the above query to reduce execution time..?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Jan 2014 06:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query/m-p/188392#M265852</guid>
      <dc:creator>kds</dc:creator>
      <dc:date>2014-01-05T06:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query/m-p/188393#M265853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is lib1.table2 a SAS or a database table?t&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With your syntax 15T passes through table2 with 20M rows are required. That's a lot of disk I/O.&lt;/P&gt;&lt;P&gt;If both tables are in SAS then I would go for a data step approach where you load the 15T table into a hash and then in a data null step have one pass through the 20M table. If there is a match with the hash delete the row(s) in the hash. At the very end write the hash table to a normal SAS table (output method).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Jan 2014 08:55:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query/m-p/188393#M265853</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-01-05T08:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query/m-p/188394#M265854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;20M rows ain't that much,&amp;nbsp; so I think you could pre sort both tables and use a merge by approach.&amp;nbsp; Perhaps not as efficient as hash tables,&amp;nbsp; but easier to code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Jan 2014 18:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query/m-p/188394#M265854</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-01-05T18:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query/m-p/188395#M265855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure if it would run any faster but this looks like you might investigate and EXCEPT operation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jan 2014 16:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query/m-p/188395#M265855</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-01-06T16:24:10Z</dc:date>
    </item>
  </channel>
</rss>

