Application Development and Automation 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: 
Read only

Optimized select statement - performance issue

Former Member
0 Likes
840

Hi,

I have a select statement on table FMFCTRT which is hitting the performance badly in my report which is called inside a BSEG table loop. I have included all the primary keys in the where condition still I do not see the difference in performance. Can anyone check and see if this is a optimized select statement on FMFCTRT table ?

SELECT BESCHR INTO LS_FILSTRU-BESCHR    

UP TO 1 ROWS       FROM FMFCTRT      

WHERE SPRAS = SY-LANGU      

AND   FIKRS = L_FIKRS      

AND   FICTR = LS_FILSTRU-FISTL     

AND   DATBIS => LS_FILSTRU-BLDAT.

Regards

Praneeth

6 REPLIES 6
Read only

former_member189779
Active Contributor
0 Likes
759

Hi,

Remove select statement if its inside the loop. Write before looping.

Then use READ TABLE inside your bseg loop to read respective entries from your  FMFCTRT internal table.

Hope this helps.

Read only

vijaymanikandan
Contributor
0 Likes
759

Hello

Avoid using select inside Loop as mentioned by Vinit. Apart from this check the database statistics in DB20 for the table and ask your basis team to update the same if its needed.

Br,

Vijay V

Read only

Former Member
0 Likes
759

Well, I would use a SELECT SINGLE rather than UP TO 1 ROWS, but I don't think that is your problem. Check you SELECT on BSEG.

Also - how many records in the BSEG loop?

Rob

Read only

Former Member
0 Likes
759

Hi,

Just assaid: Remove SELECT STATEMENT inside the loop. Get it before looping using FOR ALL ENTRIES then in your looping use READ TABLE.

Regards,

Jake

Read only

Former Member
0 Likes
759

I really don't think having the SELECT in the LOOP is the problem.

It's more likely that the BSEG internal table has multiple entries for the same value of the primary keys. So the samne SELKECT is done over and over for no particular reason.

Only do the SELECT once for each unique value of the primary key.

Rob

Read only

0 Likes
759

I also think you should not use the select within a loop. For every entry in the loop a database select is performed. Better is to select all entries at once and use a read.

Furthermore, when you are only dealing with cleared items, open iotems or customer items, you should consider to use the tabel BSIS, BSAS or BSID instead, since they are for that purpose.