2007 Aug 30 5:38 AM
Do you use select statement in loop .. endloop, how will be the performance?
how To improve the performance?
Do you use select statement in loop .. endloop, how will be the performance?
how To improve the performance?
2007 Aug 30 5:53 AM
every time the loop will start ...u r select query retrive the data from database.....
it will highly decrease the performance ...........in case if data is huge , it may go to dump
reward points if helpful...
2007 Aug 30 5:54 AM
every time the loop will start ...u r select query retrive the data from database.....
it will highly decrease the performance ...........in case if data is huge , it may go to dump
reward points if helpful...
2007 Aug 30 6:15 AM
Hi
suppose that loop executes for 100 times then ur select statement will execute 100 time
where exactly u needed this condition tell me
i will tell you
2007 Aug 30 8:13 AM
Hi Sarit,
The disadvantage of this is that in the loop you have one value and depending on this value you select so you hit the database just for this single value and during the next loop again it fetches one value. So lot of database hits are wasted just for reading one record.
It can be avoided by using for all entries stmt in select query.
ex:
select field1 field2
from table1
into table it_table1
where select-options.
now imagine you want to extract data from table2 depending on table 1 for all entries then use this select query for table2 instead of using loop.
select field1 field2
from table2
into table it_table2
for all entries in it_table1.
This would seriously improve the performance.
Reward Points if useful.
Thanks,
Tej..
2007 Aug 30 8:55 AM
Hi,
NOTE : Don't use Select statement with in loop it causes number of hits on database, so it decrease the performance.
Suppose if interna table contain 1lack records
Now if use select with loop internal table (1 lacks records) then program should hit the database 1 lack times and retrieview data.
At this situation, use the <b>for all entries to select</b> the data corresponding internal table before the loop.
with in loop we can use <b>READ</b> statement to get records form itab.... which <b>increase the performance.</b>
<b>Reward with points if helpful</b>.
Regards,
Vijay
2007 Aug 30 2:08 PM
It's not really the number of database hits that causes the problem, it's the number of trips from the application server to the database server.
For example in a loop that executes a select statement 100 times, SAP goes from you application program to the database 100 times. If you have a table with 100 entries and execute FOR ALL ENTRIES, SAP will probably goe to the database only once to get all your entries and return them to your program. (I say probably because this may be dependent on both your release of R3 and your database system.)
Rob
2007 Aug 30 6:09 PM
Hi Sarit,
Usually we always avoid the use of SELECT in LOOP or even SELECT..ENDSELECT..
Instead we use FOR ALL ENTRIES
The reason is that the Application server, where the ABAP programs are executed, is very very fast as compared to the Database server, which actually fetches the data from the database and return to the application server..
If you use SELECT in a LOOP, for each loop pass the application server will request the database server for data.. and every time, the application server will need to wait.. so, it will become very bad by performance..
Thanks and Best Regards,
Vikas Bittera.
**Reward if useful**
2007 Aug 31 5:55 AM
hi sarit,
The performance would all depend on the number of entries u have in the table....If the entries are less in number, it should not be a major concern, but ifur table has like a lakh records, then try to avoid this.
is ur query solved?
thanks
regards
nayan
2007 Sep 03 9:10 AM