<?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: Optimising inner join in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607216#M868938</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;Dont MIN get all the values from the EKET then sort it  take the first record&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  eket~eindt &lt;/P&gt;&lt;P&gt;INTO table dDelivery&lt;/P&gt;&lt;P&gt;FROM ( ekpo INNER JOIN eket&lt;/P&gt;&lt;P&gt;ON eket&lt;SUB&gt;ebeln EQ ekpo&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;AND eket&lt;SUB&gt;ebelp EQ ekpo&lt;/SUB&gt;ebelp &lt;/P&gt;&lt;P&gt;INNER JOIN ekko&lt;/P&gt;&lt;P&gt;ON ekpo&lt;SUB&gt;ebeln EQ ekko&lt;/SUB&gt;ebeln )&lt;/P&gt;&lt;P&gt;WHERE ekpo~loekz EQ space&lt;/P&gt;&lt;P&gt;AND ekpo~matnr EQ ZSales_wa-matnr&lt;/P&gt;&lt;P&gt;AND ekpo~elikz EQ space&lt;/P&gt;&lt;P&gt;AND eket~eindt &amp;gt; dHTMLdatum&lt;/P&gt;&lt;P&gt;AND ekko~ekorg EQ vkorg_wa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort dDelivery by eindt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table dDelivery index 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Mar 2008 10:28:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-25T10:28:34Z</dc:date>
    <item>
      <title>Optimising inner join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607215#M868937</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;I need to write a report that will show the next delivery that is due to arrive for a certain article and purchasing organisation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current SQL query is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT min( eket~eindt )&lt;/P&gt;&lt;P&gt;      INTO dDelivery&lt;/P&gt;&lt;P&gt;      FROM ( ekpo INNER JOIN eket&lt;/P&gt;&lt;P&gt;                     ON eket&lt;SUB&gt;ebeln EQ ekpo&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;                    AND eket&lt;SUB&gt;ebelp EQ ekpo&lt;/SUB&gt;ebelp &lt;/P&gt;&lt;P&gt;                  INNER JOIN ekko&lt;/P&gt;&lt;P&gt;                     ON ekpo&lt;SUB&gt;ebeln EQ ekko&lt;/SUB&gt;ebeln )&lt;/P&gt;&lt;P&gt;      WHERE ekpo~loekz EQ space&lt;/P&gt;&lt;P&gt;        AND ekpo~matnr EQ ZSales_wa-matnr&lt;/P&gt;&lt;P&gt;        AND ekpo~elikz EQ space&lt;/P&gt;&lt;P&gt;        AND eket~eindt &amp;gt; dHTMLdatum&lt;/P&gt;&lt;P&gt;        AND ekko~ekorg EQ vkorg_wa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From where I am sitting this looks like it will take too much time to run for all articles.&lt;/P&gt;&lt;P&gt;Is there a better way to get the information (a function perhaps?) or otherwise a way I can optimise this selection?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Charl&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 10:21:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607215#M868937</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T10:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising inner join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607216#M868938</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;Dont MIN get all the values from the EKET then sort it  take the first record&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  eket~eindt &lt;/P&gt;&lt;P&gt;INTO table dDelivery&lt;/P&gt;&lt;P&gt;FROM ( ekpo INNER JOIN eket&lt;/P&gt;&lt;P&gt;ON eket&lt;SUB&gt;ebeln EQ ekpo&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;AND eket&lt;SUB&gt;ebelp EQ ekpo&lt;/SUB&gt;ebelp &lt;/P&gt;&lt;P&gt;INNER JOIN ekko&lt;/P&gt;&lt;P&gt;ON ekpo&lt;SUB&gt;ebeln EQ ekko&lt;/SUB&gt;ebeln )&lt;/P&gt;&lt;P&gt;WHERE ekpo~loekz EQ space&lt;/P&gt;&lt;P&gt;AND ekpo~matnr EQ ZSales_wa-matnr&lt;/P&gt;&lt;P&gt;AND ekpo~elikz EQ space&lt;/P&gt;&lt;P&gt;AND eket~eindt &amp;gt; dHTMLdatum&lt;/P&gt;&lt;P&gt;AND ekko~ekorg EQ vkorg_wa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort dDelivery by eindt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table dDelivery index 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 10:28:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607216#M868938</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T10:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising inner join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607217#M868939</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;Santosh, your example seems to show the advantage of FOR ALL ENTRIES over a select/endselect.&lt;/P&gt;&lt;P&gt;Even in the example the double INNER JOIN is used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will you be able to provide an example based on what I have written to convert the INNER JOIN to FOR ALL ENTRIES and explain why it is faster/better?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shivakumar, I use a similar tactic in other areas, but could you explain why your example is better to use in this case? Either way I end up with only one result. Yours I gain a bit more control over results checking, which I like, but I also end up using more memory and data has to go between SQL and my presentation server does it not?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the quick responses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 11:09:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607217#M868939</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T11:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising inner join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607218#M868940</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;It is not recommended to use MIN MAX commands which take more time&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since  the tables are inter related and also  they  are  header and item  table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;recently  i improved the performance for the same using the tables only&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if the tables are header and item it would be better to use joins rather than for all entries &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one thing i want to say it is trial and error method to get the perfect performance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can have for all entries for EKKO EKPO into one table and finaly get the EKET EINDT based on FOR all entries of first table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this code which i have written recently&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT a~ebeln          "po number&lt;/P&gt;&lt;P&gt;         b~ebelp          "po item&lt;/P&gt;&lt;P&gt;         b~werks          "plant&lt;/P&gt;&lt;P&gt;         b~matkl          "material grp&lt;/P&gt;&lt;P&gt;         b~matnr          "material&lt;/P&gt;&lt;P&gt;         b~menge          "qty&lt;/P&gt;&lt;P&gt;         b~meins          "unit&lt;/P&gt;&lt;P&gt;         b~peinh          "price unit&lt;/P&gt;&lt;P&gt;         b~bprme          "Order Price Unit&lt;/P&gt;&lt;P&gt;         b~netpr          "net price&lt;/P&gt;&lt;P&gt;         b~retpo&lt;/P&gt;&lt;P&gt;         b~loekz&lt;/P&gt;&lt;P&gt;         b~elikz&lt;/P&gt;&lt;P&gt;         a~lifnr&lt;/P&gt;&lt;P&gt;         c~wemng&lt;/P&gt;&lt;P&gt;         c~eindt&lt;/P&gt;&lt;P&gt;         INTO TABLE lt_ekpo&lt;/P&gt;&lt;P&gt;   FROM  ekpo AS b&lt;/P&gt;&lt;P&gt;  INNER&lt;/P&gt;&lt;P&gt;   JOIN ekko AS a&lt;/P&gt;&lt;P&gt;     ON a&lt;SUB&gt;ebeln = b&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;  INNER&lt;/P&gt;&lt;P&gt;   JOIN eket AS c&lt;/P&gt;&lt;P&gt;     ON c&lt;SUB&gt;ebeln = b&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;    AND c&lt;SUB&gt;ebelp = b&lt;/SUB&gt;ebelp&lt;/P&gt;&lt;P&gt;  WHERE a~lifnr IN ilifnr1&lt;/P&gt;&lt;P&gt;    AND b~werks IN s_werks&lt;/P&gt;&lt;P&gt;    AND b~matkl IN imatkl1&lt;/P&gt;&lt;P&gt;    AND c~eindt IN ideldate&lt;/P&gt;&lt;P&gt;    AND a~bukrs EQ 'ULTA'&lt;/P&gt;&lt;P&gt;    AND a~bsart EQ 'NB'&lt;/P&gt;&lt;P&gt;    AND a~frgke NE 'B'&lt;/P&gt;&lt;P&gt;    AND b~retpo NE 'X'&lt;/P&gt;&lt;P&gt;    AND b~loekz NE 'L'&lt;/P&gt;&lt;P&gt;    AND b~elikz NE 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 11:18:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607218#M868940</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T11:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising inner join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607219#M868941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Shiva.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One last bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does the structure of the INNER JOIN influence the performance at all?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 12:06:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607219#M868941</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T12:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising inner join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607220#M868942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry  I dont have much idea &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 12:15:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607220#M868942</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T12:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising inner join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607221#M868943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; Use FOR ALL ENTRIES statement instead of joins ..&lt;/P&gt;&lt;P&gt;&amp;gt; Check out the below link for a sample code for usage&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;A href="http://www.sap-img.com/abap/usage-of-for-all-entries-in-select-statement.htm" target="test_blank"&gt;http://www.sap-img.com/abap/usage-of-for-all-entries-in-select-statement.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;completely weird recommendation, the example has a very complicated join and&lt;/P&gt;&lt;P&gt;additional FOR ALL ENTRIES ! From that example you can conclude nothing for the&lt;/P&gt;&lt;P&gt;problem here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Use FOR ALL ENTRIES statement instead of joins &lt;/P&gt;&lt;P&gt;this in incorrect, joins can be much better than for all entries, but only up to about 5 tables.&lt;/P&gt;&lt;P&gt;With more tables the optimizer will often not find the right order to process the tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you should start with the simple select:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT *
INTO it_ekpo
FROM  ekpo 
WHERE ekpo~loekz EQ space
AND ekpo~matnr EQ ZSales_wa-matnr
AND ekpo~elikz EQ space.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;compared to the join. I think already this select will not be very fast as there is no good index support.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Run both in your system and check the SQL trace&lt;/P&gt;&lt;P&gt;/people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The join conditions are quite simple on primary keys and should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 12:41:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607221#M868943</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T12:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising inner join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607222#M868944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Siegfried.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll keep it as is then.&lt;/P&gt;&lt;P&gt;When time allows I'll separate the segments of code and experiment with the SQL trace. Nice blog entry.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 13:30:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-inner-join/m-p/3607222#M868944</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T13:30:54Z</dc:date>
    </item>
  </channel>
</rss>

