<?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: performance problem in select data from data base in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467231#M554216</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello Rob, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have around 7 lacs entries in a Z table. Based on requirements sometimes Key fields are also not being provided. &lt;/P&gt;&lt;P&gt;Database selection is taking more than 5 mins after that the table output is generated as a ALV tree control. it is taking again some time to build nodes of ALV tree. &lt;/P&gt;&lt;P&gt;Sometimes i am getting TIME_OUT dump also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there still any possibility of performance improvment?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select code is here..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM Zitab INTO CORRESPONDING FIELDS OF&lt;/P&gt;&lt;P&gt;            TABLE lt_spool PACKAGE SIZE 5000 WHERE&lt;/P&gt;&lt;P&gt;                        dokar IN so_dokar AND&lt;/P&gt;&lt;P&gt;                        doknr IN so_doknr AND&lt;/P&gt;&lt;P&gt;                        dokvr IN so_dokvr AND&lt;/P&gt;&lt;P&gt;                        doktl IN so_doktl AND&lt;/P&gt;&lt;P&gt;                        recid IN lr_recid AND&lt;/P&gt;&lt;P&gt;                        com_typ1 IN so_comtp AND&lt;/P&gt;&lt;P&gt;                        reasonbpr IN so_contx AND&lt;/P&gt;&lt;P&gt;                        dokst IN so_dokst AND&lt;/P&gt;&lt;P&gt;                        aennr IN so_aennr AND&lt;/P&gt;&lt;P&gt;                        sent_date IN so_stdat AND&lt;/P&gt;&lt;P&gt;                        confirm_date IN so_cfdat AND&lt;/P&gt;&lt;P&gt;                        remind_date IN so_rmdat AND&lt;/P&gt;&lt;P&gt;                        closed_date IN so_cldat AND&lt;/P&gt;&lt;P&gt;                        sap_packet  IN lr_packt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jun 2007 15:50:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-22T15:50:56Z</dc:date>
    <item>
      <title>performance problem in select data from data base</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467228#M554213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello all, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you please suggest me which select statement is good for fetch data form data base if data base contain more than 10 lac records. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am using SELECT PACKAGE SIZE n statement,  but it's taking lot of time . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with best regards&lt;/P&gt;&lt;P&gt;srinivas rathod&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 08:13:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467228#M554213</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-22T08:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: performance problem in select data from data base</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467229#M554214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;Here is the link for Select query optimization link&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm" target="test_blank"&gt;http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abap" target="test_blank"&gt;https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abap&lt;/A&gt;&lt;EM&gt;Performance&lt;/EM&gt;and+Tuning&amp;amp;&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; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 08:17:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467229#M554214</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-22T08:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: performance problem in select data from data base</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467230#M554215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are selecting many records, there's no way you can improve performance beyond a certain point. Can you paste your code?&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, 22 Jun 2007 13:27:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467230#M554215</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-22T13:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: performance problem in select data from data base</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467231#M554216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello Rob, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have around 7 lacs entries in a Z table. Based on requirements sometimes Key fields are also not being provided. &lt;/P&gt;&lt;P&gt;Database selection is taking more than 5 mins after that the table output is generated as a ALV tree control. it is taking again some time to build nodes of ALV tree. &lt;/P&gt;&lt;P&gt;Sometimes i am getting TIME_OUT dump also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there still any possibility of performance improvment?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select code is here..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM Zitab INTO CORRESPONDING FIELDS OF&lt;/P&gt;&lt;P&gt;            TABLE lt_spool PACKAGE SIZE 5000 WHERE&lt;/P&gt;&lt;P&gt;                        dokar IN so_dokar AND&lt;/P&gt;&lt;P&gt;                        doknr IN so_doknr AND&lt;/P&gt;&lt;P&gt;                        dokvr IN so_dokvr AND&lt;/P&gt;&lt;P&gt;                        doktl IN so_doktl AND&lt;/P&gt;&lt;P&gt;                        recid IN lr_recid AND&lt;/P&gt;&lt;P&gt;                        com_typ1 IN so_comtp AND&lt;/P&gt;&lt;P&gt;                        reasonbpr IN so_contx AND&lt;/P&gt;&lt;P&gt;                        dokst IN so_dokst AND&lt;/P&gt;&lt;P&gt;                        aennr IN so_aennr AND&lt;/P&gt;&lt;P&gt;                        sent_date IN so_stdat AND&lt;/P&gt;&lt;P&gt;                        confirm_date IN so_cfdat AND&lt;/P&gt;&lt;P&gt;                        remind_date IN so_rmdat AND&lt;/P&gt;&lt;P&gt;                        closed_date IN so_cldat AND&lt;/P&gt;&lt;P&gt;                        sap_packet  IN lr_packt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 15:50:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467231#M554216</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-22T15:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: performance problem in select data from data base</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467232#M554217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PACKAGE SIZE won't really help performance. You can use it when you are returning so much data that the internal table can't hold them all and it dumps with a memory problem. That may or may not be the case here (it probably is). In any event, try increasing the package size as much as you can. Change it from 5000 to 50000. If that dumps (with a memory error) decrease the package size; if it works, increase it. Take the maximum package size that doesn't cause a dump.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should also say that if you aren't using the index, that will probably be the primary source of the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS - a bit of an understanding issue on my part. Is lac a million?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Rob Burbank&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 16:11:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467232#M554217</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-22T16:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: performance problem in select data from data base</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467233#M554218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srinivas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you have huge data and selecting ,you could decrease little bit time if you use better techniques.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not think SELECT PACKAGE SIZE  will give good performance &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;see the below examples :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;ABAP Code Samples for Simple Performance Tuning Techniques &lt;/P&gt;&lt;P&gt;	&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Query including select and sorting functionality&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: mara, mast.&lt;/P&gt;&lt;P&gt;    data: begin of itab_new occurs 0,&lt;/P&gt;&lt;P&gt;             matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;             ernam like mara-ernam,&lt;/P&gt;&lt;P&gt;             mtart like mara-mtart,&lt;/P&gt;&lt;P&gt;             matkl like mara-matkl,&lt;/P&gt;&lt;P&gt;             werks like mast-werks,&lt;/P&gt;&lt;P&gt;      	aenam like mast-aenam,&lt;/P&gt;&lt;P&gt; stlal like mast-stlal,&lt;/P&gt;&lt;P&gt;     end of itab_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select f&lt;SUB&gt;matnr f&lt;/SUB&gt;ernam f&lt;SUB&gt;mtart f&lt;/SUB&gt;matkl g&lt;SUB&gt;werks g&lt;/SUB&gt;aenam g~stlal&lt;/P&gt;&lt;P&gt;into table itab_new from mara as f inner join mast as g on&lt;/P&gt;&lt;P&gt;f&lt;SUB&gt;matnr = g&lt;/SUB&gt;matnr where g&lt;SUB&gt;stlal = '01' order by f&lt;/SUB&gt;ernam.&lt;/P&gt;&lt;P&gt;Code B&lt;/P&gt;&lt;P&gt;tables: mara, mast.&lt;/P&gt;&lt;P&gt;data: begin of itab_new occurs 0,&lt;/P&gt;&lt;P&gt;      matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;      ernam like mara-ernam,&lt;/P&gt;&lt;P&gt;      mtart like mara-mtart,&lt;/P&gt;&lt;P&gt;      matkl like mara-matkl,&lt;/P&gt;&lt;P&gt;      werks like mast-werks,&lt;/P&gt;&lt;P&gt;      aenam like mast-aenam,&lt;/P&gt;&lt;P&gt;      stlal like mast-stlal,&lt;/P&gt;&lt;P&gt;end of itab_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select f&lt;SUB&gt;matnr f&lt;/SUB&gt;ernam f&lt;SUB&gt;mtart f&lt;/SUB&gt;matkl g&lt;SUB&gt;werks g&lt;/SUB&gt;aenam g~stlal&lt;/P&gt;&lt;P&gt;into table itab_new from mara as f inner join mast as g on f~matnr =&lt;/P&gt;&lt;P&gt;g&lt;SUB&gt;matnr where g&lt;/SUB&gt;stlal = '01'.&lt;/P&gt;&lt;P&gt;sort itab_new by ernam.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Both the above codes essentially do the same function, but the execution time for code B is considerably lesser than that of Code A. Reason: The Order by clause associated with a select statement increases the execution time of the statement, so it is profitable to sort the internal table once after selecting the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Performance Improvement Due to Identical Statements &amp;#150; Execution Plan&lt;/P&gt;&lt;P&gt;Consider the below queries and their levels of efficiencies is saving the execution &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: mara, mast.&lt;/P&gt;&lt;P&gt;data: begin of itab_new occurs 0,&lt;/P&gt;&lt;P&gt;      matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;      ernam like mara-ernam,&lt;/P&gt;&lt;P&gt;      mtart like mara-mtart,&lt;/P&gt;&lt;P&gt;      matkl like mara-matkl,&lt;/P&gt;&lt;P&gt;      werks like mast-werks,&lt;/P&gt;&lt;P&gt;      aenam like mast-aenam,&lt;/P&gt;&lt;P&gt;      stlal like mast-stlal,&lt;/P&gt;&lt;P&gt;end of itab_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select f&lt;SUB&gt;matnr f&lt;/SUB&gt;ernam f&lt;SUB&gt;mtart f&lt;/SUB&gt;matkl g&lt;SUB&gt;werks g&lt;/SUB&gt;aenam g~stlal&lt;/P&gt;&lt;P&gt;into table itab_new from mara as f inner join mast as g on f~matnr =&lt;/P&gt;&lt;P&gt;g&lt;SUB&gt;matnr where g&lt;/SUB&gt;stlal = '01' . &lt;/P&gt;&lt;P&gt;sort itab_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select f&lt;SUB&gt;matnr f&lt;/SUB&gt;ernam&lt;/P&gt;&lt;P&gt;f&lt;SUB&gt;mtart f&lt;/SUB&gt;matkl g&lt;SUB&gt;werks g&lt;/SUB&gt;aenam g~stlal&lt;/P&gt;&lt;P&gt;into table itab_new from mara as&lt;/P&gt;&lt;P&gt;f inner join mast as g on f~matnr =&lt;/P&gt;&lt;P&gt;g&lt;SUB&gt;matnr where g&lt;/SUB&gt;stlal&lt;/P&gt;&lt;P&gt;= '01' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code D (Identical Select Statements)&lt;/P&gt;&lt;P&gt;tables: mara, mast.&lt;/P&gt;&lt;P&gt;data: begin of itab_new occurs 0,&lt;/P&gt;&lt;P&gt;      matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;      ernam like mara-ernam,&lt;/P&gt;&lt;P&gt;      mtart like mara-mtart,&lt;/P&gt;&lt;P&gt;      matkl like mara-matkl,&lt;/P&gt;&lt;P&gt;      werks like mast-werks,&lt;/P&gt;&lt;P&gt;      aenam like mast-aenam,&lt;/P&gt;&lt;P&gt;      stlal like mast-stlal,&lt;/P&gt;&lt;P&gt;end of itab_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select f&lt;SUB&gt;matnr f&lt;/SUB&gt;ernam f&lt;SUB&gt;mtart f&lt;/SUB&gt;matkl g&lt;SUB&gt;werks g&lt;/SUB&gt;aenam g~stlal&lt;/P&gt;&lt;P&gt;into table itab_new from mara as f inner join mast as g on f~matnr =&lt;/P&gt;&lt;P&gt;g&lt;SUB&gt;matnr where g&lt;/SUB&gt;stlal = '01' .&lt;/P&gt;&lt;P&gt;sort itab_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select f&lt;SUB&gt;matnr f&lt;/SUB&gt;ernam f&lt;SUB&gt;mtart f&lt;/SUB&gt;matkl g&lt;SUB&gt;werks g&lt;/SUB&gt;aenam g~stlal&lt;/P&gt;&lt;P&gt;into table itab_new from mara as f inner join mast as g on f~matnr =&lt;/P&gt;&lt;P&gt;g&lt;SUB&gt;matnr where g&lt;/SUB&gt;stlal = '01' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both the above codes essentially do the same function, but the execution time for code B is considerably lesser than that of Code A. Reason: Each SQL statement during the process of execution is converted into a series of database operation phases. In the second phase of conversion (Prepare phase) an &amp;#147;execution  plan&amp;#148; is determined for the current SQL statement and it is stored, if in the program any identical select statement is used, then the same execution plan is reused to save time. So retain the structure of the select statement as the same when it is used more than once in the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              &lt;/P&gt;&lt;P&gt;                                         &lt;/P&gt;&lt;P&gt;3. Reducing Parse Time Using Aliasing&lt;/P&gt;&lt;P&gt;A statement which does not have a cached execution plan should be parsed before execution; this parsing phase is a highly time and resource consuming, so parsing time for any sql query must include an alias name in it for the following reason.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;1.	Providing the alias name will enable the query engine to resolve the tables to which the specified fields belong to.&lt;/P&gt;&lt;P&gt;2.	Providing a short alias name, (a single character alias name) is more efficient that providing a big alias name.&lt;/P&gt;&lt;P&gt;Code E&lt;/P&gt;&lt;P&gt;select j&lt;SUB&gt;matnr j&lt;/SUB&gt;ernam j&lt;SUB&gt;mtart j&lt;/SUB&gt;matkl&lt;/P&gt;&lt;P&gt;g&lt;SUB&gt;werks g&lt;/SUB&gt;aenam g~stlal into table itab_new from mara as&lt;/P&gt;&lt;P&gt;j inner join mast as g on j&lt;SUB&gt;matnr = g&lt;/SUB&gt;matnr where&lt;/P&gt;&lt;P&gt;            g~stlal = '01' .&lt;/P&gt;&lt;P&gt;In the above code the alias name used is &amp;#145; j &amp;#145;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Performance Tuning Using Order by Clause&lt;/P&gt;&lt;P&gt;If in a SQL query you are going to  read a particular database record based on some key values mentioned in the select statement, then the read query can be very well optimized by ordering the fields in the same order in which we are going to read them in the read query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code F&lt;/P&gt;&lt;P&gt;tables: mara, mast.&lt;/P&gt;&lt;P&gt;data: begin of itab_new occurs 0,&lt;/P&gt;&lt;P&gt;      matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;      ernam like mara-ernam,&lt;/P&gt;&lt;P&gt;      mtart like mara-mtart,&lt;/P&gt;&lt;P&gt;      matkl like mara-matkl,&lt;/P&gt;&lt;P&gt;      end of itab_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select MATNR ERNAM MTART MATKL from mara into table itab_new where&lt;/P&gt;&lt;P&gt;MTART = 'HAWA' ORDER BY  MATNR ERNAM  MTART MATKL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab_new with key MATNR = 'PAINT1'   ERNAM = 'RAMANUM'&lt;/P&gt;&lt;P&gt;MTART = 'HAWA'   MATKL = 'OFFICE'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code G&lt;/P&gt;&lt;P&gt;tables: mara, mast.&lt;/P&gt;&lt;P&gt;data: begin of itab_new occurs 0,&lt;/P&gt;&lt;P&gt;      matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;      ernam like mara-ernam,&lt;/P&gt;&lt;P&gt;      mtart like mara-mtart,&lt;/P&gt;&lt;P&gt;      matkl like mara-matkl,&lt;/P&gt;&lt;P&gt;      end of itab_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select MATNR ERNAM MTART MATKL from mara into table itab_new where&lt;/P&gt;&lt;P&gt;MTART = 'HAWA' ORDER BY  ERNAM MATKL MATNR MTART.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab_new with key MATNR = 'PAINT1'   ERNAM = 'RAMANUM'&lt;/P&gt;&lt;P&gt;MTART = 'HAWA'   MATKL = 'OFFICE'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above code F, the read statement following the select statement is having the order of the keys as MATNR, ERNAM, MTART, MATKL. So it is less time intensive if the internal table is ordered in the same order as that of the keys in the read statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. Performance Tuning Using Binary Search&lt;/P&gt;&lt;P&gt;A very simple but useful method of fine tuning performance of a read statement is using &amp;#145;Binary search&amp;#145; addition to it. If the internal table consists of more than 20 entries then the traditional linear search method proves to be more time intensive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                          &lt;/P&gt;&lt;P&gt;Code H&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from mara into corresponding fields of table intab.&lt;/P&gt;&lt;P&gt;sort intab.	&lt;/P&gt;&lt;P&gt;read table intab with key matnr = '11530' binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Code I&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from mara into corresponding fields of table intab.&lt;/P&gt;&lt;P&gt;sort intab.	&lt;/P&gt;&lt;P&gt;read table intab with key matnr = '11530'.&lt;/P&gt;&lt;P&gt;        &lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Seshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 16:16:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467233#M554218</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-22T16:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: performance problem in select data from data base</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467234#M554219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi srinivas,&lt;/P&gt;&lt;P&gt;your where clause is too long &lt;/P&gt;&lt;P&gt;it will only confuse the database optimizer on which index to use &lt;/P&gt;&lt;P&gt;so what you need to do is re-arrange the where clause of the query in the order in which you primary index / secondary index is defined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the rest of the conditions can be evaluated within the program unless they filter a lot of data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;also avoid INTO CORRESPONDING FIELDS &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;also try to make the first few index fields mandatory in your program (or ensure that they are filled with some valid default values)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly reward points to helpful answers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use ST05 &amp;amp; check which index (if any) is being used during the select process...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2007 09:54:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467234#M554219</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-23T09:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: performance problem in select data from data base</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467235#M554220</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;You need to change your select.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Dont give *. Instead select only those fields you need to populate into the internal table from the database table in the same order as present in the db table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Dont use into correspoding. Instead create an internal table with only those fields you will fetching from the database table and use Select ... INTO TABLE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) Dont use Select Endselect. This works like a loop. Instead use Select &amp;lt;fields&amp;gt; ...&lt;/P&gt;&lt;P&gt;into table &amp;lt;internal table&amp;gt; from &amp;lt;database table&amp;gt; where ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) Do not give too many conditions while selecting from database. Use only primary fields in the where condition or any field for which secondary indexes are maintained and filter the records from the internal table by using delete statement.&lt;/P&gt;&lt;P&gt; Delete it_spool where not Dokar IN so_dokar.&lt;/P&gt;&lt;P&gt; Delete it_spool where not doknr IN so_doknr.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: Selecting data from HR table PA0001. &lt;/P&gt;&lt;P&gt;DATA: &lt;/P&gt;&lt;P&gt;begin of i_0001 occurs 0,&lt;/P&gt;&lt;P&gt;pernr like pa0001-pernr,&lt;/P&gt;&lt;P&gt;begda like pa0001-begda,&lt;/P&gt;&lt;P&gt;endda like pa0001-endda,&lt;/P&gt;&lt;P&gt;bukrs like pa0001-bukrs,&lt;/P&gt;&lt;P&gt;werks like pa0001-werks,&lt;/P&gt;&lt;P&gt;btrtl like pa0001-btrtl,&lt;/P&gt;&lt;P&gt;persg like pa0001-persg,&lt;/P&gt;&lt;P&gt;persk like pa0001-persk,&lt;/P&gt;&lt;P&gt;orgeh like pa0001-orgeh,&lt;/P&gt;&lt;P&gt;end of i_0001.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select pernr begda endda bukrs werks btrtl persg persk orgeh&lt;/P&gt;&lt;P&gt; from pa0001&lt;/P&gt;&lt;P&gt; into table i_0001&lt;/P&gt;&lt;P&gt; where pernr in s_pernr&lt;/P&gt;&lt;P&gt; and  endda &amp;gt;= sy-datum&lt;/P&gt;&lt;P&gt;and  begda &amp;lt;= sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;delete i_0001 where not bukrs in s_bukrs and&lt;/P&gt;&lt;P&gt;                              not werks in s_werks and&lt;/P&gt;&lt;P&gt;                              not btrtl in s_btrtl and&lt;/P&gt;&lt;P&gt;                              not persg in s_persg and&lt;/P&gt;&lt;P&gt;                              not persk in s_persk and&lt;/P&gt;&lt;P&gt;                              not orgeh in s_orgeh.&lt;/P&gt;&lt;P&gt;endif.&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;Navneet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2007 20:28:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem-in-select-data-from-data-base/m-p/2467235#M554220</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-23T20:28:17Z</dc:date>
    </item>
  </channel>
</rss>

