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

Problem with select queries

Former Member
0 Likes
789

Dear Friends,

I have written the below select queries to get the shipment details for a given date range.

select vbeln lddat

into table itab

from likp

where lddat in l_r_date2 .

if not it_ldt[] is initial.

select fknum fkpos rebel

into table jtab

from vfkn

for all entries in itab

where

rebel = itab-vbeln.

endif.

First query is giving 82000 entries and second query is giving approx 60000 from the table VFKN( total entries in this table are 8 lakhs).

Here the problem is second select query(for all entries select query) is taking a time of 3 to 4 hours.

So please suggest me how can i reduce the time.

Thanks and Regards

7 REPLIES 7
Read only

Former Member
0 Likes
763

For dates IN operator shouldn't be used.

use less than and greater than

Read only

JozsefSzikszai
Active Contributor
0 Likes
763

hi Chandra,

what about creating a secondary index on table VFKN, with fields MANDT and REBEL?

"total entries in this table are 8 lakhs" ==> I am not sure if the meaning of unit of measure "lakhs" is clear for everyone...

hope this helps

ec

Read only

Former Member
0 Likes
763

Hi Chandra,

Plz read the below link:

http://it.toolbox.com/blogs/sap-on-db2/for-all-entries-vs-db2-join-8912

With luck,

Pritam.

Read only

Former Member
0 Likes
763

Hi Chandra,

Before 2nd query

sort it_ldt by vbeln.

If this does not improve much on performance create secondary index on VFKN for fields MANDT and REBEL.

Regards,

Mohaiyuddin

Read only

former_member585060
Active Contributor
0 Likes
763

Hi,

Use FREE or PACKAGE size.

Some steps that might make FOR ALL ENTRIES more efficient:

Removing duplicates from the driver table Sorting the driver table

If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:

FOR ALL ENTRIES IN i_tab

WHERE mykey >= i_tab-low and

mykey <= i_tab-high.

Regards

Krishna

Read only

Former Member
0 Likes
763

hi check the if condition here ..

if not itab[] is initial.

select fknum

fkpos

LFNKN

rebel

into table jtab

from vfkn

for all entries in itab

where rebel = itab-vbeln.

endif.

use all the key fields available to fetch the data

Read only

Former Member
0 Likes
763

Hi Chandra,

you should use FREE or PACKAGE size that will help you to get fetch in complete data. also check the following link http://it.toolbox.com/blogs/sap-on-db2/for-all-entries-vs-db2-join-8912.

filter the duplicates .

I hope this will help to solve your issue.

All the best

Priyanka