Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

RE: performance issue

Former Member
0 Kudos
90

In my report I am written 10 select statements in a loop.

How can we avoid this?

can I replace with read statement?

Regards,

sampath .

6 REPLIES 6

Former Member
0 Kudos
68

Hi

You may increase the performance of select statements by how you write them, not how many you write.

-Pavan

Former Member
0 Kudos
68

Hi,

You have to aviod select inside a loop... AS FAR AS POSSIBLE...

Rather you use the loop and then read statement...

Also run the transaction ST05 and ST30 and check the difference after the change...

These help you to analyse the performance...

Regards

sk

ThomasZloch
Active Contributor
0 Kudos
68

hard to say based on the information provided.

If you select only few different values from buffered tables using the full primary key, then there is no problem.

If you select many different values from tables that are not buffered, you should consider reading all entries into sorted tables before the loop, then access the entries inside the loop using read statement.

Thomas

Former Member
0 Kudos
68

Hi sampath,

It s better to avoid select statements inside the loop.

Instead select the data using FOR ALL ENTRIES and then read them using READ TABLE statement.

Regards,

Prem

Edited by: Prem Karthick on Aug 7, 2008 2:56 PM

Former Member
0 Kudos
68

Hi Sampath,

First write all the select statements outside the loop and define a relationship between those tables, such that there should be a link between all those tables and then loop the item table.

Then read the internal tables inside the loop by using read statement with the fileds having proper relationship.

Hope this helps,

Regards,

Vijay

former_member194613
Active Contributor
0 Kudos
68

actually Thomas is right,

first you should check which tables are buffered! You should not remove select single on buffered tables from a loop.

Because the FOR ALL ENTRIES will not use the buffer (for single record buffers)

You should remove the select on unbuffered tables, and use FOR ALL ENTRIES into SORTED TABLES and use a read with key inside the loop.

But as allways, run traces first, maybe you actual performance problem is somewhere else!

Siegfried