Skip to Content
0
Jun 09, 2018 at 11:36 PM

AND OR combination poor select performance

155 Views

Can I improve the performance of such a select statement.

SELECT * FROM ZDB_TABLE1 INTO TABLE itab FOR ALL ENTRIES IN DATA_PACKAGE WHERE SALESORG = l_salesorg AND ( SOLD_TO = DATA_PACKAGE-SOLD_TO OR SHIP_TO = DATA_PACKAGE-SHIP_TO OR /BIC/zfield1 = DATA_PACKAGE-/BIC/Zfield1 ).

this statement takes a long time to execute inspite of creating three indexes.

salesorg+sold_to

salesorg+ship_to

salesorg+zfield1

execution plan:

SELECT * FROM "zDB_table1" WHERE "SALESORG"=:A0 AND ("SOLD_TO"=:A1 OR "SHIP_TO"=:A2 OR "/bic/zfield1"=:A3) OR "SALESORG"=:A4 AND ("SOLD_TO"=:A5 OR "SHIP_TO"=:A6 OR "/bic/zfield1"=:A7) OR "SALESORG"=:A8 AND ("SOLD_TO"=:A9 OR "SHIP_TO"=:A10 OR "/bic/zfield1"=:A11) OR "SALESORG"=:A12 AND ("SOLD_TO"=:A13 OR "SHIP_TO"=:A14 OR "/bic/zfield1"=:A15) OR "SALESORG"=:A16 AND ("SOLD_TO"=:A17 OR "SHIP_TO"=:A18 OR "/bic/zfield1"=:A19)