<?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: Efficient Sql Query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900784#M55149</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kelly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case, the most efficient sql query is to use 'FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;Ideally Inner join is more efficient when compared to 'FOR ALL ENTRIES' only if there the number of DB tables in the INNER JOIN is less that or equal to 3.&lt;/P&gt;&lt;P&gt;If you want to fetch from say 4 or 5 tables which have primary and foreign key relationship, its better not to go with INNER JOIN bcoz the number of tuples will be more and its not advisable to use it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this gives you added info.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santhosh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Feb 2005 06:34:49 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-02-28T06:34:49Z</dc:date>
    <item>
      <title>Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900778#M55143</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 want to extract header details from table1 and according to that some deatiled fields from table2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;So without using Innerjoin and nested Sql statements what are the rules to write an efficient sql query?&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Kelly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2005 16:36:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900778#M55143</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-25T16:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900779#M55144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My first choice would be an interjoin,  what since you  are looking for something else,  maybe you could select you header data into itab a,  then do a "select for all entries in itab a" from the second table into itab b.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2005 16:40:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900779#M55144</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-02-25T16:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900780#M55145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is an example,  i still think that an inner join would be more efficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0004
       no standard page heading.

data: begin of imara occurs 0,
      matnr type mara-matnr,
      mtart type mara-mtart,
      end of imara.

data: begin of imarc occurs 0,
      matnr type marc-matnr,
      werks type marc-werks,
      end of imarc.

* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.

start-of-selection.

  select * into corresponding fields of table imara
           from mara
                   where matnr in s_matnr.

  sort imara ascending by matnr.

  check not imara[] is initial.

  select * into corresponding fields of table imarc
           from marc
             for all entries in imara
                   where matnr = imara-matnr.


  loop at imara.
    write:/ imara-matnr, imara-mtart.
    loop at imarc where matnr = imara-matnr.
      write:/ imarc-matnr, imarc-werks.
    endloop.
  endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2005 16:50:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900780#M55145</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-02-25T16:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900781#M55146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If these are SAP tables, you can search for an existing data dictionary join using SE84 - Repository Browser.  Is there some reason why a join is not good for your requirements?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2005 17:03:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900781#M55146</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-25T17:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900782#M55147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kelly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you considered the option of using Extract datasets / field-groups ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anand Mandalika.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2005 05:22:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900782#M55147</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-28T05:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900783#M55148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;REPORT yanswer .&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;copy this code and run.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*it is recomended that if you want to extract fields from multiple&lt;/P&gt;&lt;P&gt;*table and there is primary and foeign key relationship b/w tables then&lt;/P&gt;&lt;P&gt;*joins are the best solutions (performance wise).&lt;/P&gt;&lt;P&gt;*here is an other solution.&lt;/P&gt;&lt;P&gt;*we have two table scarr which have following columns.&lt;/P&gt;&lt;P&gt;*carrid    (primary key).&lt;/P&gt;&lt;P&gt;*carrname&lt;/P&gt;&lt;P&gt;*currcode&lt;/P&gt;&lt;P&gt;*url&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*we have another table spfly which have following columns.&lt;/P&gt;&lt;P&gt;*carrid    (foreign key).&lt;/P&gt;&lt;P&gt;*connid&lt;/P&gt;&lt;P&gt;*cityfrom&lt;/P&gt;&lt;P&gt;*cityto.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES: scarr,spfli.&lt;/P&gt;&lt;P&gt;DATA wa_scarr TYPE scarr.&lt;/P&gt;&lt;P&gt;DATA wa_spfli TYPE spfli.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT carrid carrname currcode FROM scarr&lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF  wa_scarr.&lt;/P&gt;&lt;P&gt;  SELECT carrid connid cityfrom cityto FROM spfli&lt;/P&gt;&lt;P&gt;    INTO CORRESPONDING FIELDS OF wa_spfli&lt;/P&gt;&lt;P&gt;    WHERE carrid = wa_scarr-carrid.&lt;/P&gt;&lt;P&gt;    IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      WRITE: / wa_scarr-carrid, wa_scarr-carrname, wa_scarr-currcode,&lt;/P&gt;&lt;P&gt;wa_spfli-cityfrom,&lt;/P&gt;&lt;P&gt;  wa_spfli-cityto.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2005 06:19:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900783#M55148</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-28T06:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900784#M55149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kelly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case, the most efficient sql query is to use 'FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;Ideally Inner join is more efficient when compared to 'FOR ALL ENTRIES' only if there the number of DB tables in the INNER JOIN is less that or equal to 3.&lt;/P&gt;&lt;P&gt;If you want to fetch from say 4 or 5 tables which have primary and foreign key relationship, its better not to go with INNER JOIN bcoz the number of tuples will be more and its not advisable to use it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this gives you added info.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santhosh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2005 06:34:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900784#M55149</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-28T06:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900785#M55150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;REPORT yanswer .&lt;/P&gt;&lt;P&gt;*here spfli is parent table sflight table.&lt;/P&gt;&lt;P&gt;*spfli has composit primary key on carrid and connid&lt;/P&gt;&lt;P&gt;*and sflight has foreign key on carrid and connid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES: spfli, sflight.&lt;/P&gt;&lt;P&gt;PARAMETERS pa_carr TYPE spfli-carrid.&lt;/P&gt;&lt;P&gt;PARAMETERS pa_conn TYPE spfli-connid.&lt;/P&gt;&lt;P&gt;DATA wa_sflight TYPE sflight.&lt;/P&gt;&lt;P&gt;SELECT fldate price seatsmax seatsocc FROM sflight&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF wa_sflight&lt;/P&gt;&lt;P&gt;WHERE carrid = pa_carr AND connid = pa_conn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WRITE : / wa_sflight-fldate, wa_sflight-price,&lt;/P&gt;&lt;P&gt;  wa_sflight-seatsmax, wa_sflight-seatsocc.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2005 07:54:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900785#M55150</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-28T07:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900786#M55151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;REPORT yanswer .&lt;/P&gt;&lt;P&gt;*here spfli is parent table sflight table, spfli has carrid, connid, *cityfrom and cityto column.&lt;/P&gt;&lt;P&gt;*spfli has composit primary key on carrid and connid&lt;/P&gt;&lt;P&gt;*and sflight has foreign key on carrid and connid and has columns *fldate price seatsmax, seatsocc columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES: spfli, sflight.&lt;/P&gt;&lt;P&gt;PARAMETERS pa_carr TYPE spfli-carrid.&lt;/P&gt;&lt;P&gt;PARAMETERS pa_conn TYPE spfli-connid.&lt;/P&gt;&lt;P&gt;DATA wa_sflight TYPE sflight.&lt;/P&gt;&lt;P&gt;DATA wa_spfli TYPE spfli.&lt;/P&gt;&lt;P&gt;SELECT SINGLE cityfrom cityto FROM spfli&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF wa_spfli&lt;/P&gt;&lt;P&gt;WHERE carrid = pa_carr AND connid = pa_conn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT fldate price seatsmax seatsocc FROM sflight&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF wa_sflight&lt;/P&gt;&lt;P&gt;WHERE carrid = pa_carr AND connid = pa_conn.&lt;/P&gt;&lt;P&gt;  WRITE : / wa_sflight-fldate, wa_sflight-price,&lt;/P&gt;&lt;P&gt;  wa_sflight-seatsmax, wa_sflight-seatsocc, wa_spfli-cityfrom,&lt;/P&gt;&lt;P&gt;wa_spfli-cityto.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2005 09:47:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900786#M55151</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-28T09:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900787#M55152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  YOu need to check whether your table, which is used in "FOR ALL ENTRIES", is empty or not. It is always a good practice to check the table for intially condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg : &amp;lt;b&amp;gt;if not itab[] is initial.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;         select &amp;lt;f1&amp;gt;&lt;/P&gt;&lt;P&gt;                &amp;lt;f2&amp;gt;&lt;/P&gt;&lt;P&gt;                 . ....&lt;/P&gt;&lt;P&gt;                into &amp;lt;tab&amp;gt; from &amp;lt;dbtab&amp;gt;&lt;/P&gt;&lt;P&gt;              &amp;lt;b&amp;gt;for all entries in i&amp;lt;/b&amp;gt;tab&lt;/P&gt;&lt;P&gt;          where ....&lt;/P&gt;&lt;P&gt;     &amp;lt;b&amp;gt;endif.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will avoid unnecessary processing of select if the table is blank.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vara&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2005 10:34:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900787#M55152</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-28T10:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900788#M55153</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;Thank you for all the replies... You all were a great help... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I have a doubt. My thinking about InnerJoin was that it will &amp;lt;b&amp;gt;cause overhead&amp;lt;/b&amp;gt; in the database.. will take more time. Isn't it true.. ?&lt;/P&gt;&lt;P&gt;Kelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2005 16:12:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900788#M55153</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-28T16:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900789#M55154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Depends on how you code it and a number of other factors.  I use them all the time,  i've found that performance is better than doing it any other way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2005 16:16:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900789#M55154</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-02-28T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900790#M55155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I would like to know if I had the choice of Innerjoin and extract statements.. which one is more efficient?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2005 21:38:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900790#M55155</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-10T21:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900791#M55156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An innerjoin would be the most efficient way to go.  Also more supportable.  The extract statement is an older technology that is not used much anymore.  Today's ABAPers will understand joins much better than the extract statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2005 22:26:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900791#M55156</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-10T22:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900792#M55157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since extract is a way to handle large data that has already been retrieved from database the question should be: is it more efficient to keep the data in an internal table or to use an extract. &lt;/P&gt;&lt;P&gt;Usually (especially in R2 times) Extract could handle larger amounts of data than internal tables. The data was internally transferred from memory to a kind of dataset (or swap file), sorted and could be retrieved via loop. So memory consumption of the process remained rather low. &lt;/P&gt;&lt;P&gt;Nowadays the meomry management of Operating Systems usually have a more sophisticated and in build memory managment which does the swapping when memory becomes sparse. So in most of the cases Extract (no matter if you want to join different tables or not) should be the second choice. Of course, you can still run into limits of memory but then I prefer rather to redesign the program by reading packages, etc than using extracts. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2005 07:36:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900792#M55157</guid>
      <dc:creator>ChristianFi</dc:creator>
      <dc:date>2005-03-11T07:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900793#M55158</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;You all been great help... I think 'for all entries' is the best way .. .. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanx&lt;/P&gt;&lt;P&gt;kelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2005 19:56:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900793#M55158</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-11T19:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900794#M55159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kelly,&lt;/P&gt;&lt;P&gt;just a few days ago I have done some ABAP tuning in select over large tables - I still think that inner join is the best way, since the database engine has most accurate information on how to optimize the select (temporary sorting, using indices or not etc.). Be aware that "for all entries" statement will actually open Select statement for every single row in the internal table over which you iterate.&lt;/P&gt;&lt;P&gt;Inner join will open the database cursor only once, so you save some time on the select overhead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best way to decide is to use transaction ST05, switch on the SQL trace, and run your program. You will see actual times for each database access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dawood.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Mar 2005 00:45:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900794#M55159</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-12T00:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900795#M55160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another small tip, Kelly: try to avoid &amp;lt;b&amp;gt;INTO CORRESPONDING FIELDS OF&amp;lt;/b&amp;gt; clause. Certainly it is shorter in writing than accurate specification of all the fields you need, but it cause unnecessary move operations.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Mar 2005 21:28:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900795#M55160</guid>
      <dc:creator>sergey_korolev</dc:creator>
      <dc:date>2005-03-12T21:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900796#M55161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dawood,&lt;/P&gt;&lt;P&gt;Actually, &amp;lt;b&amp;gt;for all entries&amp;lt;/b&amp;gt; does not open select for every single row, it processes groups of rows at a time. I used to look into trace list in ST05. Seems that it depends on query buffer size though I do not know for sure.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Mar 2005 21:38:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900796#M55161</guid>
      <dc:creator>sergey_korolev</dc:creator>
      <dc:date>2005-03-12T21:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Sql Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900797#M55162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sergei,&lt;/P&gt;&lt;P&gt;you are probably right, in my case tables were very large and the system has probably splitted the iteration to many groups. I think the limit is 64kB for the Select statement.&lt;/P&gt;&lt;P&gt;The ABAP documentation says:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"The comparison is then performed for each line of the internal table. &amp;lt;b&amp;gt;For each line, the system selects the lines from the database table that satisfy the condition&amp;lt;/b&amp;gt;. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not explained any further, but from the last quoted sentence it seems that there is an extra load on the application-database interface communication (transferring more data than needed) and some extra load on application server itself (comparing and eliminating unnecessary lines).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dawood.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Mar 2005 22:29:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-sql-query/m-p/900797#M55162</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-12T22:29:07Z</dc:date>
    </item>
  </channel>
</rss>

