<?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 Optimization of the below query in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38155#M9750</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; My experience is that it can be hard to affect the SQL planner. &lt;/P&gt;&lt;P&gt;And I don't you can rewrite the query to boost performance, it is already quite straightforward.&lt;/P&gt;&lt;P&gt;As mentioned earlier, you could probably the ORDER BY since you are using DISTINCT (which is on the other hand unnecessary since you are using GROUP BY).&lt;/P&gt;&lt;P&gt;Probably won't help, but move your subsets to a WHERE clause instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sometimes index joins can be quite I/O intense, which could explain the quite big difference between CPU and Real Time.&lt;/P&gt;&lt;P&gt;Set OPTIONS MSGLEVEL=I FULLSTIMER, they will letr you know in more detail how you query affects the system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Linus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Aug 2011 07:41:23 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2011-08-03T07:41:23Z</dc:date>
    <item>
      <title>Optimization of the below query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38151#M9746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please provide your suggestions on how to optimize the below query:&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; low_level_min_dates &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;select&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; mca.sort_order_id, mca.sps_mca_id,sps_bca_id,sps_card_id,sps_industry_id,sps_merchant_id, sps_product_id, min(sps_time_id) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; sps_time_id &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; lup_mca_match mca inner join fact.fact_billings_month bil &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;on&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; mca.sps_mca_id = bil.sps_mca_id &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;AND&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; bil.sps_billings_type_id = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;AND&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; bil.bill_bud_usd_am ne &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;group &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; sort_order_id, mca.sps_mca_id, sps_bca_id, sps_card_id, sps_industry_id, sps_merchant_id,sps_product_id &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; sort_order_id, sps_time_id ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;NOTE: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: red; font-family: 'Courier New'; background-color: white;"&gt;Table&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; WORK.LOW_LEVEL_MIN_DATES created, with &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;48812804&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; rows and &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: teal; font-family: 'Courier New'; background-color: white;"&gt;columns.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;NOTE: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: red; font-family: 'Courier New'; background-color: white;"&gt;PROCEDURE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; SQL used (Total process time):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;:&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;58&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;:&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;14.00&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;:&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;58.92&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table fact.fact_billings_month has 200 million records and there are indexes on all the variables and table lup_mca_match has 6000 records and my fact is using a SPDE engine.&lt;/P&gt;&lt;P&gt;So can you please suggest me in the different ways the above query can be written in reducing the real time.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Samuel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 11:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38151#M9746</guid>
      <dc:creator>samuelallu</dc:creator>
      <dc:date>2011-07-28T11:46:04Z</dc:date>
    </item>
    <item>
      <title>Optimization of the below query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38152#M9747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not have a direct solution but for such cases I often use the "_method" option as described in &lt;A href="http://support.sas.com/techsup/technote/ts553.html"&gt;TS-DOC 533&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;This document also provides additional information and tips on how to optimize an SQL query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Besides "_method" I furthermore use the INOBS option to (initially) limit the number of rows that are processed to evaluate the result of my optimization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this hint helps you to optimize your query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 13:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38152#M9747</guid>
      <dc:creator>Resa</dc:creator>
      <dc:date>2011-07-28T13:09:27Z</dc:date>
    </item>
    <item>
      <title>Optimization of the below query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38153#M9748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for ur inputs i have already used _Method which is using the index algorithm which is right and do u have any idea on implementing the same query in any other alternate method.. Once again thanks for your inputs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 13:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38153#M9748</guid>
      <dc:creator>samuelallu</dc:creator>
      <dc:date>2011-07-28T13:24:32Z</dc:date>
    </item>
    <item>
      <title>Optimization of the below query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38154#M9749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code is good.If you can ,remove 'order by' clause, because sql will sort variables automatically.&lt;/P&gt;&lt;P&gt;And if you can try to make some index for your inner join 's variables ,which can reduce the time a lot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 05:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38154#M9749</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-08-03T05:28:42Z</dc:date>
    </item>
    <item>
      <title>Optimization of the below query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38155#M9750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; My experience is that it can be hard to affect the SQL planner. &lt;/P&gt;&lt;P&gt;And I don't you can rewrite the query to boost performance, it is already quite straightforward.&lt;/P&gt;&lt;P&gt;As mentioned earlier, you could probably the ORDER BY since you are using DISTINCT (which is on the other hand unnecessary since you are using GROUP BY).&lt;/P&gt;&lt;P&gt;Probably won't help, but move your subsets to a WHERE clause instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sometimes index joins can be quite I/O intense, which could explain the quite big difference between CPU and Real Time.&lt;/P&gt;&lt;P&gt;Set OPTIONS MSGLEVEL=I FULLSTIMER, they will letr you know in more detail how you query affects the system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Linus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 07:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Optimization-of-the-below-query/m-p/38155#M9750</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2011-08-03T07:41:23Z</dc:date>
    </item>
  </channel>
</rss>

