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

Select query performance.

Former Member
0 Likes
1,278

Can somebody explain me which is the better option provided we have large data selection.

select * into table it_mara from mara.

or

select * appending table it_mara from mara package size 10000.

endselect.

Please tell me as i don't have large data in my development system.

11 REPLIES 11
Read only

Former Member
0 Likes
1,212

select * into table it_mara from mara.

is better out of 2.

Try selecting only those fields which are required instead of using select *.

Cheers

VJ

Read only

Former Member
0 Likes
1,212

Hi,

Go for second one

select * appending table it_mara from mara package size 10000.

endselect.

Regards

vijay

Read only

Former Member
0 Likes
1,212

>

> select * into table it_mara from mara.

This is a better as it does not go through a limit and there is only one hit on the database

Regards,

Ravi

Note : Please mark all the helpful answes

Read only

0 Likes
1,212

Example

Addition

... PACKAGE SIZE n

Effect

Works like ... INTO wa, except that the selected data is not placed in the internal table itab line by line, but in packets of n lines. The old contents of itab are overwritten.

n <= 0 causes a runtime error.

Internally, n is placed in a type I field. Here, the usual conversion rules apply (see MOVE).

After leaving the processing loop, the contents of the internal table itab are undefined.

If the result of the selection is a table, the data is retrieved in a processing loop introduced by SELECT and concluded by ENDSELECT. The processing passes through the loop once for each line read.

Read only

Former Member
0 Likes
1,212

the first option is better, if possible select only the fields which you need instead of selecting all the fields, if there is any where condition try to use the Index.

Read only

aris_hidalgo
Contributor
0 Likes
1,212

Hi Phani,

First check if you really need to select all fields of table MARA. If you just need a specfic number of records then you could use UP TO n ROWS in your select.

Hope this helps...

P.S. Please award points for useful answers.

Read only

Former Member
0 Likes
1,212

What exactly is the differnce in database access when we use packet size?

Read only

0 Likes
1,212

Hi,

When you Use Packet size then in your case it will fetch 10000 records and then again starts from 10001to 20000 records. if you have millions of records then Packet size is better option.

Regards

vijay

Read only

Former Member
0 Likes
1,212

hi,

It depends on the data.

If we are having less data, so for

Select * into table it_mara from mara.

If you are having huge amount of data.

Then we have to go for

Select * appending table it_mara from mara package size 10000.

Ex: If there is a select which executes for a long time, if this time is exceeding the limit of timeout., then we get data in packages.

Regards,

Sailaja.

Read only

Former Member
0 Likes
1,212

hi,

When we are using packet size as 100 ,the system gets 100 records from the database for every loop. So, for getting every 100 records, it hits the database.

Regards,

Sailaja.

Read only

Former Member
0 Likes
1,212

Hi,

If you don`t have too many records to be fetched, use select <fieldlist.......

1. Your first query fetches all records and make sure that the primary key of the table are addressed in where conditions.

2. By adding appending addition you append records into your internal table.

To ensure optimized code, use your select query with all key additions in the where clause, avoid endselect and only select fields which are needed instead of all fields.

Hope the info. is helpful, reward points if so.

Regards