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

sorting technique

Former Member
0 Likes
1,076

What is the advantage/disadvantage (over each other) of sorting using the 2 options below?

1. sorting a table through the select command (Ex. "into sorted table").

2. sorting a table using the sort keyword (Ex. "sort table itab by carrid").

thanks for the help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
968

sorting the table using select may take more time and where as the second one is consumes less time

8 REPLIES 8
Read only

Former Member
0 Likes
969

sorting the table using select may take more time and where as the second one is consumes less time

Read only

Former Member
0 Likes
968

Jabbar Junzo

by performance wise

sort table itab by carrid this one is better

because here we process in ABAP memory during runtime

but in first case ( it directly deal with records in Database it consume more time to fetch a record)

regards

deva

Read only

Former Member
0 Likes
968

One you are sorting the data at the sametime while retriving it form database and the 2nd one you are sorting after getting the data in your internal table.

So if there is selection criteria its better to sort after retriving the data in your internal table, performance wise this is better

With luck,

Pritam.

Read only

Former Member
0 Likes
968

Hi,

By performance wise 2 nd statement is fine bz SORT is a abap keyword.

So after getting data into int table u have to use sort int table. If in the select query u use sorting then the performance will be down bz for every select statement the data going to sort.

thanks,

Edited by: Baidyanath Subudhi on Aug 27, 2008 5:48 PM

Read only

Former Member
0 Likes
968

Hi,

A Very good question.

Sorting with select query makes your internal table data as in the sorted by option.But it takes much time as the burdon on the database server is more.

Where as Sort itab makes more performance.

Regards,

Rama.

Read only

Former Member
0 Likes
968

disadvantage at No. 1 is that you are using a sorted table.

means you gotta take care when working with it. E.G. Append will not work tho you gotta insert instead.

another disadvantage is that it uses more time than just doing an array fetch and the sorting the stuff.

Read only

Former Member
0 Likes
968

Hi,

For first select ... into sorted table...

it has to select the data as well as sort at same time so lot of performance issue.

for second sort itab... its juz matter of sorting so not that much overhead..

thanx.

Read only

Former Member
0 Likes
968

thanks people. I gave points to all of you.