<?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: Select statement performance improvement. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940168#M1152282</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Thomas,&lt;/P&gt;&lt;P&gt;This is a copy of a standard program.   I created an index by name TST for another program. It has the below fields :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXETIMEST&lt;/P&gt;&lt;P&gt;MANDT&lt;/P&gt;&lt;P&gt;PID&lt;/P&gt;&lt;P&gt;ADMINUSER&lt;/P&gt;&lt;P&gt;MSGTYPE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CAn you please suggest me my actions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Dec 2008 12:12:54 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-12-16T12:12:54Z</dc:date>
    <item>
      <title>Select statement performance improvement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940164#M1152278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Guru's,&lt;/P&gt;&lt;P&gt;I am new to ABAP.&lt;/P&gt;&lt;P&gt;I have the below select stement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;000304         SELECT mandt msgguid pid exetimest&lt;/P&gt;&lt;P&gt;000305           INTO TABLE lt_key&lt;/P&gt;&lt;P&gt;000306           UP TO lv_del_rows ROWS&lt;/P&gt;&lt;P&gt;000307           FROM (gv_master)&lt;/P&gt;&lt;P&gt;000308           WHERE&lt;/P&gt;&lt;P&gt;000309 *          msgstate   IN rt_msgstate&lt;/P&gt;&lt;P&gt;000310 *          AND   ( adapt_stat =  cl_xms_persist=&amp;gt;co_stat_adap_processed&lt;/P&gt;&lt;P&gt;000311 *          OR      adapt_stat =  cl_xms_persist=&amp;gt;co_stat_adap_undefined )&lt;/P&gt;&lt;P&gt;000312 *          AND     itfaction  =  ls_itfaction&lt;/P&gt;&lt;P&gt;000313 *          AND     msgtype    =  cl_xms_persist=&amp;gt;co_async&lt;/P&gt;&lt;P&gt;000314 *          AND&lt;/P&gt;&lt;P&gt;000315           exetimest  LE lv_timestamp&lt;/P&gt;&lt;P&gt;000316           AND     exetimest  GE last_ts&lt;/P&gt;&lt;P&gt;000317           AND     reorg      =  cl_xms_persist=&amp;gt;co_reorg_ini&lt;/P&gt;&lt;P&gt;000318           ORDER BY mandt itfaction reorg exetimest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me how i can improve the performance of this statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the sql trace for the statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;/*+&lt;/P&gt;&lt;P&gt;  FIRST_ROWS (100)&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;  "MANDT" , "MSGGUID" , "PID" , "EXETIMEST"&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;  "SXMSPMAST"&lt;/P&gt;&lt;P&gt;WHERE&lt;/P&gt;&lt;P&gt;  "MANDT" = :A0 AND "EXETIMEST" &amp;lt;= :A1 AND "EXETIMEST" &amp;gt;= :A2 AND "REORG" = :A3&lt;/P&gt;&lt;P&gt;ORDER BY&lt;/P&gt;&lt;P&gt;  "MANDT" , "ITFACTION" , "REORG" , "EXETIMEST"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Execution Plan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SELECT STATEMENT ( Estimated Costs = 3 , Estimated #Rows = 544 )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        4 SORT ORDER BY&lt;/P&gt;&lt;P&gt;          ( Estim. Costs = 2 , Estim. #Rows = 544 )&lt;/P&gt;&lt;P&gt;          Estim. CPU-Costs = 15.671.852 Estim. IO-Costs = 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            3 FILTER&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                2 TABLE ACCESS BY INDEX ROWID SXMSPMAST&lt;/P&gt;&lt;P&gt;                  ( Estim. Costs = 1 , Estim. #Rows = 544 )&lt;/P&gt;&lt;P&gt;                  Estim. CPU-Costs = 11.130 Estim. IO-Costs = 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                    1 INDEX RANGE SCAN SXMSPMAST~TST&lt;/P&gt;&lt;P&gt;                      Search Columns: 2&lt;/P&gt;&lt;P&gt;                      Estim. CPU-Costs = 3.329 Estim. IO-Costs = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do I need to create any new index ? Do i need to remove the Order By clause?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 11:10:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940164#M1152278</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T11:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement performance improvement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940165#M1152279</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;Create a secondary index on EXETIMEST and REORG for the table SXMSPMAST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Suthan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 11:28:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940165#M1152279</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T11:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement performance improvement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940166#M1152280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suthan,&lt;/P&gt;&lt;P&gt;Thanks for the inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the ST05 trace can you please confirm if the statement is using an index by name TST?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thabks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 11:41:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940166#M1152280</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T11:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement performance improvement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940167#M1152281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; 1 INDEX RANGE SCAN SXMSPMAST~TST&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes it is using index TST. I cannot find it here, did you create that index yourself? what are the fields? Is the above code your own or SAP standard?.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 11:54:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940167#M1152281</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-12-16T11:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement performance improvement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940168#M1152282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Thomas,&lt;/P&gt;&lt;P&gt;This is a copy of a standard program.   I created an index by name TST for another program. It has the below fields :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXETIMEST&lt;/P&gt;&lt;P&gt;MANDT&lt;/P&gt;&lt;P&gt;PID&lt;/P&gt;&lt;P&gt;ADMINUSER&lt;/P&gt;&lt;P&gt;MSGTYPE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CAn you please suggest me my actions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 12:12:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940168#M1152282</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T12:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement performance improvement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940169#M1152283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;why is there an &lt;/P&gt;&lt;P&gt;UP TO lv_del_rows ROWS &lt;/P&gt;&lt;P&gt;together with an ORDER BY?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The database will find all rows fulfilling the condition but returns only the largest Top lv_del_rows.&lt;/P&gt;&lt;P&gt;Therefore it can take a while.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your index, always put the client field at first position.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;actually I am not really convinced by your logic:&lt;/P&gt;&lt;P&gt; itfaction reorg exetimest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itfaction is the first in the sort order, so all records with the smallest itfactio will come first, but itfaction is not specified, is this really what you want?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change the index to mandt reorg exetimest reorg&lt;/P&gt;&lt;P&gt;and change the ORDER BY to mandt reorg exetimest&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then it will become fast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* AND ( adapt_stat = cl_xms_persist=&amp;gt;co_stat_adap_processed
000311 * OR adapt_stat = cl_xms_persist=&amp;gt;co_stat_adap_undefined )
000312 * AND itfaction = ls_itfaction
000313 * AND msgtype = cl_xms_persist=&amp;gt;co_async
000314 * AND
000315 exetimest LE lv_timestamp
000316 AND exetimest GE last_ts
000317 AND reorg = cl_xms_persist=&amp;gt;co_reorg_ini
000318 ORDER BY mandt itfaction reorg exetimest.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 12:37:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940169#M1152283</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T12:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement performance improvement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940170#M1152284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try removing index TST, it is almost the same as the existing index MON (EXETIMEST, MANDT, PID, MSGSTATE). Too many indexes might "confuse" the optimizer.&lt;/P&gt;&lt;P&gt;Since it is a copy of a standard program, also try searching for SAP notes for known performance problems with the original program.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 12:54:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performance-improvement/m-p/4940170#M1152284</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-12-16T12:54:16Z</dc:date>
    </item>
  </channel>
</rss>

