<?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: buffered tables in join in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933066#M691116</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Siegfried - I wrote a small program based on your code snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ztest MESSAGE-ID 00.

TABLES: t001k, t001w.

PARAMETERS: p_bukrs TYPE t001k-bukrs,
            p_werks TYPE t001w-werks.

DATA: b_bwkey   TYPE t001k-bwkey,
      a_werks   TYPE t001w-werks,

      BEGIN OF itab OCCURS 0,
        bwkey   TYPE t001k-bwkey,
      END   OF itab.

DATA: start     TYPE i,
      end       TYPE i,
      dif       TYPE i,
      count     TYPE i.

DO 5 TIMES.
  CLEAR count.
  GET RUN TIME FIELD start.
  SELECT bwkey
    INTO b_bwkey
    FROM t001k
    WHERE bukrs = p_bukrs.

    SELECT werks
      INTO a_werks
      FROM t001w
      WHERE bwkey = b_bwkey
        AND werks = p_werks.
      count = count + 1.
    ENDSELECT.
  ENDSELECT.
  GET RUN TIME FIELD end.
  dif = end - start.
  WRITE: /001 'Time for nested SELECTs on buffered tables: ', dif,
              'microseconds for', count, 'records'.
ENDDO.

SKIP 1.

DO 5 TIMES.
  CLEAR count.
  GET RUN TIME FIELD start.
  SELECT t001k~bwkey t001w~werks
    INTO (b_bwkey, a_werks)
    FROM t001k JOIN t001w
      ON t001k~bwkey = t001w~bwkey
    WHERE t001k~bukrs = p_bukrs
      AND t001w~werks = p_werks.
    count = count + 1.
  ENDSELECT.
  GET RUN TIME FIELD end.
  dif = end - start.
  WRITE: /001 'Time for JOINED SELECTs on buffered tables: ', dif,
              'microseconds for', count, 'records'.
ENDDO.
SKIP 1.

DO 5 TIMES.
  CLEAR count.
  GET RUN TIME FIELD start.
  SELECT bwkey
    INTO TABLE itab
    FROM t001k
    WHERE bukrs = p_bukrs.
  SELECT werks
    INTO a_werks
    FROM t001w
    FOR ALL ENTRIES IN itab
    WHERE bwkey = itab-bwkey
      AND werks = p_werks.
    count = count + 1.
  ENDSELECT.

  GET RUN TIME FIELD end.
  dif = end - start.
  WRITE: /001 'Time for FOR ALL ENTRIEs on buffered tables:', dif,
              'microseconds for', count, 'records'.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The results were interesting:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the JOIN quite often takes much more time than the nested SELECTS, but other times the times are quite comperable. But the clear winner in this case is FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Oct 2007 14:46:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-17T14:46:27Z</dc:date>
    <item>
      <title>buffered tables in join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933062#M691112</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;Can below select give much poor performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;used tables are buffered tables. i have used them in join, so buffering will be by passed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if so plz suggest other way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a~WERKS INTO TABLE ITAB_WERKS&lt;/P&gt;&lt;P&gt;  FROM T001W as a&lt;/P&gt;&lt;P&gt; inner join T001K as b on a&lt;SUB&gt;bwkey eq b&lt;/SUB&gt;bwkey&lt;/P&gt;&lt;P&gt; WHERE a~WERKS eq p_werks&lt;/P&gt;&lt;P&gt;   and b~bukrs EQ '9101'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 09:28:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933062#M691112</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-17T09:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: buffered tables in join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933063#M691113</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;&amp;lt;b&amp;gt;Database access using Buffer concept&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Buffering allows you to access data quicker by letting you&lt;/P&gt;&lt;P&gt;access it from the application server instead of the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Advantages of buffering&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table buffering increases the performance when the records of the table are read. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As records of a buffered table are read directly from the local buffer of the application server on which the accessing transaction is running, time required to access data is greatly reduced. The access improves by a factor of 10 to 100 depending on the structure of the table and on the exact system configuration. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the storage requirements in the buffer increase due to further data, the data that has not been accessed for the longest time is displaced. This displacement takes place asynchronously at certain times which are defined dynamically based on the buffer accesses. Data is only displaced if the free space in  the buffer is less than a predefined value or the quality of the access is not satisfactory at this time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Entering $TAB in the command field resets the table buffers on the corresponding application server. Only use this command if there are inconsistencies in the buffer. In large systems, it can take several hours to fill the buffers. The performance is considerably reduced during this time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Concept of buffering&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;The R/3 System manages and synchronizes the buffers on the individual application servers. If an application program accesses data of a table, the database interfaces determines whether this data lies in the buffer of the application server. If this is the case, the data is read directly from the buffer. If the data is not in the buffer of the application server, it is read from the database and loaded into the buffer. The buffer can therefore satisfy the next access to this data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The buffering type determines which records of the table are loaded into the buffer of the application server when a record of the table is accessed. There are three different buffering types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With full buffering, all the table records are loaded into the buffer when one record of the table is accessed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With generic buffering, all the records whose left-justified part of the key is the same are loaded into the buffer when a table record is accessed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With single-record buffering, only the record that was accessed is loaded into the buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Synchronizing local buffers&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;The table buffers reside locally on each application server in the system. However, this makes it necessary for the buffer administration to transfer all changes made to buffered objects to all the application servers of the system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If a buffered table is modified, it is updated synchronously in the buffer of the application server from which the change was made. The buffers of the whole network, that is, the buffers of all the other application servers, are synchronized with an asynchronous procedure.&lt;/P&gt;&lt;P&gt;Entries are written in a central database table (DDLOG) after each table modification that could be buffered. Each application server reads these entries at fixed time intervals.&lt;/P&gt;&lt;P&gt;If entries are found that show a change to the data buffered by this server, this data is invalidated. If this data is accessed again, it is read directly from the database. In such an access, the table can then be loaded to the buffer again. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Using buffered tables improves the performance considerably&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bypassing the buffer increases the network considerably&lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM T100 INTO T100_WA&lt;/P&gt;&lt;P&gt;  BYPASSING BUFFER&lt;/P&gt;&lt;P&gt;  WHERE     SPRSL = 'D'&lt;/P&gt;&lt;P&gt;        AND ARBGB = '00'&lt;/P&gt;&lt;P&gt;        AND MSGNR = '999'.&lt;/P&gt;&lt;P&gt;The above mentioned code can be more optimized by using the following code&lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM T100  INTO T100_WA&lt;/P&gt;&lt;P&gt;  WHERE     SPRSL = 'D'&lt;/P&gt;&lt;P&gt;        AND ARBGB = '00'&lt;/P&gt;&lt;P&gt;        AND MSGNR = '999'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;reward if usefull&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 10:11:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933063#M691113</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-17T10:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: buffered tables in join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933064#M691114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the select statement is executed only once in your code to fill that internal table, it does not really matter, since both are customizing tables with a limited number of entries.&lt;/P&gt;&lt;P&gt;Only when repeatedly selecting (e.g. within loops) should you avoid using joins on buffered tables, instead read the single tables into workareas/internal tables and work with the data from there.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 10:59:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933064#M691114</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2007-10-17T10:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: buffered tables in join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933065#M691115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Buffered tables should not be used in joins, because the joins are not reallized by&lt;/P&gt;&lt;P&gt;the SAP buffers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use nested SELECTS:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT bwkey
              INTO b_bwkey
              FROM t001k
              WHERE bukrs = '9101'.

   SELECT werks
                INTO a_werks  
                FROM t001w 
                WHERE bwkey = b_bwkey
                AND      werks = p_werks.

APPEND a_werks TO TABLE itab_werks.

    ENDSELECT.
ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 13:17:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933065#M691115</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-17T13:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: buffered tables in join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933066#M691116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Siegfried - I wrote a small program based on your code snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ztest MESSAGE-ID 00.

TABLES: t001k, t001w.

PARAMETERS: p_bukrs TYPE t001k-bukrs,
            p_werks TYPE t001w-werks.

DATA: b_bwkey   TYPE t001k-bwkey,
      a_werks   TYPE t001w-werks,

      BEGIN OF itab OCCURS 0,
        bwkey   TYPE t001k-bwkey,
      END   OF itab.

DATA: start     TYPE i,
      end       TYPE i,
      dif       TYPE i,
      count     TYPE i.

DO 5 TIMES.
  CLEAR count.
  GET RUN TIME FIELD start.
  SELECT bwkey
    INTO b_bwkey
    FROM t001k
    WHERE bukrs = p_bukrs.

    SELECT werks
      INTO a_werks
      FROM t001w
      WHERE bwkey = b_bwkey
        AND werks = p_werks.
      count = count + 1.
    ENDSELECT.
  ENDSELECT.
  GET RUN TIME FIELD end.
  dif = end - start.
  WRITE: /001 'Time for nested SELECTs on buffered tables: ', dif,
              'microseconds for', count, 'records'.
ENDDO.

SKIP 1.

DO 5 TIMES.
  CLEAR count.
  GET RUN TIME FIELD start.
  SELECT t001k~bwkey t001w~werks
    INTO (b_bwkey, a_werks)
    FROM t001k JOIN t001w
      ON t001k~bwkey = t001w~bwkey
    WHERE t001k~bukrs = p_bukrs
      AND t001w~werks = p_werks.
    count = count + 1.
  ENDSELECT.
  GET RUN TIME FIELD end.
  dif = end - start.
  WRITE: /001 'Time for JOINED SELECTs on buffered tables: ', dif,
              'microseconds for', count, 'records'.
ENDDO.
SKIP 1.

DO 5 TIMES.
  CLEAR count.
  GET RUN TIME FIELD start.
  SELECT bwkey
    INTO TABLE itab
    FROM t001k
    WHERE bukrs = p_bukrs.
  SELECT werks
    INTO a_werks
    FROM t001w
    FOR ALL ENTRIES IN itab
    WHERE bwkey = itab-bwkey
      AND werks = p_werks.
    count = count + 1.
  ENDSELECT.

  GET RUN TIME FIELD end.
  dif = end - start.
  WRITE: /001 'Time for FOR ALL ENTRIEs on buffered tables:', dif,
              'microseconds for', count, 'records'.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The results were interesting:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the JOIN quite often takes much more time than the nested SELECTS, but other times the times are quite comperable. But the clear winner in this case is FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 14:46:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933066#M691116</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-17T14:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: buffered tables in join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933067#M691117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nope,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code is perfectly fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since it's ur intention to bypass buffer that's being done.&lt;/P&gt;&lt;P&gt;In this case there is no other better way .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Nishant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 03:17:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/buffered-tables-in-join/m-p/2933067#M691117</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T03:17:53Z</dc:date>
    </item>
  </channel>
</rss>

