<?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: SQL performance: Joining FI tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070022#M428691</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Richard,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just a normal report with total of almost 30 variants, not using alv...&lt;/P&gt;&lt;P&gt;but requires calculation..so no choice but to combine everything into a big itab...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem is with the inner join of the 4 tables.&lt;/P&gt;&lt;P&gt;&amp;amp; this is done 2 times.. 1st with bsid.. then 2nd with bsad.. &amp;amp; then both itabs are combined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i realised if i break up this 2 inner join statements into smaller statements and use for all entries... i may encounter other problems..&lt;/P&gt;&lt;P&gt;eg. if i start by inner join kna1 and knb1..&lt;/P&gt;&lt;P&gt;some variants will result in a huge amount of customer data... so for all entries would have problem here&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 17 Mar 2007 09:06:59 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-03-17T09:06:59Z</dc:date>
    <item>
      <title>SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070005#M428674</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'm trying to join the following FI tables into 1 table:&lt;/P&gt;&lt;P&gt;bkpf&lt;/P&gt;&lt;P&gt;kna1&lt;/P&gt;&lt;P&gt;knb1&lt;/P&gt;&lt;P&gt;bsid&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and these into another table:&lt;/P&gt;&lt;P&gt;bkpf&lt;/P&gt;&lt;P&gt;kna1&lt;/P&gt;&lt;P&gt;knb1&lt;/P&gt;&lt;P&gt;bsad&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...so any efficient way of joining these? Current code uses inner joins.. but its causing performance issues.&lt;/P&gt;&lt;P&gt;i'm thinking of using for all entries...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any comments on which method? and why that method? if use for all entries...&lt;/P&gt;&lt;P&gt;what is the order i should start with?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 03:03:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070005#M428674</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T03:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070006#M428675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The amount of data in these tables do cause the performance issue.&lt;/P&gt;&lt;P&gt;The only way to increas the performance is to use all key fields for the tables to extract data.&lt;/P&gt;&lt;P&gt;If this select is calling many times then instead call all the required data from all the tables in 4 different internal tables and do READ statement usng where claue.&lt;/P&gt;&lt;P&gt;This method is still applicable if you just read data from BKPF,BSAD,BSID in the table and use READ on it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward all helpful replies.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 03:14:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070006#M428675</guid>
      <dc:creator>amit_khare</dc:creator>
      <dc:date>2007-03-14T03:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070007#M428676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have answered you in another post, here it is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You first need to understand what is contained in the secondary index tables as compared to the main FI document posting table BKPF. Then you can make a better decision in joining.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The index tables BSID (only customer active postings) and BSAD (only customer and that too cleared postings, huge piles up over time) are much smaller in size compared to BKPF which also contains postings to general ledger, vendor posting and so on. So BSID is subset of BSAD which in turn is subset of BKPF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KNA1 on the other hand is master data table and should be still smaller in size (why because for each customer there may be many FI postings)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also the MOST IMPORTANT point is which fields are available to you for selection? For example, if you have customer number, first join KNA1 with KNB1 and then with BSAD or BSID, then join with BKPF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So tell us the selection fields that are available to you to seed the query&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 03:26:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070007#M428676</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T03:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070008#M428677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all the input. I'll reward after i try them out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'm also taking into consideration this information&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;total no of records in tables:&lt;/P&gt;&lt;P&gt;kna1: 2,356,681&lt;/P&gt;&lt;P&gt;knb1: 6,430,912&lt;/P&gt;&lt;P&gt;bkpf: 30,489,104&lt;/P&gt;&lt;P&gt;bsid: 507,874&lt;/P&gt;&lt;P&gt;bsad: 18,075,629&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;some fields include:&lt;/P&gt;&lt;P&gt;bukrs "Company code, mandatory, usually single value selection&lt;/P&gt;&lt;P&gt;kunnr "Customer No, mandatory, may be single, range or selecting all&lt;/P&gt;&lt;P&gt;busab "Accounting clerk, mandatory, may be single or range values&lt;/P&gt;&lt;P&gt;ktokd "Customer Account Group, mandatory, usually single value selection&lt;/P&gt;&lt;P&gt;budat "13 months selection, mandatory, range, fixed range based on current date&lt;/P&gt;&lt;P&gt;zuonr " not mandatory&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 03:57:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070008#M428677</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T03:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070009#M428678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;anymore input? thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 09:09:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070009#M428678</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T09:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070010#M428679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not keep kna1 and knb1 in one table and bkpf, bsid and bsad in another.. It will help reducing database load..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 13:36:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070010#M428679</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T13:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070011#M428680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Charles,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   According to your requirement there could be multiple ways you can try and solve this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) try joining kna1 &amp;amp; knb1 and use for all entries or loop and select from bkpf and bsad or bsid separately using index ( as they have huge data).&lt;/P&gt;&lt;P&gt;2) Join KNA1, KNB1 and BKPF and the resultant use in BSAD and BSID separately as the first resultant is common for both the tables.&lt;/P&gt;&lt;P&gt;3) If indexes are generated then try and read them separately and then join them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try all methods and check the performance.. &lt;/P&gt;&lt;P&gt;Hope you find a solution here..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you have further questions..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Rakesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 17:41:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070011#M428680</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T17:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070012#M428681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;any more input? thx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 07:42:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070012#M428681</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T07:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070013#M428682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i'm thinking of the following steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) inner join kna1, kbb1&lt;/P&gt;&lt;P&gt;2) access bsid with for all entries (kna1, kbb1)&lt;/P&gt;&lt;P&gt;3) access bsad with for all entries (kna1, kbb1)&lt;/P&gt;&lt;P&gt;4) append bsad to bsid itab&lt;/P&gt;&lt;P&gt;5) acess bkpf with for all entries (bsid itab)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem is i'm cant really make use of indexes for accessing bsid and bsad...&lt;/P&gt;&lt;P&gt;which is causing the slowness...&lt;/P&gt;&lt;P&gt;accessing bsid has the same selection criteria and where condition as bsad..&lt;/P&gt;&lt;P&gt;but these the where fields are either using IN and ranges.. index cannot be used..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"select with quite a number of fields....
      WHERE bukrs IN s_bukrs 
        AND kunnr IN s_kunnr
        AND budat BETWEEN backdate_13 AND p_r_date  
        AND blart IN r_blart 
        AND zuonr IN szuonr. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 08:08:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070013#M428682</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T08:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070014#M428683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi charles&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refer to the blog related to FI tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;madhu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 09:06:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070014#M428683</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T09:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070015#M428684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 09:10:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070015#M428684</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T09:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070016#M428685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is wrong with this SQL statement? abap dump generated&lt;/P&gt;&lt;P&gt;checking through ST11...found this..&lt;/P&gt;&lt;P&gt;ERROR =&amp;gt; max. statement length (65536) exceeded&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;there are &lt;/P&gt;&lt;P&gt;114 records in r_blart&lt;/P&gt;&lt;P&gt;44 records in itab&lt;/P&gt;&lt;P&gt;in this selection statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    SELECT
      bukrs
      belnr
      gjahr
      kunnr
      blart
      buzei
      budat
      bldat
      mansp
      shkzg
      xblnr
      bschl
      dmbtr
      zuonr
      INTO TABLE i_bsid
      FROM bsid
      FOR ALL ENTRIES IN itab
      WHERE bukrs = itab-bukrs
        AND kunnr = itab-kunnr
        AND budat BETWEEN backdate_13 AND p_r_date
        AND blart IN r_blart
        AND zuonr IN szuonr.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 10:59:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070016#M428685</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T10:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070017#M428686</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 seems you have not enough memory space for WHERE condition, probably it can depend on the number of the hit in R_BLART.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or check how you have defined the table i_bsid: it should have only the fields indicated in the select.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 11:03:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070017#M428686</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T11:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070018#M428687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;but how come if there are&lt;/P&gt;&lt;P&gt;43 records in itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;..there will be no dump?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the dump is something to do with the length of the SQL statement?&lt;/P&gt;&lt;P&gt;as mentioned in ST11?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 11:10:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070018#M428687</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T11:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070019#M428688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi charles&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can u post how itab is populated and its declaration too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;madhu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 12:44:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070019#M428688</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T12:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070020#M428689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes, i suspect its due to the length of the SQL after it is translated into native SQL.. something to do with the SQL statement length&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i wonder if there is any way to solve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'm doing performance tuning for a report which does a inner join for &lt;/P&gt;&lt;P&gt;kna1, kpb1, bkpf and bsid...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the report later does another inner join for&lt;/P&gt;&lt;P&gt;kna1, kpb1, bkpf and bsad...with the same criteria and combines both itab into a big itab..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;these 2 inner joins can take up for several hours for huge data... (selection for 13months)&lt;/P&gt;&lt;P&gt;so, i'm trying to break this up into more efficient statements...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab is a standard table.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  SELECT
    knb1~bukrs
    knb1~kunnr
    knb1~busab
    kna1~ktokd
    kna1~adrnr
    kna1~brsch
    kna1~name1
    INTO TABLE itab
    FROM knb1 INNER JOIN kna1
      ON knb1~kunnr = kna1~kunnr
    WHERE knb1~bukrs IN s_bukrs   "Company code
      AND knb1~kunnr IN s_kunnr   "Customer Number
      AND knb1~busab IN s_busab   "Accounting clerk
      AND kna1~ktokd IN s_ktokd.  "Customer Account Group
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 14:56:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070020#M428689</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T14:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070021#M428690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the deal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case the Inner join is working against you.  you will be far better off, breaking down the Inner join into separate sorted internal tables.  Let me know if you need help with that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also consider reading data in packages rather than all at once, may be 25,000 to 50,000 and build them into one big table if it is for a report, if it is for a file then you are better off sending the combined string directly to the file, if it is ALV then u have no choice but to build a big internal table, if you are doing SapScript or write statements then consider inserting report logic within the selections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you need any assistance in any areas I have described.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 18:04:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070021#M428690</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T18:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070022#M428691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Richard,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just a normal report with total of almost 30 variants, not using alv...&lt;/P&gt;&lt;P&gt;but requires calculation..so no choice but to combine everything into a big itab...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem is with the inner join of the 4 tables.&lt;/P&gt;&lt;P&gt;&amp;amp; this is done 2 times.. 1st with bsid.. then 2nd with bsad.. &amp;amp; then both itabs are combined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i realised if i break up this 2 inner join statements into smaller statements and use for all entries... i may encounter other problems..&lt;/P&gt;&lt;P&gt;eg. if i start by inner join kna1 and knb1..&lt;/P&gt;&lt;P&gt;some variants will result in a huge amount of customer data... so for all entries would have problem here&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Mar 2007 09:06:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070022#M428691</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-17T09:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070023#M428692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Charles,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your problem occurs because the deprecated ranges couldn't be split into smaller ranges by the database interface of the SAP kernel. Therefore the size of the SQL statement exceeds sooner or later the database limit. If you rewrite it with an internal table and for all entries, the kernel will split the SQL into suitable pieces (depending on the rsdb/max_blocking_factor and rsdb/max_in_blocking_factor parameters).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your ranges contains real ranges (low - high which results into BETWEEN) you should split your ranges to suite the database limits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Ralph Ganszky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 14:05:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070023#M428692</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T14:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance: Joining FI tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070024#M428693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;will open cursor help in this case?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2007 12:11:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-joining-fi-tables/m-p/2070024#M428693</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-20T12:11:47Z</dc:date>
    </item>
  </channel>
</rss>

