I have a small sql (running in PeopleSoft application engine) which I am using to calculate depreciation. The below pasted sql is taking a lot of time to run.I have aroung 8 crore rows in the depreciation table/record. I did the indexing on business_unit,asset_id and book as well on the ps_depreciation table/record but no affect.
UPDATE PS_AZC_INTFC_FIN A
SET A.DEPR=(
SELECT SUM(B.DEPR)
FROM TP_AZ_DEPRECIATION B
WHERE A.BUSINESS_UNIT=B.BUSINESS_UNIT
AND A.ASSET_ID=B.ASSET_ID
AND A.BOOK=B.BOOK
AND B.FISCAL_YEAR <=2012)
WHERE EXISTS(
SELECT 'X' FROM TP_AZ_DEPRECIATION D
WHERE A.BUSINESS_UNIT=D.BUSINESS_UNIT
AND A.ASSET_ID=D.ASSET_ID
AND A.BOOK=D.BOOK
AND D.FISCAL_YEAR <=2012)
This PS_AZC_INTFC_FIN is a custom record which has asset_id,businesS_unit and book as keys.
Please help.
Regards,
Vishal
UPDATE PS_AZC_INTFC_FIN A
SET A.DEPR=(
SELECT SUM(B.DEPR)
FROM TP_AZ_DEPRECIATION B
WHERE A.BUSINESS_UNIT=B.BUSINESS_UNIT
AND A.ASSET_ID=B.ASSET_ID
AND A.BOOK=B.BOOK
AND B.FISCAL_YEAR <=2012)
WHERE EXISTS(
SELECT 'X' FROM TP_AZ_DEPRECIATION D
WHERE A.BUSINESS_UNIT=D.BUSINESS_UNIT
AND A.ASSET_ID=D.ASSET_ID
AND A.BOOK=D.BOOK
AND D.FISCAL_YEAR <=2012)
This PS_AZC_INTFC_FIN is a custom record which has asset_id,businesS_unit and book as keys.
Please help.
Regards,
Vishal