<?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: Select Query Perfoemance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883416#M1478987</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We cannot replace OR with IN here.&lt;/P&gt;&lt;P&gt;OR is used with all different fields and not the values for the same field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Apr 2010 18:18:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-04-23T18:18:10Z</dc:date>
    <item>
      <title>Select Query Perfoemance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883412#M1478983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;The below Query is taking 3 minutes to execute. Can anybody suggest me how best I can optimize it. &lt;/P&gt;&lt;P&gt;Even after creating secondary indexes, it takes that much time. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select * from /bic/azfiafo0300 into table int_trns1&lt;/P&gt;&lt;P&gt;                    for all entries in int_mu2&lt;/P&gt;&lt;P&gt;                    where comp_code = int_mu2-comp_code&lt;/P&gt;&lt;P&gt;                    and ( bus_area = int_mu2-bus_area&lt;/P&gt;&lt;P&gt;                    or /bic/zorg = int_mu2-/bic/zorg&lt;/P&gt;&lt;P&gt;                    or costcenter = int_mu2-costcenter )&lt;/P&gt;&lt;P&gt;                    and calday ge int_mu2-datefrom&lt;/P&gt;&lt;P&gt;                    and calday le int_mu2-dateto.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Apr 2010 17:16:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883412#M1478983</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-23T17:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Perfoemance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883413#M1478984</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;Please specify the required fields in select statement instead of select *.&lt;/P&gt;&lt;P&gt;It improves the performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Ramya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Apr 2010 17:30:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883413#M1478984</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-23T17:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Perfoemance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883414#M1478985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, I will be needing all the fields of my table. &lt;/P&gt;&lt;P&gt;There were just 60k records in the table and it takes such a huge time to fetch. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking for a better approach.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Apr 2010 17:34:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883414#M1478985</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-23T17:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Perfoemance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883415#M1478986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;WHERE fields in the order of the secondary index fields.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;indicate the secondary index to use in the SELECT&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: David Funez on Apr 23, 2010 12:15 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Apr 2010 18:14:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883415#M1478986</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-23T18:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Perfoemance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883416#M1478987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We cannot replace OR with IN here.&lt;/P&gt;&lt;P&gt;OR is used with all different fields and not the values for the same field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Apr 2010 18:18:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883416#M1478987</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-23T18:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Perfoemance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883417#M1478988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and calday ge int_mu2-datefrom&lt;/P&gt;&lt;P&gt;and calday le int_mu2-dateto.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and calday beetwen int_mu2-date and int_mu2-dateto&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and calday IN r_dates&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use a new table for the range of dates to improve the performance:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA : BEGIN OF r_dates OCCURS 0,&lt;/P&gt;&lt;P&gt;              sign   TYPE c LENGTH 1,&lt;/P&gt;&lt;P&gt;              option TYPE c LENGTH 2,&lt;/P&gt;&lt;P&gt;              low    TYPE c LENGTH 18,&lt;/P&gt;&lt;P&gt;              high   TYPE c LENGTH 18,&lt;/P&gt;&lt;P&gt;           END OF r_dates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;r_dates-low = int_mu2-date.&lt;/P&gt;&lt;P&gt;r_dates-high = int_mu2-dateto.&lt;/P&gt;&lt;P&gt;r_dates-sign = 'I'.&lt;/P&gt;&lt;P&gt;r_dates-option = 'BT'.&lt;/P&gt;&lt;P&gt;append r_dates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Apr 2010 20:13:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883417#M1478988</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-23T20:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Perfoemance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883418#M1478989</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;Instead of using logical expressions in the where clause, use ranges. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Wenonah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Apr 2010 14:58:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883418#M1478989</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-26T14:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Perfoemance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883419#M1478990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Veera,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to prepare 3 internal tables to perform a clean understandeable instruction to database:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similar too:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;int_mu2_aux1[] = int_mu2.
int_mu2_aux2[] = int_mu2.
int_mu2_aux3[] = int_mu2.

* looking for bus_area
sort int_mu2_aux1 by comp_code bus_area datefrom dateto.
delete adjacent duplicates from int_mu2_aux1 comparing comp_code bus_area datefrom dateto.
if int_mu2_aux1[] is not initial.
select * from /bic/azfiafo0300 into table int_trns1
for all entries in int_mu2_aux1
where comp_code = int_mu2_aux1-comp_code
  and bus_area = int_mu2_aux1-bus_area
  and calday between int_mu2_aux1-datefrom int_mu2_aux1-dateto.
endif.

* looking for internal customer organization
sort int_mu2_aux2 by comp_code /bic/zorg datefrom dateto.
delete adjacent duplicates from int_mu2_aux2 comparing comp_code /bic/zorg datefrom dateto.
if int_mu2_aux2[] is not initial.
select * from /bic/azfiafo0300 into table int_trns1
for all entries in int_mu2_aux2
where comp_code = int_mu2_aux2-comp_code
  and /bic/zorg = int_mu2_aux2-/bic/zorg
  and calday between int_mu2_aux2-datefrom int_mu2_aux2-dateto.
endif.

* looking for cost center
sort int_mu2_aux3 by comp_code costcenter datefrom dateto.
delete adjacent duplicates from int_mu2_aux3 comparing comp_code costcenter datefrom dateto.
if int_mu2_aux3[] is not initial.
select * from /bic/azfiafo0300 into table int_trns1
for all entries in int_mu2_aux3
where comp_code = int_mu2_aux3-comp_code
  and costcenter = int_mu2_aux3-costcenter
  and calday between int_mu2_aux3-datefrom int_mu2_aux3-dateto.
endif.

FREE: int_mu2_aux1, int_mu2_aux2, int_mu2_aux3.

* removing duplicates
sort int_trns1.
delete adjacent duplicates from int_trns1 comparing all fields.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Viewing in that way you may notice that 3 indexes are required to a performatic execution, but you can analyse each one according to number of entries in each auxiliary internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In other hand, since you have a not so huge (60k) table you can fetch from database all records w/o filtering org keys and do it on abap but it may be not a good option since you must recheck it with non performatic binary find due to datefrom/dateto range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, it's important to do the coding acording to data you have on int_trns1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Fernando Da Rós&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---" /&gt;&lt;P&gt;Also, tell us about the keys you used on your secondary index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Fernando Ros on Apr 26, 2010 7:12 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Apr 2010 17:09:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-perfoemance/m-p/6883419#M1478990</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-26T17:09:35Z</dc:date>
    </item>
  </channel>
</rss>

