<?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: Why doesn't SAS use index on nested query, or is it another problem? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102785#M28772</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;might try...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table ccf_gdn as&lt;/P&gt;&lt;P&gt;select f.*&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fad.ccf_gdn f&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join falt2 f2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on f.basecardnumber = f2.acct_nbr&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.effecdtivedate between '02oct2012'd and '02jan2013'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and f2.acct_nbr is null;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Feb 2013 00:43:09 GMT</pubDate>
    <dc:creator>DBailey</dc:creator>
    <dc:date>2013-02-08T00:43:09Z</dc:date>
    <item>
      <title>Why doesn't SAS use index on nested query, or is it another problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102784#M28771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have used nested query to query on a variable that is already indexed, but SAS returns the following message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INFO: Index BaseCardNumber not used.&amp;nbsp; Sorting into index order may help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table CCF_GDN as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from fad.CCF_GDN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where BaseCardNumber not in (select distinct ACCT_NBR &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from FALT2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and EffectiveDate between '02oct2012'd and '02jan2013'd&lt;/P&gt;&lt;P&gt;;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I'm wondering how should I write this in another way to optimise the search by using the index on the variable BaseCardNumber.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance guys.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Feb 2013 23:48:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102784#M28771</guid>
      <dc:creator>kooliskool</dc:creator>
      <dc:date>2013-02-07T23:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't SAS use index on nested query, or is it another problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102785#M28772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;might try...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table ccf_gdn as&lt;/P&gt;&lt;P&gt;select f.*&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fad.ccf_gdn f&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join falt2 f2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on f.basecardnumber = f2.acct_nbr&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.effecdtivedate between '02oct2012'd and '02jan2013'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and f2.acct_nbr is null;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 00:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102785#M28772</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-02-08T00:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't SAS use index on nested query, or is it another problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102786#M28773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks on the reply, I guess it is a possible solution, because I tried and the joining does use the index. However I'm interested in querying BaseCardNumber NOT in acct_nbrs, so can't really do that with joins right.....?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the answer I was really after is how to still do the nested query, but using the index to make it faster, because the error message says order of the observation is not the same as in the index, how can I fix that problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 04:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102786#M28773</guid>
      <dc:creator>kooliskool</dc:creator>
      <dc:date>2013-02-08T04:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't SAS use index on nested query, or is it another problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102787#M28774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How would it use an index for NOT in query?&amp;nbsp; I can see if you have a list of IDs you can look them up in the index.&amp;nbsp; But how could you use the index to look up a the ones that aren't in your list?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 05:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102787#M28774</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-02-08T05:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't SAS use index on nested query, or is it another problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102788#M28775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;that's the purpose of doing a left join and then requiring the value to be null.&amp;nbsp; It actually accomplishes the same things as a "not in"...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *&lt;/P&gt;&lt;P&gt;from t1 left outer join t2 on t1.col1 = t2.col1&lt;/P&gt;&lt;P&gt;where t2.col1 is null&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is functionally equivalent to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from t1 where col1 not in (select col1 from t2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a bit surprised that the not exists doesn't use the index on t2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from t1 where not exists (select * from t2 where col1=t1.col1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would have thought that it did.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 13:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-doesn-t-SAS-use-index-on-nested-query-or-is-it-another/m-p/102788#M28775</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-02-08T13:25:23Z</dc:date>
    </item>
  </channel>
</rss>

