<?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 issue with VBAP table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548164#M853620</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First thing is avoid joining more than 3 tables. So split your query, use select for all entries construct (with an initial check on the driver table). Select the data roughly in the same order as they appear in the table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Mar 2008 11:58:50 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-18T11:58:50Z</dc:date>
    <item>
      <title>SQL-Performance issue with VBAP table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548162#M853618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I have a query on table VBAP which fetches data based on date-time stamp and few other fields. Date-tme fields are always filled. If no plant is additionally entered, query runs for about 20 minutes. However, when user enters a plant, query runs for ever (Last run took about 16 hours). I tried tweaking the "where clause" a bit with no sign of improved performance. I really don't understand why should plant mess with the index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your replies are appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Yogi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT b&lt;SUB&gt;vbeln b&lt;/SUB&gt;posnr b&lt;SUB&gt;uepos b&lt;/SUB&gt;matnr b&lt;SUB&gt;werks b&lt;/SUB&gt;meins b~objnr&lt;/P&gt;&lt;P&gt;b&lt;SUB&gt;erdat c&lt;/SUB&gt;webaz c&lt;SUB&gt;plifz e&lt;/SUB&gt;fabkl e~pipatg&lt;/P&gt;&lt;P&gt;INTO TABLE pt_order&lt;/P&gt;&lt;P&gt;FROM vbak AS a &lt;/P&gt;&lt;P&gt;INNER JOIN vbap AS b&lt;/P&gt;&lt;P&gt;ON a&lt;SUB&gt;vbeln = b&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;INNER JOIN marc AS c&lt;/P&gt;&lt;P&gt;ON b&lt;SUB&gt;matnr = c&lt;/SUB&gt;matnr AND&lt;/P&gt;&lt;P&gt;b&lt;SUB&gt;werks = c&lt;/SUB&gt;werks&lt;/P&gt;&lt;P&gt;INNER JOIN vbuk AS d&lt;/P&gt;&lt;P&gt;ON a&lt;SUB&gt;vbeln = d&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;INNER JOIN tvst AS e&lt;/P&gt;&lt;P&gt;ON b&lt;SUB&gt;vstel = e&lt;/SUB&gt;vstel&lt;/P&gt;&lt;P&gt;WHERE a~vkorg IN s_vkorg&lt;/P&gt;&lt;P&gt;AND a~auart IN s_auart&lt;/P&gt;&lt;P&gt;AND ( ( ( b&lt;SUB&gt;erdat LT s_erdat-high ) OR ( b&lt;/SUB&gt;erdat EQ s_erdat-high&lt;/P&gt;&lt;P&gt;AND b~erzet LE p_totim ) )&lt;/P&gt;&lt;P&gt;AND ( ( b&lt;SUB&gt;erdat GT s_erdat-low ) OR ( b&lt;/SUB&gt;erdat EQ s_erdat-low&lt;/P&gt;&lt;P&gt;AND b~erzet GE p_frtim ) ) )&lt;/P&gt;&lt;P&gt;AND b~werks IN s_werks &lt;/P&gt;&lt;P&gt;AND b~abgru IN s_abgru &lt;/P&gt;&lt;P&gt;AND c~mtvfp IN s_mtvfp&lt;/P&gt;&lt;P&gt;AND d~cmgst IN s_cmgst.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2008 19:54:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548162#M853618</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-17T19:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: SQL-Performance issue with VBAP table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548163#M853619</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;your query seems to have been fetching data from the tables:&lt;/P&gt;&lt;P&gt;vbap&lt;/P&gt;&lt;P&gt;marc &lt;/P&gt;&lt;P&gt;tvst&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so, I think you can modify your query with the above 3 tables as under: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT b&lt;SUB&gt;vbeln b&lt;/SUB&gt;posnr b&lt;SUB&gt;uepos b&lt;/SUB&gt;matnr b&lt;SUB&gt;werks b&lt;/SUB&gt;meins b~objnr&lt;/P&gt;&lt;P&gt;b&lt;SUB&gt;erdat c&lt;/SUB&gt;webaz c&lt;SUB&gt;plifz e&lt;/SUB&gt;fabkl e~pipatg&lt;/P&gt;&lt;P&gt;INTO TABLE pt_order&lt;/P&gt;&lt;P&gt;FROM vbap AS b &lt;/P&gt;&lt;P&gt;INNER JOIN marc AS c&lt;/P&gt;&lt;P&gt;ON b&lt;SUB&gt;matnr = c&lt;/SUB&gt;matnr &lt;/P&gt;&lt;P&gt;AND&lt;/P&gt;&lt;P&gt;b&lt;SUB&gt;werks = c&lt;/SUB&gt;werks&lt;/P&gt;&lt;P&gt;INNER JOIN tvst AS e&lt;/P&gt;&lt;P&gt;ON b&lt;SUB&gt;vstel = e&lt;/SUB&gt;vstel&lt;/P&gt;&lt;P&gt;WHERE &lt;/P&gt;&lt;P&gt;AND ( ( ( b&lt;SUB&gt;erdat LT s_erdat-high ) OR ( b&lt;/SUB&gt;erdat EQ s_erdat-high&lt;/P&gt;&lt;P&gt;AND b~erzet LE p_totim ) )&lt;/P&gt;&lt;P&gt;AND ( ( b&lt;SUB&gt;erdat GT s_erdat-low ) OR ( b&lt;/SUB&gt;erdat EQ s_erdat-low&lt;/P&gt;&lt;P&gt;AND b~erzet GE p_frtim ) ) )&lt;/P&gt;&lt;P&gt;AND b~werks IN s_werks &lt;/P&gt;&lt;P&gt;AND b~abgru IN s_abgru &lt;/P&gt;&lt;P&gt;AND c~mtvfp IN s_mtvfp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and test the changes how it is working for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please make changes as the per above suggestions and let me know how it worked for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vishnu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2008 09:47:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548163#M853619</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-18T09:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQL-Performance issue with VBAP table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548164#M853620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First thing is avoid joining more than 3 tables. So split your query, use select for all entries construct (with an initial check on the driver table). Select the data roughly in the same order as they appear in the table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2008 11:58:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548164#M853620</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-18T11:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: SQL-Performance issue with VBAP table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548165#M853621</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 use so many inner joins in the query...may be you can split the query aand try...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ramesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2008 12:29:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548165#M853621</guid>
      <dc:creator>former_member282823</dc:creator>
      <dc:date>2008-03-18T12:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: SQL-Performance issue with VBAP table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548166#M853622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Difficult to say without more information, so run a SQL trace through ST05 to pinpoint where the issue is. At a guess it's table-scanning somewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What database platform are you on? Do you have any custom indexes on VBAP?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2008 15:12:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548166#M853622</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-18T15:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: SQL-Performance issue with VBAP table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548167#M853623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ST05 trace revealed that MARC  table was executed in interation when user entered plant on the selection-screen. I split the query such that data from transaction tables and master tables are fetched separately.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2008 18:17:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance-issue-with-vbap-table/m-p/3548167#M853623</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-21T18:17:54Z</dc:date>
    </item>
  </channel>
</rss>

