<?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: Improving an SQL Statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228963#M1208790</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When doing the trace, check especially if index CATSDB~6 (by ARBID) is being used for access, this seems to be the best one as far as I can tell by just looking at the table definition. Also check if that index is active in your database.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Feb 2009 09:11:59 GMT</pubDate>
    <dc:creator>ThomasZloch</dc:creator>
    <dc:date>2009-02-17T09:11:59Z</dc:date>
    <item>
      <title>Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228957#M1208784</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 been hounded by my Admin Team to try and sort this SQL block out as it is taking a while to execute in Production.. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT * INTO CORRESPONDING FIELDS OF TABLE i_cats&lt;/P&gt;&lt;P&gt;    FROM catsdb AS a&lt;/P&gt;&lt;P&gt;   INNER JOIN catsps AS b&lt;/P&gt;&lt;P&gt;      ON a&lt;SUB&gt;counter = b&lt;/SUB&gt;counter&lt;/P&gt;&lt;P&gt;     FOR ALL ENTRIES IN i_data&lt;/P&gt;&lt;P&gt;   WHERE a~arbid  EQ i_data-arbid&lt;/P&gt;&lt;P&gt;     AND a~raufpl EQ i_data-aufpl&lt;/P&gt;&lt;P&gt;     AND a~raplzl EQ i_data-aplzl&lt;/P&gt;&lt;P&gt;     AND a~workdate IN s_wdate&lt;/P&gt;&lt;P&gt;     AND a~status EQ '30'&lt;/P&gt;&lt;P&gt;     AND b~transfer EQ 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I really can' t think of a better way to do this? Help! &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 08:17:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228957#M1208784</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T08:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228958#M1208785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Dont use &lt;STRONG&gt;for all entries&lt;/STRONG&gt; &amp;amp; &lt;STRONG&gt;INTO CORRESPONDING FIELDS OF&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead use Join with three Tables...&lt;/P&gt;&lt;P&gt;Reduce two db hits to 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Way:&lt;/P&gt;&lt;P&gt;Create a Database veiw with all fields of the required table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use the view in use program and Use select on the view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE:Views are buffered at application server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;GP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: GP on Feb 17, 2009 9:23 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 08:19:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228958#M1208785</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T08:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228959#M1208786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One thing that you can do is avoid SELECT * INTO CORRESPONDING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write each column name u want to fetch into &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT col1 col2 .....&lt;/P&gt;&lt;P&gt;INTO TABLE I_CATS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second thing..in internal table I_DATA..if possible delete duplicate entries in case any&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this will help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 08:23:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228959#M1208786</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T08:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228960#M1208787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Prashant, thanks but the i_cats table has many many fields hence I don't think this is feasible ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 08:25:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228960#M1208787</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T08:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228961#M1208788</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;Try this out:&lt;/P&gt;&lt;P&gt;1. Create Database view combining catsdb &amp;amp; catsps.&lt;/P&gt;&lt;P&gt;2. Create secondary index for catsdb using 'aufpl' field&lt;/P&gt;&lt;P&gt;3. Try to squeeze your for all entries table, by sorting it out and delete for any duplicate entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lim...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 08:26:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228961#M1208788</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T08:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228962#M1208789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is always the same task, run the SQL trace, otherwise there is no way to improve the statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the explain, in which way is the statement processed, what index is used, how selective is the access etc. etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Leave the rest of the statement as it is, &lt;STRONG&gt;I do not recommend&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;+ to remove the INTO CORRESPONDING&lt;/P&gt;&lt;P&gt;+ I do not recommend a view&lt;/P&gt;&lt;P&gt;+ and the FOR ALL ENTRIES can also not be removed&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But check, whether the FAE is empty or has a lot of duplicates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 08:57:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228962#M1208789</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T08:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228963#M1208790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When doing the trace, check especially if index CATSDB~6 (by ARBID) is being used for access, this seems to be the best one as far as I can tell by just looking at the table definition. Also check if that index is active in your database.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 09:11:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228963#M1208790</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2009-02-17T09:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228964#M1208791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do not use inner joins and FAE in a single statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can increase the performance by creating a view from CATSDB and CATSPS and secondary index AUFPL for CATSDB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Lucky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 10:42:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228964#M1208791</guid>
      <dc:creator>former_member506713</dc:creator>
      <dc:date>2009-02-17T10:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228965#M1208792</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;a view is a view is a view...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A view is nothing more than a STORED SQL statement (yes, and it can describe a join of tables or other complex staments). But it has nothing to do with performance, neither it's result is STORED anywhere inside the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is no silver bullett to performance like "avoid this, instead do that" (however,  there &lt;/P&gt;&lt;P&gt;are existing best practices about data retrieval - see for the guys in the top list of answers).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the end it's reading from disks into database buffers (and if you are lucky it's already cached there)&lt;/P&gt;&lt;P&gt;minimizing I/O.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ST05 SQL trace gives the ONLY clue what execution path the database is likely to choose.&lt;/P&gt;&lt;P&gt;Start here to improve the statement...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bye&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Feb 2009 13:46:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228965#M1208792</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-18T13:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228966#M1208793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;done&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2009 15:34:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228966#M1208793</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-27T15:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Improving an SQL Statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228967#M1208794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;done&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2009 15:34:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improving-an-sql-statement/m-p/5228967#M1208794</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-27T15:34:42Z</dc:date>
    </item>
  </channel>
</rss>

