<?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: Inner Join and performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001975#M1344461</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does it mean  "buffered table" ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please some example for - &amp;gt; to use the buffer and remove the table from the join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Aug 2009 12:56:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-08-14T12:56:10Z</dc:date>
    <item>
      <title>Inner Join and performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001972#M1344458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have similar SQL, which is running long time&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT x&lt;SUB&gt;kunnr x&lt;/SUB&gt;matnr x&lt;SUB&gt;vtweg x&lt;/SUB&gt;datbi&lt;/P&gt;&lt;P&gt;               z~knumh&lt;/P&gt;&lt;P&gt;    APPENDING CORRESPONDING FIELDS OF TABLE t_acust&lt;/P&gt;&lt;P&gt;    FROM yhdwt_004 AS x INNER JOIN knvv AS y&lt;/P&gt;&lt;P&gt;      ON  x&lt;SUB&gt;kunnr = y&lt;/SUB&gt;kunnr&lt;/P&gt;&lt;P&gt;      AND x&lt;SUB&gt;vkorg = y&lt;/SUB&gt;vkorg&lt;/P&gt;&lt;P&gt;      AND x&lt;SUB&gt;vtweg = y&lt;/SUB&gt;vtweg&lt;/P&gt;&lt;P&gt;                   INNER JOIN a950 AS z&lt;/P&gt;&lt;P&gt;      ON  y&lt;SUB&gt;vkbur = z&lt;/SUB&gt;vkbur&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    WHERE z~kappl = 'V '&lt;/P&gt;&lt;P&gt;      AND z~kschl IN ('Z950', 'Z954')&lt;/P&gt;&lt;P&gt;      AND z~datbi IN lr_datbi&lt;/P&gt;&lt;P&gt;      AND z~datab IN lr_datab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and my question - &amp;gt; Can we say that order of tables in select is important for performance (maybe optimalizator do select for first and second tables and after that third )?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    FROM yhdwt_004 AS x INNER JOIN knvv AS y  INNER JOIN a950 AS z&lt;/P&gt;&lt;P&gt;    FROM knvv AS x INNER JOIN yhdwt_004 AS y  INNER JOIN a950 AS z&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yhdwt_004 - several million rows&lt;/P&gt;&lt;P&gt;knvv           - several hundred thousend rows &lt;/P&gt;&lt;P&gt;a950           - thousend rows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for feedback&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 12:28:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001972#M1344458</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-14T12:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join and performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001973#M1344459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use [ST05|https://forums.sdn.sap.com/search.jspa?objID=f234&amp;amp;q=ST05] and run your report in different versions to get some information to compare. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also &lt;SPAN __jive_macro_name="thread" id="1283414"&gt;&lt;/SPAN&gt; and perform some search with keywords [join order table select |https://wiki.sdn.sap.com/wiki/dosearchsite.action?searchQuery.queryString=join&lt;EM&gt;order&lt;/EM&gt;table+select&amp;amp;searchQuery.spaceKey=conf_global]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 12:45:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001973#M1344459</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2009-08-14T12:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join and performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001974#M1344460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the order of tables in joins is not important in the coding: Normally the opitmizer determines the join order based on statistics. The order of the tables in the coding is not important.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However when it comes to the execution on the database the order of the table is very important. But the opitmizer should be able to figure out the best order. If not you might want to help the optimizer and only then the order of the tables might be important as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So first start with reading the execution plan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What order does the optimzer choose? And what join type does the optimzer choose? (Nested Loops, Sort Merge or Hash?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Nested Loops the optimizer should start with the smallest RESULTSET (not necessarily the smalles table). Map your WHERE conditions to the tables to see which table has the smalles result set. For nested loops make sure the optimizer starts here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More things to check: Do you have index support for where and Join donditions? Is any table a buffered table (A950?) if so, try to youse the buffer and remove the table from the join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hermann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 12:46:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001974#M1344460</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2009-08-14T12:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join and performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001975#M1344461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does it mean  "buffered table" ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please some example for - &amp;gt; to use the buffer and remove the table from the join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 12:56:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001975#M1344461</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-14T12:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join and performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001976#M1344462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can check the buffer settings in transaction SE13.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But again, more important is that your nested loop joins start with the &lt;/P&gt;&lt;P&gt;smallest result set. So work that out first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Generally your where and join conditions should be supported with indexes (for often executed sql statements)&lt;/P&gt;&lt;P&gt;and generally you should not access buffered tables in joins (since the buffer can not be used).&lt;/P&gt;&lt;P&gt;In such a case do the join select on the other tables and then access the buffered table e.g. in a loop&lt;/P&gt;&lt;P&gt;over the result set from the join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hermann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 13:06:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001976#M1344462</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2009-08-14T13:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join and performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001977#M1344463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in principle the order should not have an influence, but I am not 100% sure that it can not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Still I would always recommend you the following order, a is the smallest table and only one with conditions in WHERE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FROM          a950 AS a
INNER JOIN  knvv AS b
ON b~vkbur = a~vkbur
INNER JOIN   yhdwt_004 AS c 
ON    c~kunnr = b~kunnr
AND c~vkorg  = b~vkorg
AND c~vtweg = b~vtweg
WHERE a~kschl IN ('Z950', 'Z954')
AND     a~datbi IN lr_datbi
AND     a~datab IN lr_datab
AND     a~kappl = 'V '
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 13:25:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001977#M1344463</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-14T13:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join and performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001978#M1344464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Probable Cause of Issue&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You say that your custom table YHDWT_004 has several million records yet you do not seem to be restricting records on this table. Based on the way you have constructed your query, I am led to believe that you are iterating through all the records in the huge custom table.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Recommended Solution&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1) Your where clause seems to be restricting only table A950. It makes sense starting with this table first so as to limit your iterations. Construct your query in the following dircetion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A950 -&amp;gt; KNVV -&amp;gt; YHDWT_004.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Evaluate the possibility of creating an index on database table YHDWT_004 on the fields KUNNR VKORG and VTWEG (if such an index does not already exist).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 14:05:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-and-performance/m-p/6001978#M1344464</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-14T14:05:30Z</dc:date>
    </item>
  </channel>
</rss>

