09-10-2008 8:25 AM
Hi,
Do we have to SORT the internal table before
DELETE ITAB ....WHERE... staement also to improve performance?
Thanks,
Lalitha.
09-10-2008 9:12 AM
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
09-10-2008 9:40 AM
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
09-10-2008 9:48 AM
Wrong.
Correct:
standard table -> full table scan
sorted and hashed tables -> optimized access by table key
all three are internal tables.
Thomas
09-10-2008 10:40 AM
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). '
09-10-2008 10:52 AM
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
09-10-2008 10:05 AM
09-10-2008 11:54 AM
hi,
if it is an internal table its necessary to sort it .
this will increase the speed