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: 

Would an index help?

Former Member
0 Kudos
74

Hi,

People are complaining about the time it takes to execute a report, and when I checked out the program, I found the following select that is slowing things down:

SELECT * INTO CORRESPONDING FIELDS OF TABLE t_vbfa FROM vbfa

WHERE vbeln = lt_recup-vbeln

AND vbtyp_n = 'M'

AND vbtyp_v = 'J'.

Would an index help to speed this up?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
46

Hi,

Instead you can code it like this and see that it is not in a loop.It lowers the performance.

SELECT *(instead of * use list of the fields u need)

INTO TABLE t_vbfa FROM vbfa

WHERE vbeln = lt_recup-vbeln

AND vbtyp_n = 'M'

AND vbtyp_v = 'J'.

Dont use corresponding also. But take care that the order of source and destination tables are the same.

4 REPLIES 4

former_member386202
Active Contributor
0 Kudos
46

Hi,

I seems that u r using select statement within loop. Dont use select stamtent within loop and select fields only those u required . Use into table instead of into corresponding. Use FOR ALL ENTRIES.

Regards,

prashant

0 Kudos
46

Hi,

You can create further indexes on a table in the ABAP Dictionary. These are called secondary indexes.

PURPOSE:

This is necessary if the table is frequently accessed in a way that does not take advantage of the sorting of the primary index for the access. Different indexes on the same table are distinguished with a three-place index identifier.

Generally it is used when field which u want is not a primary field .

Advatange:

1. faster access to data when field is not a primary key field.

Disadvatnage:

1. Slower down database table inset, update delete commands.

Few secondary indexes, don't create any problem,

in fact they are very good,

if we use those fields in search queryes, often.

If there are many secondary indexes,

the only overhead (very little overhead)

is felt by the database,

when ever it INSERTS a new record , in the table.

(bcos it has to update the index also , all indexes)

If we use secondary index it takes more time to fetch data than using primary index.

Secondary indexes are used to enhancement performance when retrieving data. For example, say you have a table AFKO where the key to the table is AUFNR. You can select data from this table using AUFNR, the performance will be great because you are using the key. Say you need to hit this table with GLTRP(finish date), it is not part of the key, so the performance would be poor. If you created a secondard index using this field GLTRP, the performance would be improved.

http://help.sap.com/saphelp_470/helpdata/en/cf/21eb20446011d189700000e8322d00/frameset.htm

kesavadas_thekkillath
Active Contributor
0 Kudos
46

Donot include *,corresponding in the query......

put the exact fields u require in select clause and use ""into table"" .

Then check all the key fields are provided in where clause.

use for all entries in select clause......if there is indexexd for the table then provide it.

Former Member
0 Kudos
47

Hi,

Instead you can code it like this and see that it is not in a loop.It lowers the performance.

SELECT *(instead of * use list of the fields u need)

INTO TABLE t_vbfa FROM vbfa

WHERE vbeln = lt_recup-vbeln

AND vbtyp_n = 'M'

AND vbtyp_v = 'J'.

Dont use corresponding also. But take care that the order of source and destination tables are the same.