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

Select Statement performance

Former Member
0 Likes
906

SELECT * FROM CATSPS INTO TABLE TCATSPS

WHERE TRANSFER = 'X' .

SELECT RUECK

CATSBELNR

STOKZ

FROM AFRU

INTO table T_AFRU

for all entries in tcatsps

WHERE CATSBELNR = TCATSPS-BELNR

AND STOKZ = TCATSPS-STOKZ.

In the above statement, Tcatsps internal table is getting around 3 Lakh records. Becos of which when i run the select statement, time is taken for ever.

Can I improve the performance statment of above select statemtn in any other effective way.

Thanks

Regds

Venu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
875

Hi <b>Saamy</b>,

Instead of <b>*</b> specify <b>require fields</b> only...

In where condition specify all <b>Primary keys</b> and <b>Secondary indexes</b>...

If helpful reward..

Regards,

<b>Kishore Reddy Vuppuluri.</b>

6 REPLIES 6
Read only

Former Member
0 Likes
875

hi Venu,

1. Put all the entries order IN T_AFRU i.e, the way they are in the database table ..

2. Try including all the primary keys in the where condition of your select statement ..

3. Avoid using * instead fetch the required fields only ..

this way you can improve the performance of your program

Regards,

Santosh

Read only

Former Member
0 Likes
876

Hi <b>Saamy</b>,

Instead of <b>*</b> specify <b>require fields</b> only...

In where condition specify all <b>Primary keys</b> and <b>Secondary indexes</b>...

If helpful reward..

Regards,

<b>Kishore Reddy Vuppuluri.</b>

Read only

Former Member
0 Likes
875

Hi Venu,

From your code i could see that u have totally ignored the Primary keys.

Try to give counter and stokz feilds of CATSPS in ranges and the RUECK and RMZHL feilds of AFRU in ranges.

Dont use select * from catsps.

Reward if it helps.

Thanks,

Anooop

Read only

Former Member
0 Likes
875

Hi,

the problem is first select statement is wotking fione. the time is taken for second select statement. and i couldnt use primary keys... cos condition i need doesnt depend on promary keys.

regds

Venu

Read only

0 Likes
875

define secondary indexes on the fields using which you are writing the select statement.

Read only

Former Member
0 Likes
875

Yes, Use Secondary Index as well as Inner Join.

Thx

SAP Developer