<?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: Improve that SELECT statement: in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309989#M1224316</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT &lt;STRONG&gt;DISTINCT&lt;/STRONG&gt; ---&amp;gt;It will increase the load on the database server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Instead Remove Distinct&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  a~partner_no
    INTO TABLE lt_partners32
    FROM crmd_order_index AS a INNER JOIN crm_jest AS b
    ON a~header = b~objnr
    WHERE a~object_type     =  'BUS2000126' "Activity
      AND a~process_type_ix IN ('0000','Z000')
      AND a~STAT_OPEN       'X' "Closed
      AND a~date_1               &amp;gt;= p_date
      AND b~inact                  =  SPACE
      AND b~stat                   =  'E0003'.

 
  SORT lt_partners32.

 DELETE ADJACENT DUPLICATES FROM lt_partners32.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will reduce load on database server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gurpreet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Mar 2009 15:29:41 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-03-13T15:29:41Z</dc:date>
    <item>
      <title>Improve that SELECT statement:</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309987#M1224314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm in CRM and I have to get the partners with some activity from a given date. The date format is a time stamp (DEC 15 field), so if the user enters a very old date, for example year 2007 date, the operation date_1 &amp;gt; p_date is very very slow and the programp generates a dump.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe if I select the whole table and check the values later in a LOOP the performance will improve but I'm not sure because there are 17.000.000  entries on table crmd_order_index and my possible result is around 40.000 entries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you think?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  SELECT DISTINCT a~partner_no
    INTO TABLE lt_partners32
    FROM crmd_order_index AS a INNER JOIN crm_jest AS b
    ON a~header = b~objnr
    WHERE a~object_type     =  'BUS2000126' "Activity
      AND a~process_type_ix IN ('0000','Z000')
      AND a~STAT_OPEN      &amp;lt;&amp;gt; 'X' "Closed
      AND a~date_1               &amp;gt;= p_date
      AND b~inact                  =  SPACE
      AND b~stat                   =  'E0003'.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Marshal on Mar 13, 2009 3:01 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2009 13:58:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309987#M1224314</guid>
      <dc:creator>Marcal_Oliveras</dc:creator>
      <dc:date>2009-03-13T13:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Improve that SELECT statement:</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309988#M1224315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What indexes are there for crmd_order_index?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2009 14:07:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309988#M1224315</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-13T14:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Improve that SELECT statement:</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309989#M1224316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT &lt;STRONG&gt;DISTINCT&lt;/STRONG&gt; ---&amp;gt;It will increase the load on the database server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Instead Remove Distinct&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  a~partner_no
    INTO TABLE lt_partners32
    FROM crmd_order_index AS a INNER JOIN crm_jest AS b
    ON a~header = b~objnr
    WHERE a~object_type     =  'BUS2000126' "Activity
      AND a~process_type_ix IN ('0000','Z000')
      AND a~STAT_OPEN       'X' "Closed
      AND a~date_1               &amp;gt;= p_date
      AND b~inact                  =  SPACE
      AND b~stat                   =  'E0003'.

 
  SORT lt_partners32.

 DELETE ADJACENT DUPLICATES FROM lt_partners32.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will reduce load on database server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gurpreet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2009 15:29:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309989#M1224316</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-13T15:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Improve that SELECT statement:</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309990#M1224317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you try using the package size option in the select statement (say packages of 10000 records) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mathews.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2009 16:29:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309990#M1224317</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-13T16:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Improve that SELECT statement:</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309991#M1224318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; Maybe if I select the whole table and check the values later in a LOOP the performance will improve&lt;/P&gt;&lt;P&gt;&amp;gt;  but I'm not sure because there are 17.000.000 entries on table crmd_order_index and my possible&lt;/P&gt;&lt;P&gt;&amp;gt;  result is around 40.000 entries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. of April is still weeks ahead!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can not improve performance by transferring more data then you need!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Same holds for the recommendation with the removal of the DISTINCT. Leave it where it is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How many data are actually selected? What performance do you expect. Tables are large if you select a lot then it can need some time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise check the join, are the right indexes used. Sorry, I can not explain you in detail how this works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Mar 2009 16:09:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309991#M1224318</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-14T16:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Improve that SELECT statement:</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309992#M1224319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try out few steps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Write 2 separate SELECT statements which will reduce load of  inner join since table "crm_jest" will have more entries. In this case second SELECT statement will take less time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Check if  you can create a secondary index on table crmd_order_index with required fields of your report. Before this check with Basis person if he can help you in this and also find out how many indexes are alreay created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.  Other option is to create a database view for both the tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will give some help to improve performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sunil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2009 06:16:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309992#M1224319</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-16T06:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Improve that SELECT statement:</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309993#M1224320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marshal,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  If I understood you question correctly, you are obtaining the partners who have an CRM object in some situation.&lt;/P&gt;&lt;P&gt;  Check if you can change the table access strategy. If the amount of records on CRM_JEST with INACT = space and STAT = E0003, don't increase for long date selects concluding that is a temporary situation, you can try something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT DISTINCT objnr INTO lt_objnr
FROM crm_jest
WHERE inact = space
  AND 'E0003'.

IF NOT lt_objnr[] IS INITIAL.
  SELECT DISTINCT partner_no INTO TABLE lt_partners32
  FROM crmd_order_index
  FOR ALL ENTRIES IN lt_objnr
  WHERE header = lt_objnr-objnr
    AND object_type     =  'BUS2000126' "Activity
    AND process_type_ix IN ('0000','Z000')
    AND STAT_OPEN       = 'X' "Closed
    AND date_1          &amp;gt;= p_date.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fernando Da Ró&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2009 22:31:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309993#M1224320</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-16T22:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Improve that SELECT statement:</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309994#M1224321</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 major case in which SELECT DISTINCT is a serious performance penalty is when the volume of data to be sorted is exceedingly large (for example TEMP disk storage area may be used). It uses DELETE ADYACENT DUPLICATE instead of  SELECT DISTINCT and use Range for the values ('0000','Z000').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionally you must verify the correct use of the indexes of the tables to improve the access to Data Base.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this information is help to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;José&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 14:15:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-that-select-statement/m-p/5309994#M1224321</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T14:15:20Z</dc:date>
    </item>
  </channel>
</rss>

