Subject On optimising query
Author Sudheer Palaparambil
Hi,

The following query using 2 tables, sale and sale_det

sale has ( COMPANY_ID, ID ) as PK and has an index SALE_CID_ED on (
COMPANY_ID, ENTRY_DATE )

and sale_det has a PK ( COMPANY_ID, ID ) and a FK ( COMPANY_ID,
PARENT_ID ) to sale

SELECT S.bill_no, S.entry_date,
SUM( ( SD.rate * SD.quantity ) * SD.exchange_rate )
FROM sale S JOIN sale_det SD ON ( SD.company_id = S.company_id )
AND ( SD.parent_id = S.id )
WHERE ( ( S.company_id = :dCID ) AND ( S.entry_date < :dAsOn )
AND ( S.cancelled = 0 ) )
GROUP BY S.bill_no, S.entry_date

but the adapted plan is

PLAN JOIN (S INDEX (SALE_CID_ED),SD INDEX (FK_SALE_DET_TO_SALE)).

Is there any way to utilise the PK (index) of sale also to speed up the
query ?

Thank you.

Sudheer Palaparambil