<?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 optimisation suggestion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110328#M22891</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First, it seem you have a ; too much, in the present condition your where and group by doesn't execute.&lt;/P&gt;&lt;P&gt;As for optimization, you need to know a little how this table is set up in Oracle.&lt;/P&gt;&lt;P&gt;Is the table partitioned by period_id? If not, your total run time would probably benefit if executed in one pass (not looping through the different periods).&lt;/P&gt;&lt;P&gt;A part from that, the query is quite straight forward, and if SAS pushes the query to Oracle, then you need to talk to the Oracle DBA about Oracle performance.&lt;/P&gt;&lt;P&gt;To see what is really going "down" specify:&lt;/P&gt;&lt;P&gt;options sastrace=',,,d' sastraceloc=saslog;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Aug 2013 07:24:20 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2013-08-14T07:24:20Z</dc:date>
    <item>
      <title>Query optimisation suggestion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110327#M22890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have huge oracle table ,in that one column's value is getting populated as missing and I have been asked to find out how many are getting populated as missing (count) and for which group var. So I am writing following query but its taking a lot of time.(running for more than 3 hrs)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LIBNAME gdw&amp;nbsp; ORACLE&amp;nbsp; PATH=P1&amp;nbsp; SCHEMA=W&amp;nbsp; USER=R&amp;nbsp; &lt;/P&gt;&lt;P&gt;PASSWORD="XXXXXX" &lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;libname ip&amp;nbsp;&amp;nbsp; '/gpfs3' ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Macro m1 (period);&lt;/P&gt;&lt;P&gt;proc sql outobs=1000;&lt;/P&gt;&lt;P&gt;create table ip._&amp;amp;period. as &lt;/P&gt;&lt;P&gt;select count(status) as cnt,&lt;/P&gt;&lt;P&gt;period_id from gdw.ACCT_HIST;&lt;/P&gt;&lt;P&gt;where status is missing and period_id="&amp;amp;period"&lt;/P&gt;&lt;P&gt;group by period_id;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%m1(201307)&lt;/P&gt;&lt;P&gt;%m1(201306)&lt;/P&gt;&lt;P&gt;%m1(201305)&lt;/P&gt;&lt;P&gt;%m1(201304)&lt;/P&gt;&lt;P&gt;%m1(201303)&lt;/P&gt;&lt;P&gt;%m1(201302)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest any alternatives to get faster results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 05:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110327#M22890</guid>
      <dc:creator>yashpande</dc:creator>
      <dc:date>2013-08-14T05:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimisation suggestion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110328#M22891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First, it seem you have a ; too much, in the present condition your where and group by doesn't execute.&lt;/P&gt;&lt;P&gt;As for optimization, you need to know a little how this table is set up in Oracle.&lt;/P&gt;&lt;P&gt;Is the table partitioned by period_id? If not, your total run time would probably benefit if executed in one pass (not looping through the different periods).&lt;/P&gt;&lt;P&gt;A part from that, the query is quite straight forward, and if SAS pushes the query to Oracle, then you need to talk to the Oracle DBA about Oracle performance.&lt;/P&gt;&lt;P&gt;To see what is really going "down" specify:&lt;/P&gt;&lt;P&gt;options sastrace=',,,d' sastraceloc=saslog;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 07:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110328#M22891</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-08-14T07:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimisation suggestion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110329#M22892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a reason you need to output a separate table for each period_id? Especially since each table will consist solely of the period_id and the count of missing obs? Why not create one table with a "group by" based on period_id?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 10:00:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110329#M22892</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2013-08-14T10:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimisation suggestion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110330#M22893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code is error free. The question is about performance.&lt;/P&gt;&lt;P&gt;By happy, the machine is still not smart enough to transform the unstructerd&amp;nbsp; question in answer on his own.&lt;/P&gt;&lt;P&gt;You have something to do and think about it.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some advices:&lt;/P&gt;&lt;P&gt;- Break up your research into smaller parts.&lt;/P&gt;&lt;P&gt;Eg extract the missings to a smaller table to do more research on.&amp;nbsp; The pre-req is this number and size must fit in your environment.&amp;nbsp; &lt;/P&gt;&lt;P&gt;The smaller the dataset to work on the easier it becomes.&amp;nbsp; (Same as fugues)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Understand the physical effects of your request&lt;/P&gt;&lt;P&gt;&amp;nbsp; Indeed Check with you ORA DBA (as LinusH) already stated. If there are views (disadvantage), indexes(advantage) you could imagine what the DBMS internally wil do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Sequential/Random&amp;nbsp; Normally invisible as hidden behind the SQL.&lt;/P&gt;&lt;P&gt;When the effect wil be an access to the whole database touching every record. Try to have it done just once and sequential.&lt;/P&gt;&lt;P&gt;When the effect will be accessing more than (rule of thumb) as 10% still do it sequential once, is it less random (indexed) would be faster. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Getting some answers, iterate this as new questions will need to solved.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 14:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110330#M22893</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-08-14T14:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimisation suggestion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110331#M22894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fot the tecnical part on SAS/Access to oracle there are a lot of tuning options.&lt;/P&gt;&lt;P&gt;For simple read retrieve is should commonly be acceptable. Teh buffsize can help to improve, some functions are causing ... (heavy network load)&amp;nbsp; &lt;BR /&gt;&lt;A class="active_link" href="http://support.sas.com/resources/papers/proceedings13/081-2013.pdf" title="http://support.sas.com/resources/papers/proceedings13/081-2013.pdf"&gt;http://support.sas.com/resources/papers/proceedings13/081-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 14:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110331#M22894</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-08-14T14:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimisation suggestion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110332#M22895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just as a genereal question, are you running this on a local sas machine that is not connected to a server? Or are you running it on a server that is in a different storage location from your Oracle server?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, it could be your network that is causing a lot of the slowdown. I know because I was running reports on a local machine that was accessing a server half way across the country, and a query that would take ~30 seconds on the server was taking over 45 minutes to go through the network (especially when you're returning a lot of data).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just another thing to check out&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 14:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-optimisation-suggestion/m-p/110332#M22895</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-08-14T14:29:17Z</dc:date>
    </item>
  </channel>
</rss>

