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 taking more time..

former_member192432
Participant
0 Likes
821

Hi friends..

The below inner join statement is taking more time , can any body sugget me to improve the performance . I tried FOR ALL ENTRIES also but that also taking more time than inner join statement .

SELECT a~vbeln from vbap as a inner join vakpa as b

on avbeln = bvbeln

into corresponding fields of table IT_VAKPA

where a~WERKS IN S_IWERKS

and a~pstyv NE 'ZRS'

and b~vkorg = IVKORG

and b~audat IN IAUDAT

and b~vtweg IN IVTWEG.

Regards

Chetan

1 ACCEPTED SOLUTION
Read only

Rui_Dantas
Active Contributor
0 Likes
780

Hi.

VAKPA is an index table to quickly get sales orders for a given partner (sold-to party, bill-to, ship-to, etc.). It only makes sense to use it if yo know the partner number; in your case you don't, so it doesn't make sense to use it.

If what you need is to filter by VKORG, VTWEG, AUDAT then replace VAKPA by VBAK.

Rui Dantas

5 REPLIES 5
Read only

Rui_Dantas
Active Contributor
0 Likes
781

Hi.

VAKPA is an index table to quickly get sales orders for a given partner (sold-to party, bill-to, ship-to, etc.). It only makes sense to use it if yo know the partner number; in your case you don't, so it doesn't make sense to use it.

If what you need is to filter by VKORG, VTWEG, AUDAT then replace VAKPA by VBAK.

Rui Dantas

Read only

0 Likes
780

Thanks for reply....

Read only

Former Member
0 Likes
780

Hi Chetan ,

VAKPA is an index table. From the select query , it has been observed that you are not fetching any data from VAKPA. Only you have added some selection paramenters in where clause of select query.

My suggestion will be instead of using VAKPA in inner join you use VBAK along with VBAP. All the fields that you are using as selection condition from VAKPA are there in VBAK.

I am sure performance of query will be improved.

If still duo to business logic you need to use VAKPA, try to create secondary non unique index on fields VKORD,AUDATand VTWEG on table VAKPA.

However I will recommend you to go for first option only. If this does not work then go for second option.

Hopfully this will help you.

Regards,

Nikhil

Read only

Former Member
0 Likes
780

Hi Chetan ,

Prefer not to use NE in select query and also into corresponding fields of table.

Try this



SELECT a~vbeln from vbap as a inner join vakpa as b
on a~vbeln = b~vbeln
into corresponding fields of table IT_VAKPA "Try to avoid this
where a~WERKS IN S_IWERKS
"and a~pstyv NE 'ZRS'
and b~vkorg = IVKORG
and b~audat IN IAUDAT
and b~vtweg IN IVTWEG.

Delete from table T_VAKPA where pstyv = 'ZRS'.

Hope this helps you.

Edited by: Harsh Bhalla on Jan 7, 2010 9:52 PM

Read only

0 Likes
780

NE in a where is OK so long as the other key fileds in the WHERE are selective enough.

There is nothing wrong with using INTO CORRESPONDING.

Rob