<?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: Optimize SQL ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916272#M686546</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check removing the Join on the table, if it doesn't help then do an SQL trace for the Query. Try Creating an Index on the tables based on the query if it doesn't exist. Creating an index will improve the performance of the query. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will you be fetching the Documents for all the Sales Org? If not, then introduce Sales Org also in the where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Abhishek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Oct 2007 18:14:11 GMT</pubDate>
    <dc:creator>former_member195698</dc:creator>
    <dc:date>2007-10-19T18:14:11Z</dc:date>
    <item>
      <title>Optimize SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916269#M686543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Expert:&lt;/P&gt;&lt;P&gt;The following sql statement take long time to run. how to optimize it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT a&lt;SUB&gt;mandt   a&lt;/SUB&gt;vbeln   a&lt;SUB&gt;vkgrp   a&lt;/SUB&gt;vkbur   a~guebg&lt;/P&gt;&lt;P&gt;         a&lt;SUB&gt;gueen   a&lt;/SUB&gt;ktext   a&lt;SUB&gt;auart   b&lt;/SUB&gt;bzirk  b~kdgrp&lt;/P&gt;&lt;P&gt;        INTO TABLE pi_record&lt;/P&gt;&lt;P&gt;        FROM vbak AS a&lt;/P&gt;&lt;P&gt;          INNER JOIN vbkd AS b&lt;/P&gt;&lt;P&gt;            ON a&lt;SUB&gt;mandt EQ b&lt;/SUB&gt;mandt&lt;/P&gt;&lt;P&gt;            AND a&lt;SUB&gt;vbeln EQ b&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;        WHERE b~posnr EQ c_posnr&lt;/P&gt;&lt;P&gt;          AND a~auart IN ls_contract.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2007 16:37:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916269#M686543</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-19T16:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916270#M686544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use &amp;lt;b&amp;gt;FOR ALL ENTRIES&amp;lt;/b&amp;gt;  to optimize it...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT matnr mtart&lt;/P&gt;&lt;P&gt;  FROM mara&lt;/P&gt;&lt;P&gt;  INTO TABLE t_mara&lt;/P&gt;&lt;P&gt;  WHERE matnr IN s_matnr.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;IF NOT t_mara[] IS INITIAL.&lt;/P&gt;&lt;P&gt;  SELECT matnr maktx&lt;/P&gt;&lt;P&gt;    FROM makt&lt;/P&gt;&lt;P&gt;    INTO TABLE t_makt&lt;/P&gt;&lt;P&gt;    FOR ALL ENTRIES IN t_mara&lt;/P&gt;&lt;P&gt;    WHERE matnr EQ t_mara-matnr.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ilesh 24x7&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2007 16:41:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916270#M686544</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-19T16:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916271#M686545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As you are not passing any primary keys in the SELECT, it is taking long time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First get all Sales orders from VBAK using condition AUART IN LS_CONTRACT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then using this data, fetch data from VBKD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will help to optimize the performance. For more analysis, do the SQL trace and check if it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ashish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2007 16:50:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916271#M686545</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-19T16:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916272#M686546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check removing the Join on the table, if it doesn't help then do an SQL trace for the Query. Try Creating an Index on the tables based on the query if it doesn't exist. Creating an index will improve the performance of the query. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will you be fetching the Documents for all the Sales Org? If not, then introduce Sales Org also in the where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Abhishek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2007 18:14:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916272#M686546</guid>
      <dc:creator>former_member195698</dc:creator>
      <dc:date>2007-10-19T18:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916273#M686547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use transaction ST05 for obtain perfomances sentences in SQL, create index in the tables ,etc . Watch this blog /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try not to use join sentences. Access the database the minimum. Ask for the minimum data&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Oct 2007 09:47:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916273#M686547</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-21T09:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916274#M686548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So long as you don't use a key field in the WHERE, it will be slow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Oct 2007 15:47:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916274#M686548</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-21T15:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916275#M686549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Yunfa,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just wondering why is posnr a constant?  C_POSNR. Is that correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The join is simple, For All Entries will not benefit. No key fields in your WHERE clause so whether you Select each table separately, or join as you have, it will be slow.&lt;/P&gt;&lt;P&gt;Only thing to suggest is a secondary index on AUART in VBAK. It will greatly improve your performance but you may need to justify the creation of an index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can run ST05 performance trace to see if any indexes are being used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Oct 2007 02:43:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimize-sql/m-p/2916275#M686549</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-22T02:43:04Z</dc:date>
    </item>
  </channel>
</rss>

