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: 

Perfomance issue

Former Member
0 Kudos

Hi,

Do we have to SORT the internal table before

DELETE ITAB ....WHERE... staement also to improve performance?

Thanks,

Lalitha.

7 REPLIES 7

ThomasZloch
Active Contributor
0 Kudos

Check out the online help for the "DELETE itab" statement. It says that you need to work with SORTED tables (defined as SORTED, not just sorted with the SORT command) to optimize the deletion process. The fields in the WHERE condition should be all fields or at least a top-down part of the table key. This applies to 7.00 and up as I have just discovered.

You could also use "DELETE ... WITH TABLE KEY ..."

Thomas

Former Member
0 Kudos

Hi,

Before you use the delete comand you need check if the table is STANDARD or HASHED table or internal table.

If it is a standard table or hashed table a full table scan is always required.

If it is a internal table then, you need to sort the table.

Regards,

Shobana.K

0 Kudos

Wrong.

Correct:

standard table -> full table scan

sorted and hashed tables -> optimized access by table key

all three are internal tables.

Thomas

0 Kudos

In SAP F1 help for delete with where condition, this is wat is given

'When you use the WHERE condition with a STANDARD or HASHED table, a full table scan is always required.

If you are working with a SORTED TABLE, the partial sequential processing can be optimized so that only the entries that actually satisfy the WHERE condition are processed. This optimization requires that each sub-condition is linked with AND; that no parentheses are used; that at least one sub-condition is in the form k = v; and that the conditions in the form k1 = v1 ... kn = vn cover at least the first part of the table key.

The starting point for the loop is specified using a binary search with the sub-conditions that cover the table key (partially or completely). This optimization is similar to the optimization in the READ statement. The loop is only processed from the starting point to the point where these sub-conditions are still met. (See also Optimized Key Operations in Internal Tables). '

0 Kudos

I had another look. Your statement is correct in a 6.20 release (maybe 6.40, cannot check), but not any longer in a 7.00 release.

So I take back the simple "wrong" and replace with the above.

This shows that somebody raising a question should include the SAP release he is working on, but nobody ever does this here anyway.

Cheers

Thomas

Former Member
0 Kudos

It is a standard table.

Statement is

DELETE ITAB WHERE -


.

Former Member
0 Kudos

hi,

if it is an internal table its necessary to sort it .

this will increase the speed