JetDeveloper
May 7th, 2009, 12:02 AM
Hi all:
UPDATE PERSON SET HISPANIC_FLAG =
(
SELECT CASE WHEN SPECIAL_CODE = 'H' THEN 'Y' ELSE 'N' END
FROM PERSON PER
LEFT JOIN LOOKUP_VALUES VAL ON (PER.ETHNIC_CODE = VAL.VALUE_CODE AND
VAL.LOOKUP_ID = 'A3247EE2772CB541AF1EB8B97A9E8D91')
WHERE PERSON.PERSON_ID = PER.PERSON_ID
)
The above query is VERY slow in Oracle (takes about 5 minutes). The PERSON table has around 56000 records. For the same database in SQL Server, it takes less than a second.
It seems to be executing the inner select 56000 times, instead of storing a copy of the LEFT JOIN in memory.
Any ideas on how to speed this up?
Thanks in advance
UPDATE PERSON SET HISPANIC_FLAG =
(
SELECT CASE WHEN SPECIAL_CODE = 'H' THEN 'Y' ELSE 'N' END
FROM PERSON PER
LEFT JOIN LOOKUP_VALUES VAL ON (PER.ETHNIC_CODE = VAL.VALUE_CODE AND
VAL.LOOKUP_ID = 'A3247EE2772CB541AF1EB8B97A9E8D91')
WHERE PERSON.PERSON_ID = PER.PERSON_ID
)
The above query is VERY slow in Oracle (takes about 5 minutes). The PERSON table has around 56000 records. For the same database in SQL Server, it takes less than a second.
It seems to be executing the inner select 56000 times, instead of storing a copy of the LEFT JOIN in memory.
Any ideas on how to speed this up?
Thanks in advance