cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Select from internal table or Filter internal table

dhawal_patil
Participant
0 Likes
17,040

I want to filter an internal table and store the data into another internal table based on a condition. I know of two ways, I can achieve it, i.e. with "SELECT from @itab" and "FILTER #( itab WHERE field1 = 'SOME_VALUE' )".

I want to know if there is any difference between the performance of these two approaches? Is any one of them preferred more than another?

Here's a sample code of what I am trying to do:

TYPES: BEGIN OF ty_itab,
field1 TYPE char15,
field2 TYPE char15,
END OF TY_GLINTDATA. DATA: itab TYPE SORTED TABLE OF ty_itab WITH NON-UNIQUE KEY field1. SELECT field1, field2 from ztable into table @itab. "Using SELECT from @itab SELECT field1, field2 FROM @itab as a WHERE field1 <> 'SOME_VALUE' INTO TABLE @DATA(itab_filtered). "Using filter DATA(itab_filtered) = FILTER #( itab where field1 <> 'SOME_VALUE' ).

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor

As rule-of-thumb, execution of simple logic on application server will always be faster than execution on database system, because you avoid network/data transfer.

dhawal_patil
Participant
0 Likes

Thanks, Sandra. From the documentation of SELECT - FROM @itab I understand that the data is not transported to database system if the SELECT statement meets the requirements for table buffering. If that is the case with my sample code in the question, won't the SELECT statement in my code be executed on application server and avoid network/data transfer?

Correct me if my understanding is wrong here. I am just curious about how the "SELECT - FROM @itab" works and in which cases it can be used?

Sandra_Rossi
Active Contributor

You understand well. But few tables are buffered, so, as rule-of-thumb... (as I said)

Better write natively-optimized code than relying on hypothetical same-performance SQL.

Now, it takes few minutes to test the performance by yourself...

Answers (0)