<?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: Problem with JOIN statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410544#M1048062</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alex,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the query for the first join from mkpf and mseg, the entries based on the condition &lt;/P&gt;&lt;P&gt;head&lt;SUB&gt;mblnr = item&lt;/SUB&gt;mblnr AND&lt;/P&gt;&lt;P&gt;head&lt;SUB&gt;mjahr = item&lt;/SUB&gt;mjahr ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the line items that are matching this condition in both tables will be picked up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then from this result,  based on this condition &lt;/P&gt;&lt;P&gt;item&lt;SUB&gt;matnr = mat&lt;/SUB&gt;matnr, all the line items, matching between the preivous result and mara table is fetched into the table t_goods_issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;suggestion: If you need to use this query in your program, better thing is to write seperate select query for each table, avoid the join and loop at the item table and read the other tables is the best way for good performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shobana.K&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Sep 2008 12:21:58 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-09-17T12:21:58Z</dc:date>
    <item>
      <title>Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410541#M1048059</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;Does anyone have an idea on what the JOIN statement does below?  This is not an inner join, im not sure if it's an outer join because the join type has not been specified.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT head~mblnr&lt;/P&gt;&lt;P&gt;              head~budat&lt;/P&gt;&lt;P&gt;              item~matnr&lt;/P&gt;&lt;P&gt;              item~menge&lt;/P&gt;&lt;P&gt;              item~kunnr&lt;/P&gt;&lt;P&gt;              item~werks&lt;/P&gt;&lt;P&gt;    FROM ( mkpf AS head JOIN mseg AS item&lt;/P&gt;&lt;P&gt;      ON head&lt;SUB&gt;mblnr = item&lt;/SUB&gt;mblnr AND&lt;/P&gt;&lt;P&gt;         head&lt;SUB&gt;mjahr = item&lt;/SUB&gt;mjahr ) JOIN mara AS mat&lt;/P&gt;&lt;P&gt;      ON item&lt;SUB&gt;matnr = mat&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;    INTO TABLE t_goods_issue&lt;/P&gt;&lt;P&gt;   WHERE head~budat IN r_date AND&lt;/P&gt;&lt;P&gt;         item~werks IN lr_werks  AND&lt;/P&gt;&lt;P&gt;         item~bwart IN s_bwart  AND&lt;/P&gt;&lt;P&gt;         item~matnr IN s_matnr  AND&lt;/P&gt;&lt;P&gt;         mat~mtart  IN s_mtart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-AJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2008 07:05:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410541#M1048059</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-17T07:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410542#M1048060</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;if it is not specified, that means it is an INNER JOIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will have as many lines, as many you have in MSEG (MKPF and MARA will be joined to each MSEG lines)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;ec&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2008 07:10:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410542#M1048060</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2008-09-17T07:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410543#M1048061</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;The select query you specified used inner join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) First mkpf and mseg is joined based on mblnr and mjahr and afterwards output of join joined with another table mara based on matnr of mara and matnr of mseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Naveen Kumar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2008 11:26:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410543#M1048061</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-17T11:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410544#M1048062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alex,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the query for the first join from mkpf and mseg, the entries based on the condition &lt;/P&gt;&lt;P&gt;head&lt;SUB&gt;mblnr = item&lt;/SUB&gt;mblnr AND&lt;/P&gt;&lt;P&gt;head&lt;SUB&gt;mjahr = item&lt;/SUB&gt;mjahr ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the line items that are matching this condition in both tables will be picked up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then from this result,  based on this condition &lt;/P&gt;&lt;P&gt;item&lt;SUB&gt;matnr = mat&lt;/SUB&gt;matnr, all the line items, matching between the preivous result and mara table is fetched into the table t_goods_issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;suggestion: If you need to use this query in your program, better thing is to write seperate select query for each table, avoid the join and loop at the item table and read the other tables is the best way for good performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shobana.K&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2008 12:21:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410544#M1048062</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-17T12:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410545#M1048063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;better thing is to write seperate select query for each table, avoid the join and loop at the item table and read the other tables is the best way for good performance.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do you have any proof or just feel so?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2008 12:46:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410545#M1048063</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2008-09-17T12:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410546#M1048064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; do you have any proof or just feel so?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If he would have such a proof, then he would have not only 14 points ..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 09:28:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410546#M1048064</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-19T09:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410547#M1048065</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;Is this the way educated people respect each other.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;feel bad this education and forum points has taught only these things to you all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shobana.K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 10:59:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410547#M1048065</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-19T10:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410548#M1048066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;If he would have such a proof, then he would have not only 14 points ..&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although his contribution was not correct, this was not nice to say ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Valter Oliveira.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 11:04:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410548#M1048066</guid>
      <dc:creator>valter_oliveira</dc:creator>
      <dc:date>2008-09-19T11:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410549#M1048067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eric ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is it...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joins in the FROM Clause&lt;/P&gt;&lt;P&gt;You can read data from more than one database table in a single SELECT statement by using inner or left outer joins in the FROM clause. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The disadvantage of using joins is that redundant data is read from the hierarchically-superior table if there is a 1:N relationship between the outer and inner tables. This can considerably increase the amount of data transferred from the database to the application server. Therefore, when you program a join, you should ensure that the SELECT clause contains a list of only the columns that you really need. Furthermore, joins bypass the table buffer and read directly from the database. For this reason, you should use an ABAP Dictionary view instead of a join if you only want to read the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The runtime of a join statement is heavily dependent on the database optimizer, especially when it contains more than two database tables. However, joins are nearly always quicker than using nested SELECT statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you dont believe me , this was taken from SAP help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally to reduce direct hit to database table directly many time , it is prefered we dont use the joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shobana.K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 11:05:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410549#M1048067</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-19T11:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410550#M1048068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shobana,&lt;/P&gt;&lt;P&gt;while this quote cannot be ignored, it does not apply to this example. Here, only field BUDAT falls under the redundant 1:N category. If you use the popular FOR ALL ENTRIES approach, you have to redundantly read the key columns from three tables to be able to link the data together later. Also, the involved tables are not buffered, so this is also not a problem here.&lt;/P&gt;&lt;P&gt;Your approach of reading MSEG, MKPF and MARA separately then loop through the MSEG result set and READ TABLE on the other data within the loop (if I understand you correctly) is not OK for this example, since MARA is not used to read data, but only to limit the result set. So you would be reading too many MSEG entries from the database.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 12:07:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410550#M1048068</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-09-19T12:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410551#M1048069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt; The disadvantage of using joins is that redundant data is read from the hierarchically-superior table if there is a 1:N relationship between the outer and inner tables. This can considerably increase the amount of data transferred from the database to the application server.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This could be true, but this is defintly not the case here with MKPF and MSEG, and not necessarly the case here with MARA (if there are lots of different materials used in the selected material documents).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt; Therefore, when you program a join, you should ensure that the SELECT clause contains a list of only the columns that you really need.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is true for any SELECT, not just for JOINs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt; Furthermore, joins bypass the table buffer and read directly from the database. For this reason, you should use an ABAP Dictionary view instead of a join if you only want to read the data. The runtime of a join statement is heavily dependent on the database optimizer, especially when it contains more than two database tables.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the important point is here to analyse and test each single case and based on the runtime results make an intelligent decision at the end. However I still have very good experience with JOINs!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt; However, joins are nearly always quicker than using nested SELECT statements.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe this is far away from truth...&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;  If you dont believe me , this was taken from SAP help.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you give a link?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;  Finally to reduce direct hit to database table directly many time , it is prefered we dont use the joins.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I still use them, hope you don't mind &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 12:10:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410551#M1048069</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2008-09-19T12:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410552#M1048070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eric,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is the link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/aa/47349a0f1c11d295380000e8353423/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/aa/47349a0f1c11d295380000e8353423/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;The disadvantage of using joins is that redundant data is read from the hierarchically-superior table if there is a 1:N relationship between the outer and inner tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if this is still accurate with the latest DB versions...maybe Mr. Boes (he just lives up to his last name &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt; or the YukonKid can clarify.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. also using JOINS effectively for many years...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 12:30:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410552#M1048070</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-09-19T12:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410553#M1048071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Thomas! The above sentecen I also found in SAPHelp on my own. I would be interested in getting the origin of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;However, joins are nearly always quicker than using nested SELECT statements.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This the last sentece from Shobana's post before:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;If you dont believe me , this was taken from SAP help.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 12:36:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410553#M1048071</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2008-09-19T12:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410554#M1048072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; However, joins are nearly always quicker than using nested SELECT statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;same link, last sentence in chapter "Joins in the FROM Clause".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or am I missing something?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 12:45:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410554#M1048072</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-09-19T12:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410555#M1048073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I got it. Sorry, my fault, I completely misunderstood and was searching for that in 4.7 Help where this sentence is really missing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 12:50:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410555#M1048073</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2008-09-19T12:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410556#M1048074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;gt; &amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt; However, joins are nearly always quicker than using nested SELECT statements.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I believe this is far away from truth...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I misread, of course JOINs are faster than nested SELECTs, sorry everyone!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 12:52:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410556#M1048074</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2008-09-19T12:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410557#M1048075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's Friday afternoon, what can you do... &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 13:32:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410557#M1048075</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-09-19T13:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410558#M1048076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the information and correcting me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Shobana.K&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Sep 2008 12:43:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410558#M1048076</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-20T12:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410559#M1048077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ask myself: why should anybody use table joining anymore because it is so inefficient &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a Join adict and  favor joins (if the statement can expressed with them) over nested SELECTS .&lt;/P&gt;&lt;P&gt;While subqueries (or nested SELECTs) and joins can be very similar in terms of formulating a SQL &lt;/P&gt;&lt;P&gt;statement over several tables, nested SELECTS tend to be come out with more complex queries , &lt;/P&gt;&lt;P&gt;hence the optimizer has more work to do and probably is exposed to fail in choosing the best execution plan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joins can be expressed very easily and if you indexed the join fields well in the involved tables (and some fields that you use as filters in the WHERE) you should outcome with a efficient execution plan. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see 3 important factors wich plan is choosen by the optimizer:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 .Sure data volume on inner or outer table (and filters you apply on these tables in WHERE) are key here: While it seems the statement you quoted assumes always a kind of NESTED LOOP path between outer and inner tables (and moreover this seems to be "dictated" by indexes on the join fields) optimizers are much smarter than that and have lot more choices like Sort merge or hash joins (if they seem more efficient).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. You prefer throughput over response time (wich means you want to have all rows in the fastest way OR you are interested to get the first rows as quick as possible). You can influence this by using the &lt;/P&gt;&lt;P&gt;hints (by OPEN SQL or native). I.e. for ORACLE's CBO  throughput is the default goal wich will prefer &lt;/P&gt;&lt;P&gt;Sort merge or hash joins instead of NESTED LOOPS (wich , in turn, is best for response time)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. You use rule optimization instead of  cost based optimization: This is easy: because rule applies a NESTED LOOPS always when indexes are present (and ignores completyl data volume statsitics), otherwise the sort merge or hash is choosen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While you can find all three of them in databases supported by SAP it may that different databases handle the generating of execution plan different.  Get your ST05 running and check it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some rules (out of others) for join optimization :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- for nested loops &lt;/P&gt;&lt;P&gt;the join index should contain also the fields used in the WHERE clause&lt;/P&gt;&lt;P&gt;while cost based optimizing takes care of join orders of tables (i.e. for a  4 table join you will have 24 possible join orders) if it has sufficient statsitical data, despite of it you can put the driving table with the most selective WHERE into the front. Thus filtering out data not needed at an early join stage&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- for a sort merge/ hash join increase sort memory (database parameters ) and filter out rows not needed early&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bye&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 07:57:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410559#M1048077</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-22T07:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JOIN statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410560#M1048078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry, my response was only a small step further from Erics remark. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If somebody could prove which of the accesses join, nested select or FAE is &lt;STRONG&gt;always the best/optimal&lt;/STRONG&gt; he would easily get a lot of points. He could contact me, if deserved I would convince the responsible persons ... but I think it will never happen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The good thing of my remark was the continuation of the discussion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think, there is no generally best solution for this question (as usually in performance), there are always execptions. I would be more inclined to state that joins are in general the best solution besides some exceptions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;One exception&lt;/STRONG&gt; was mentioned above, the hierarchical relation between the 2 tables:&lt;/P&gt;&lt;P&gt;If that appears, then too much data must be transferred from database to application server for the join:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
table A                  tableB
line_A1                  line_B11         
line_A1                  line_B12
                              ....
line_A1                  line_B1N
line_A2                  line_B21
...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;line_A = selected columns of table A&lt;/P&gt;&lt;P&gt;line_B = selected columns of table B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The information coming from table A is transferred N times identically and this can be an overhead. But maybe N is small or line_B is anyway much larger than line_A, then the overhead is small. About Thomas question, I don't think that new databases change something in this behaviour. The search is faster than with any other access type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Another exception&lt;/STRONG&gt; appears when the optimizer comes to a wrong conclusion for the order in which the tables should be processed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This appears when the ON-conditions have only fields which are not clearly realted to the existion indexes. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assume the join has 3 tables,  the fasted order would be A B and C&lt;/P&gt;&lt;P&gt;but the optimizer decides to use a different order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then a FAE with the order A, B and C can be faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT very often it is possible to influence the optimizer, for example with a hint, to use the order A B and C and then the join is again faster than the FAE. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No proof, no example, just my opinion. I would be interested to hear others.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 14:43:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-join-statement/m-p/4410560#M1048078</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-22T14:43:03Z</dc:date>
    </item>
  </channel>
</rss>

