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

Performance Issue with this Join

Former Member
0 Likes
675

select distinct vbrkvbeln vbrkfkart vbrkvtweg vbrkknumv vbrk~fkdat

vbrkkunrg vbrksfakn vbrk~knuma

into table i_vbrk

from VRPMA join vbrk

on vrpmavbeln = vbrkvbeln

where ( vrpmafkart = 'ZCB4' or vrpmafkart = 'S2' or

vrpma~fkart = 'S1')

and vrpma~vtweg = p_vtweg

and vbrk~fkdat ge t_date

and vbrk~fkdat le e_date

and vbrk~vkorg = p_vkorg.

Any ideas on enhancing the above selection as both vbrk vrpma are huge tables!

Thanks in advance

5 REPLIES 5
Read only

messier31
Active Contributor
0 Likes
615

Hi Srikanth,

Try this

select vbrkvbeln vbrkfkart vbrkvtweg vbrkknumv vbrk~fkdat

vbrkkunrg vbrksfakn vbrk~knuma

into table i_vbrk

<b>from VBRK join VRPMA</b> on vbrkvbeln = vrpmavbeln

where ( vrpmafkart = 'ZCB4' or vrpmafkart = 'S2' or

vrpma~fkart = 'S1')

and vrpma~vtweg = p_vtweg

and vbrk~fkdat ge t_date

and vbrk~fkdat le e_date

and vbrk~vkorg = p_vkorg.

let me know if is efficient and works by selecting appropriate data..

Read only

Former Member
0 Likes
615

Pankaj,

Thanks for your reply, your suggestion basically involves interchanging selection tables, so this has no effect on performance metric. any ideas about enhancing/replacing joins as a whole ??

Thanks.

Read only

Former Member
0 Likes
615

give a try to this piece of code

select vbrkvbeln vbrkfkart vbrkvtweg vbrkknumv vbrk~fkdat

vbrkkunrg vbrksfakn vbrk~knuma

into table i_vbrk

from VRPMA inner join vbrk

on vrpmamandt = vbrkmandt

and vrpmavbeln = vbrkvbeln

and vrpmavbeln = vbrkvbeln

and vrpmavkorg = vbrkvkorg

and vrpmafkdat = vbrkfkdat

and vrpmavtweg = vbrkvtweg

and vrpmafkart = vbrkfkart

and vrpmakunnr = vbrkkunrg

and vrpmakunag = vbrkkunag

and vrpmavbtyp = vbrkvbtyp

and vrpmaERNAM = vbrkERNAM

where ( vrpmafkart = 'ZCB4' or vrpmafkart = 'S2' or

vrpma~fkart = 'S1')

and vrpma~vtweg = p_vtweg

and vbrk~fkdat ge t_date

and vbrk~fkdat le e_date

and vbrk~vkorg = p_vkorg.

after the select query

SORT i_vbrk by fdl1 fld2...

delete adjacent duplicates from i_vbrk comparing fld1 fld2 ...

note: here fld1, fld2 denotes the key fields of your internal table according to which you were initially saying SELECT DISTINCT.

SHANE

Read only

0 Likes
615

Could you just tell me whether view created based on these 2 tables can be used instead of join. Please suggest me which is more efficient with very large amount of data??

Read only

Former Member
0 Likes
615

As you are selecting all the fields from VBRK and even the filters are also present in VBRK table, I really do not understand the use of VRPMA.

Instead if you try the below query

select distinct vbrkvbeln vbrkfkart vbrkvtweg vbrkknumv vbrk~fkdat

vbrkkunrg vbrksfakn vbrk~knuma

into table i_vbrk

from vbrk

where vbrk~fkart in ('ZCB4','S2','S1')

and vrpma~vtweg = p_vtweg

and vbrk~fkdat ge t_date

and vbrk~fkdat le e_date

and vbrk~vkorg = p_vkorg.