<?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: [Bug]  Select query doesnt follow basic performance optimization rules in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897016#M1961987</link>
    <description>&lt;P&gt;Hi &lt;A href="https://answers.sap.com/users/36313/quynhdoanmanh.html"&gt;Quynh Doan Manh&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply, I get that data is sorted.&lt;/P&gt;&lt;P&gt;But the select query is using duplicate date as I mentioned above :&lt;/P&gt;&lt;P&gt;@P80 nvarchar(10) N'0100009323'&lt;BR /&gt;@P81 nvarchar(4) N'2018'&lt;BR /&gt;@P82 nvarchar(4) N'8750'&lt;BR /&gt;@P83 nvarchar(10) N'0100009323'&lt;BR /&gt;@P84 nvarchar(4) N'2018'&lt;BR /&gt;@P85 nvarchar(4) N'8750'&lt;BR /&gt;@P86 nvarchar(10) N'0100009323'&lt;BR /&gt;@P87 nvarchar(4) N'2018'&lt;BR /&gt;@P88 nvarchar(4) N'8750'&lt;/P&gt;&lt;P&gt;Reason for this issue is as you mentioned this table has key (bukrs, belnr, gjahr, buzei, budat),&lt;/P&gt;&lt;P&gt;so this means the combination of the 5 fields will be unique, but that doesn't mean that combination of 3 fileds "bukrs , belnr and gjahr cant be duplicate".&lt;/P&gt;&lt;P&gt;In the where clause this query is using these 3 fields which are duplicate just as the data I posted.&lt;/P&gt;&lt;P&gt;Proposed fix : put the data of this internal table into some temporary table.&lt;/P&gt;&lt;P&gt;Then delete the duplicate entries on the basis of these three fields (bukrs, belnr and gjahr).&lt;/P&gt;&lt;P&gt;then use this temporary table in the where clause.&lt;/P&gt;&lt;P&gt;This will fix the performance issue which this query is causing.&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Ramandeep Kaur&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Apr 2019 04:34:05 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2019-04-12T04:34:05Z</dc:date>
    <item>
      <title>[Bug]  Select query doesnt follow basic performance optimization rules</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897014#M1961985</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
  &lt;P&gt;We recently noticed in DBACOCKPIT, that background job scheduled for standard program "&lt;STRONG&gt;RFITEMAP&lt;/STRONG&gt;" was taking very high CPU utilization (&lt;STRONG&gt;more than 64%&lt;/STRONG&gt;).&lt;/P&gt;
  &lt;P&gt;SQL query which is causing the issue is as below :&lt;/P&gt;
  &lt;P&gt;Name of the Include file : &lt;STRONG&gt;RFITEM_INC&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Query:&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Around line no. 537:&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;SELECT (gt_spec_fields)&lt;BR /&gt; FROM bkpf&lt;BR /&gt; INTO CORRESPONDING FIELDS OF wa_bkpf&lt;BR /&gt; FOR ALL ENTRIES IN gt_pos_posted&lt;BR /&gt; WHERE bukrs = gt_pos_posted-bukrs&lt;BR /&gt; AND belnr = gt_pos_posted-belnr&lt;BR /&gt; AND gjahr = gt_pos_posted-gjahr.&lt;/P&gt;
  &lt;P&gt;On analyzing further , we found that this is a performance bug as this query doesn't follow basic best practices for writing select query with for all entries.&lt;/P&gt;
  &lt;P&gt;1) Deletion of the duplicate data is not done before using for all entries&lt;/P&gt;
  &lt;P&gt;2) Sorting of the data is not done before using for all entries&lt;/P&gt;
  &lt;P&gt;Below is the data we noticed in DBACOCKPIT (which is duplicate and not sorted):&lt;/P&gt;
  &lt;P&gt;1. Duplicate data being passed in Where clause &lt;/P&gt;
  &lt;P&gt;@P80 nvarchar(10) N'0100009323'&lt;BR /&gt;@P81 nvarchar(4) N'2018'&lt;BR /&gt;@P82 nvarchar(4) N'8750'&lt;BR /&gt;@P83 nvarchar(10) N'0100009323'&lt;BR /&gt;@P84 nvarchar(4) N'2018'&lt;BR /&gt;@P85 nvarchar(4) N'8750'&lt;BR /&gt;@P86 nvarchar(10) N'0100009323'&lt;BR /&gt;@P87 nvarchar(4) N'2018'&lt;BR /&gt;@P88 nvarchar(4) N'8750'&lt;/P&gt;
  &lt;P&gt;2. Non sorted Data being passed in where clause&lt;/P&gt;
  &lt;P&gt;@P39 nvarchar(4) N'&lt;STRONG&gt;2018&lt;/STRONG&gt;'&lt;BR /&gt;@P40 nvarchar(4) N'8370'&lt;BR /&gt;@P41 nvarchar(10) N'4600000023'&lt;BR /&gt;@P42 nvarchar(4) N'&lt;STRONG&gt;2019&lt;/STRONG&gt;'&lt;BR /&gt;@P43 nvarchar(4) N'8370'&lt;BR /&gt;@P44 nvarchar(10) N'5900000016'&lt;BR /&gt;@P45 nvarchar(4) N'&lt;STRONG&gt;2018&lt;/STRONG&gt;'&lt;/P&gt;
  &lt;P&gt;There is no note available for this fix. Please fix this performance issue and let us know!&lt;/P&gt;
  &lt;P&gt;Thanks &amp;amp; Regards,&lt;BR /&gt;Ramandeep Kaur&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 06:25:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897014#M1961985</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-04-11T06:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: [Bug]  Select query doesnt follow basic performance optimization rules</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897015#M1961986</link>
      <description>&lt;P&gt;gt_pos_posted is a sorted table with key bukrs, belnr, gjahr, buzei, budat and it sort acording to those key automatically so you dont have to sort it. also it cant be dupplicate due to: &lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abaptypes_primary_key.htm#!ABAP_ALTERNATIVE_1@1@" target="test_blank"&gt;https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abaptypes_primary_key.htm#!ABAP_ALTERNATIVE_1@1@&lt;/A&gt;&lt;/P&gt;&lt;P&gt;so you should check your input first&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 00:39:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897015#M1961986</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-04-12T00:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: [Bug]  Select query doesnt follow basic performance optimization rules</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897016#M1961987</link>
      <description>&lt;P&gt;Hi &lt;A href="https://answers.sap.com/users/36313/quynhdoanmanh.html"&gt;Quynh Doan Manh&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply, I get that data is sorted.&lt;/P&gt;&lt;P&gt;But the select query is using duplicate date as I mentioned above :&lt;/P&gt;&lt;P&gt;@P80 nvarchar(10) N'0100009323'&lt;BR /&gt;@P81 nvarchar(4) N'2018'&lt;BR /&gt;@P82 nvarchar(4) N'8750'&lt;BR /&gt;@P83 nvarchar(10) N'0100009323'&lt;BR /&gt;@P84 nvarchar(4) N'2018'&lt;BR /&gt;@P85 nvarchar(4) N'8750'&lt;BR /&gt;@P86 nvarchar(10) N'0100009323'&lt;BR /&gt;@P87 nvarchar(4) N'2018'&lt;BR /&gt;@P88 nvarchar(4) N'8750'&lt;/P&gt;&lt;P&gt;Reason for this issue is as you mentioned this table has key (bukrs, belnr, gjahr, buzei, budat),&lt;/P&gt;&lt;P&gt;so this means the combination of the 5 fields will be unique, but that doesn't mean that combination of 3 fileds "bukrs , belnr and gjahr cant be duplicate".&lt;/P&gt;&lt;P&gt;In the where clause this query is using these 3 fields which are duplicate just as the data I posted.&lt;/P&gt;&lt;P&gt;Proposed fix : put the data of this internal table into some temporary table.&lt;/P&gt;&lt;P&gt;Then delete the duplicate entries on the basis of these three fields (bukrs, belnr and gjahr).&lt;/P&gt;&lt;P&gt;then use this temporary table in the where clause.&lt;/P&gt;&lt;P&gt;This will fix the performance issue which this query is causing.&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Ramandeep Kaur&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 04:34:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897016#M1961987</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-04-12T04:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: [Bug]  Select query doesnt follow basic performance optimization rules</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897017#M1961988</link>
      <description>&lt;P&gt;If you have found a bug in standard sap code, then report it at support.sap.com &lt;/P&gt;&lt;P&gt;Posting details here and requesting a fix is unlikely to get you anywhere.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 05:54:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897017#M1961988</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-04-12T05:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: [Bug]  Select query doesnt follow basic performance optimization rules</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897018#M1961989</link>
      <description>&lt;P&gt;ok i get your ideal. but at that point of program there is no enhancement you could use to modify that table. maybe you should raise this issue to sap. beside, i suggest you should try that query in a test program to make sure the performance issue is because of duplicate in that table...&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 02:50:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bug-select-query-doesnt-follow-basic-performance-optimization-rules/m-p/11897018#M1961989</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-04-15T02:50:57Z</dc:date>
    </item>
  </channel>
</rss>

