以下の計画をヒントに変換したいと思います。
これは、より長い時間がかかる実際のクエリです。同じ解決策を提案してください
SELECT AIA.INVOICE_ID,
AIA.INVOICE_NUM,
AIA.INVOICE_TYPE_LOOKUP_CODE,
AIA.BATCH_ID,
AIA.LAST_UPDATED_BY,
AIA.INVOICE_DATE,
AIA.ORG_ID,
AIA.VENDOR_ID,
AIA.INVOICE_CURRENCY_CODE,
AIA.SET_OF_BOOKS_ID,
AIA.VENDOR_SITE_ID,
AIA.INVOICE_AMOUNT,
AIA.BASE_AMOUNT
FROM AP_INVOICES_ALL AIA
WHERE AIA.INVOICE_AMOUNT = 0
AND AIA.SET_OF_BOOKS_ID = 1
AND AIA.CANCELLED_DATE is null
AND EXISTS
(SELECT 1
FROM AP_INVOICE_DISTRIBUTIONS_ALL AIDA,
GL_CODE_COMBINATIONS GCC,
FND_LOOKUP_VALUES_VL FLVC
WHERE AIDA.INVOICE_id=AIA.INVOICE_id
AND AIDA.ACCOUNTING_DATE BETWEEN '01-apr-2006' AND
sysdate
AND GCC.CODE_COMBINATION_ID= AIDA.DIST_CODE_COMBINATION_ID
AND FLVC.LOOKUP_CODE=GCC.SEGMENT7
AND FLVC.LOOKUP_TYPE = 'NATURAL_ACCT_SERVICE_TAX'
AND FLVC.DESCRIPTION IN
('Service Tax', 'Secondary High Edu',
'Education Cess'));
これが計画です
SELECT STATEMENT, GOAL = ALL_ROWS Cost=43 Cardinality=1 Bytes=83
FILTER Parent id=0
TABLE ACCESS BY INDEX ROWID Object owner=AP Object name=AP_INVOICES_ALL Cost=31 Cardinality=1 Bytes=83 Parent id=1
INDEX RANGE SCAN Object owner=AP Object name=AP_INVOICES_N4 Cost=3 Cardinality=31 Parent id=2
FILTER Parent id=1
NESTED LOOPS Cost=12 Cardinality=1 Bytes=80 Parent id=4
MERGE JOIN CARTESIAN Cost=10 Cardinality=1 Bytes=68 Parent id=5
TABLE ACCESS BY INDEX ROWID Object owner=APPLSYS Object name=FND_LOOKUP_VALUES Cost=6 Cardinality=1 Bytes=48 Parent id=6
INDEX RANGE SCAN Object owner=APPLSYS Object name=FND_LOOKUP_VALUES_U1 Cost=3 Cardinality=16 Parent id=7
BUFFER SORT Cost=4 Cardinality=4 Bytes=80 Parent id=6
TABLE ACCESS BY INDEX ROWID Object owner=AP Object name=AP_INVOICE_DISTRIBUTIONS_ALL Cost=4 Cardinality=4 Bytes=80 Parent id=9
INDEX RANGE SCAN Object owner=AP Object name=AP_INVOICE_DISTRIBUTIONS_U1 Cost=2 Cardinality=8 Parent id=10
TABLE ACCESS BY INDEX ROWID Object owner=GL Object name=GL_CODE_COMBINATIONS Cost=2 Cardinality=1 Bytes=12 Parent id=5
INDEX UNIQUE SCAN Object owner=GL Object name=GL_CODE_COMBINATIONS_U1 Cost=1 Cardinality=1 Parent id=12
取っている