<?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: Performance Select Query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196520#M468857</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;I found your query is perfect,  but one exception there u r giving appending clause, instead of this give into table option and then append these entries in your itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u try to remove Appending clause. Also, in where clause do not give non primary key field, instead remove these entries from resultset itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jogdand M B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Jogdand M B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 May 2007 06:42:23 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-08T06:42:23Z</dc:date>
    <item>
      <title>Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196518#M468855</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;Kindly let me know how can i improve performance of the below query...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT c&lt;SUB&gt;bukrs c&lt;/SUB&gt;waers c&lt;SUB&gt;prctr b&lt;/SUB&gt;kostl &lt;/P&gt;&lt;P&gt;            a&lt;SUB&gt;kstar a&lt;/SUB&gt;versn a~gjahr &lt;/P&gt;&lt;P&gt;            a&lt;SUB&gt;wkg001 a&lt;/SUB&gt;wkg002  a&lt;SUB&gt;wkg003 a&lt;/SUB&gt;wkg004 a&lt;SUB&gt;wkg005 a&lt;/SUB&gt;wkg006 &lt;/P&gt;&lt;P&gt;            a&lt;SUB&gt;wkg007  a&lt;/SUB&gt;wkg008  a&lt;SUB&gt;wkg009 a&lt;/SUB&gt;wkg010 a&lt;SUB&gt;wkg011 a&lt;/SUB&gt;wkg012 &lt;/P&gt;&lt;P&gt;            a&lt;SUB&gt;wkg013 a&lt;/SUB&gt;wkg014   a&lt;SUB&gt;wkg015  a&lt;/SUB&gt;wkg016 &lt;/P&gt;&lt;P&gt;      APPENDING TABLE i_temp &lt;/P&gt;&lt;P&gt;       FROM coss AS a &lt;/P&gt;&lt;P&gt;        JOIN cssl AS b ON a&lt;SUB&gt;objnr = b&lt;/SUB&gt;objnr &lt;/P&gt;&lt;P&gt;        JOIN csks AS c ON b&lt;SUB&gt;kostl = c&lt;/SUB&gt;kostl &lt;/P&gt;&lt;P&gt;       WHERE ( a~lednr EQ '00' &lt;/P&gt;&lt;P&gt;         AND a~versn EQ '000' &lt;/P&gt;&lt;P&gt;         AND b~kostl IN r_ccde &lt;/P&gt;&lt;P&gt;         AND a~wrttp EQ '04' &lt;/P&gt;&lt;P&gt;         AND a~gjahr EQ p_fy &lt;/P&gt;&lt;P&gt;         AND a~kstar GE '0000000000' &lt;/P&gt;&lt;P&gt;         AND a~kstar LE '0000999999' ) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2007 03:20:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196518#M468855</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-08T03:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196519#M468856</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 to remove the inner join and use FOR ALL ENTRIES. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Priyanka.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2007 03:23:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196519#M468856</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-08T03:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196520#M468857</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;I found your query is perfect,  but one exception there u r giving appending clause, instead of this give into table option and then append these entries in your itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u try to remove Appending clause. Also, in where clause do not give non primary key field, instead remove these entries from resultset itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jogdand M B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Jogdand M B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2007 06:42:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196520#M468857</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-08T06:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196521#M468858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You must add KOKRS to both the JOIN and the WHERE:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT DISTINCT c~bukrs c~waers c~prctr b~kostl
                a~kstar a~versn a~gjahr
                a~wkg001 a~wkg002 a~wkg003 a~wkg004 a~wkg005 a~wkg006
                a~wkg007 a~wkg008 a~wkg009 a~wkg010 a~wkg011 a~wkg012
                a~wkg013 a~wkg014 a~wkg015 a~wkg016
  APPENDING TABLE i_temp
  FROM coss AS a
  JOIN cssl AS b ON a~objnr = b~objnr
  JOIN csks AS c ON b~kokrs = c~kokrs AND
                    b~kostl = c~kostl
  WHERE ( a~lednr EQ '00'
    AND a~versn EQ '000'
    AND c~kokrs EQ p_kokrs
    AND b~kostl IN r_ccde
    AND a~wrttp EQ '04'
    AND a~gjahr EQ p_fy
    AND a~kstar GE '0000000000'
    AND a~kstar LE '0000999999' ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2007 13:32:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196521#M468858</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-08T13:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196522#M468859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi santosh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If u use the inner joins the tables will be get linking in the database server..so that only ur performance is slower..For that u have to make the processes in the application server..U need to use the FOR ALL ENTRIES command..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is give the respective fields in one internal table and by using for all entries we can inter link that with another internal table.. Always split the queries and then perform the actions..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if  it's helpful...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2007 04:57:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196522#M468859</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-09T04:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196523#M468860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Santosh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following instructions can be followed while writing SELECT query in ABAP for better performance.&lt;/P&gt;&lt;P&gt;1. Do not use APPENDING clause. Instead have an internal table exactly of the same size as of selection fields and should be there only for select query. So try using INTO TABLE &amp;lt;itab&amp;gt; clause.&lt;/P&gt;&lt;P&gt;2. Select the field in the same sequence in which they are present in the tables in database.&lt;/P&gt;&lt;P&gt;3. Also give the WHERE clause fields in the same sequence as of the database tables.&lt;/P&gt;&lt;P&gt;4. Try to give as many as key fields in the WHERE Clause.&lt;/P&gt;&lt;P&gt;5. Avoid using DISTINCT clause in SELECT query. Instead, have all the entries in an internal table. After SELECT query, sort the table and delete the duplicate entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now for your query, following will result in better performance.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------------------------------------------------------------------" /&gt;&lt;P&gt;DATA RT_KSTART TYPE RANGE OF KSTAR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RT_KSTAR-LOW  = '0000000000'. &lt;/P&gt;&lt;P&gt;RT_KSTAR-HIGH = '0000999999'.&lt;/P&gt;&lt;P&gt;RT_KSTAR-OPTION = 'BT'.&lt;/P&gt;&lt;P&gt;RT_KSTAR-SIGN =  'I'.&lt;/P&gt;&lt;P&gt;APPEND RT_KSTAR. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a&lt;SUB&gt;gjahr a&lt;/SUB&gt;versn a&lt;SUB&gt;kstar  a&lt;/SUB&gt;wkg001 a&lt;SUB&gt;wkg002 a&lt;/SUB&gt;wkg003 a&lt;SUB&gt;wkg004 a&lt;/SUB&gt;wkg005 a~wkg006 &lt;/P&gt;&lt;P&gt;       a&lt;SUB&gt;wkg007 a&lt;/SUB&gt;wkg008 a&lt;SUB&gt;wkg009 a&lt;/SUB&gt;wkg010 a&lt;SUB&gt;wkg011 a&lt;/SUB&gt;wkg012 a&lt;SUB&gt;wkg013 a&lt;/SUB&gt;wkg014 a&lt;SUB&gt;wkg015 a&lt;/SUB&gt;wkg016 &lt;/P&gt;&lt;P&gt;       b~kostl&lt;/P&gt;&lt;P&gt;       c&lt;SUB&gt;bukrs c&lt;/SUB&gt;waers c~prctr  &lt;/P&gt;&lt;P&gt; INTO TABLE i_temp &lt;/P&gt;&lt;P&gt; FROM coss AS a &lt;/P&gt;&lt;P&gt;     INNER JOIN cssl AS b ON b&lt;SUB&gt;objnr = a&lt;/SUB&gt;objnr &lt;/P&gt;&lt;P&gt;     INNER JOIN csks AS c ON c&lt;SUB&gt;kostl = b&lt;/SUB&gt;kostl&lt;/P&gt;&lt;P&gt; WHERE a~lednr EQ '00'     AND&lt;/P&gt;&lt;P&gt;       a~gjahr EQ p_fy     AND&lt;/P&gt;&lt;P&gt;       a~wrttp EQ '04'     AND&lt;/P&gt;&lt;P&gt;       a~versn EQ '000'    AND&lt;/P&gt;&lt;P&gt;       a~kstar IN RT_KSTAR AND&lt;/P&gt;&lt;P&gt;       b~kostl IN r_ccde. &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this sort out your issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS If the answer solves your query, plz close the thread by rewarding each reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2007 13:47:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196523#M468860</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-09T13:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196524#M468861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Santosh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is so much wrong with your query that I do not know where to begin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Never use DISTINCT in your select because it bypasses the SAP buffer and forces a sort at the database level. Using this in conjunction to 2 joins is even worse. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) In my personal openion joins are not the way to go about your queries. Very often they are slow. I would recommend that you make separate selects on each table and use FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) There is no index (provided by SAP) on field OBJNR in table CSSL. Check your system and see if somebody has already created a Z index on this field. This is a biggy because you are doing a sequential search on this table for all the entries in found in table COSS. The performance of this query will be greatly improved if you can create a Z index on this table for fields OBJNR and GJAHR. However you need to remember that indexes will only increase your database size. You will have to choose between the performance and database size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) I also noticed that you are asking the user to only enter the year in the selection screen. I assume 'P_FY' is a parameter. You would help the performance of this query by asking the user to enter more information on the screen. Getting information like KOKRS, KOSTL and LSTAR if possible would be invaluable in constructing a more efficient query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5) Use the KOKRS you get from table CSSL to get data from table CSKS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2007 14:12:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196524#M468861</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-09T14:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196525#M468862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;buddy...,&lt;/P&gt;&lt;P&gt;select distint is not good in effeciency. so best thing you can do is write normal SELECT and then sort and delete adjacent duplicates..,the reason why i am telling this is..., this entair process of comparisons will be done in database..., which will decrease performance of database..., sacrifying application server if better to sacrify data base server...,&lt;/P&gt;&lt;P&gt;reward me if useful...,&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;&lt;P&gt;Harish&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Harish AGINATI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Harish AGINATI&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2007 13:41:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196525#M468862</guid>
      <dc:creator>harishaginati</dc:creator>
      <dc:date>2007-05-10T13:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196526#M468863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The issue still persists, some more  light on this would help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers..&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 05:48:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196526#M468863</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T05:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196527#M468864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Remove the inner join and try create views and make the select query from the same..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 05:54:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-select-query/m-p/2196527#M468864</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T05:54:42Z</dc:date>
    </item>
  </channel>
</rss>

