<?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: SQL - Tuning in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-tuning/m-p/2416074#M539268</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try to reduce maximum IN statements by using EQ.  because IN statement makes a complete search of that column......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because there is nearly 1000 records its better to use group by clause than using distinct clause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Jul 2007 05:03:11 GMT</pubDate>
    <dc:creator>kesavadas_thekkillath</dc:creator>
    <dc:date>2007-07-06T05:03:11Z</dc:date>
    <item>
      <title>SQL - Tuning</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-tuning/m-p/2416071#M539265</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;I hv SQL code like,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 - SELECT bname&lt;/P&gt;&lt;P&gt;INTO TABLE bname_itab&lt;/P&gt;&lt;P&gt;FROM vbak&lt;/P&gt;&lt;P&gt;WHERE ernam IN s_ernam&lt;/P&gt;&lt;P&gt;AND bname NE space&lt;/P&gt;&lt;P&gt;AND auart IN s_auart&lt;/P&gt;&lt;P&gt;AND vkorg IN s_org&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and ktokd in s_c_ag&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;AND vtweg IN s_d_ch&lt;/P&gt;&lt;P&gt;AND spart IN s_div.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 - SORT bname_itab.&lt;/P&gt;&lt;P&gt;3 - DELETE ADJACENT DUPLICATES FROM bname_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, the 1st statement is, consuming much time, as there 1000's BNAMEs in VBAK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to avoide selecting duplicates in the 1st SELECT statement itself? &lt;/P&gt;&lt;P&gt;I mean, only the new/differed BNAMEs shuld b selected! &lt;/P&gt;&lt;P&gt;(so, I dont use 2ns and 3rd stetents any more)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanq.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2007 15:01:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-tuning/m-p/2416071#M539265</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-25T15:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: SQL - Tuning</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-tuning/m-p/2416072#M539266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT bname&lt;/P&gt;&lt;P&gt;INTO TABLE bname_itab&lt;/P&gt;&lt;P&gt;FROM vbak&lt;/P&gt;&lt;P&gt;WHERE ernam IN s_ernam&lt;/P&gt;&lt;P&gt;AND bname NE space&lt;/P&gt;&lt;P&gt;AND auart IN s_auart&lt;/P&gt;&lt;P&gt;AND vkorg IN s_org&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and ktokd in s_c_ag&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;AND vtweg IN s_d_ch&lt;/P&gt;&lt;P&gt;AND spart IN s_div&lt;/P&gt;&lt;P&gt;group by bname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ernst&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2007 15:10:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-tuning/m-p/2416072#M539266</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-25T15:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: SQL - Tuning</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-tuning/m-p/2416073#M539267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the distinct keyword to make all results unique, but in terms of performance it will likely be the same.  The performance issue is that you are doing a scan on a field that is not indexed (bname).  If you can somehow narrow the result set by using a date range, or something of that sort, it would help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &amp;lt;b&amp;gt;DISTINCT&amp;lt;/b&amp;gt; bname&lt;/P&gt;&lt;P&gt;INTO TABLE bname_itab&lt;/P&gt;&lt;P&gt;FROM vbak&lt;/P&gt;&lt;P&gt;WHERE ernam IN s_ernam&lt;/P&gt;&lt;P&gt;AND bname NE space&lt;/P&gt;&lt;P&gt;AND auart IN s_auart&lt;/P&gt;&lt;P&gt;AND vkorg IN s_org&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and ktokd in s_c_ag&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;AND vtweg IN s_d_ch&lt;/P&gt;&lt;P&gt;AND spart IN s_div.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2007 17:56:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-tuning/m-p/2416073#M539267</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-25T17:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL - Tuning</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-tuning/m-p/2416074#M539268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try to reduce maximum IN statements by using EQ.  because IN statement makes a complete search of that column......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because there is nearly 1000 records its better to use group by clause than using distinct clause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jul 2007 05:03:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-tuning/m-p/2416074#M539268</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2007-07-06T05:03:11Z</dc:date>
    </item>
  </channel>
</rss>

