Skip to Content
0
Former Member
Jan 13, 2015 at 06:17 PM

Performance issue in SELECT query

27 Views

Hi All,

I have been facing a performance issue in the below query . Please let me know your suggestions. The number of records in ITAB is around 7500.

SELECT k~vbeln k~auart k~vkorg p_posnr

FROM vbak AS k

INNER JOIN vbap AS p ON p~vbeln = k~vbeln

INTO TABLE it_output

FOR ALL ENTRIES IN ITAB

WHERE K~vbeln ne itab-vbeln

AND k~kunnr = itab-kunag

AND k~vkorg = itab-vkorg

AND k~bstnk = itab-bstnk. =>Timeout error

I have tried to put ITAB-VBELN values in a range table and tried with the following query. Still the same issue.

SELECT k~vbeln k~auart k~vkorg p_posnr

FROM vbak AS k

INNER JOIN vbap AS p ON p~vbeln = k~vbeln

INTO TABLE it_output

FOR ALL ENTRIES IN ITAB

WHERE K~vbeln not in ITAB_VBELN_RANGE_TABLE

AND k~kunnr = itab-kunag

AND k~vkorg = itab-vkorg

AND k~bstnk = itab-bstnk.

I have tried the following variation. But no improvement.

SELECT k~vbeln k~auart k~vkorg p_posnr

FROM vbak AS k

INNER JOIN vbap AS p ON p~vbeln = k~vbeln

INTO TABLE it_output

FOR ALL ENTRIES IN ITAB

WHERE k~kunnr = itab-kunag

AND k~vkorg = itab-vkorg

AND k~bstnk = itab-bstnk.

DELETE it_output WHERE vbeln in ITAB_VBELN_RANGE_TABLE.

Thanks in advance.