You Asked
How Can we optimize the below query
MERGE INTO Department dept
USING (SELECT DISTINCT emp_name, hire_date
FROM employees
WHERE emp_id = '10') emp_details
ON (dept.emp_name = emp_details.emp_name
AND emp_details.hire_date IS NOT NULL)
WHEN MATCHED THEN
UPDATE
SET dept.hire_date = emp_details.hire_date
MERGE INTO Department dept
USING (SELECT DISTINCT emp_name, gender
FROM employees
WHERE emp_id = '10') emp_details
ON (dept.emp_name = emp_details.emp_name
AND emp_details.gender IS NOT NULL)
WHEN MATCHED THEN
UPDATE
SET dept.gender = emp_details.gender
and Connor said...
They look fine to me.... Nicely formatted, mixed case makes it easier to read.
And since you've given us NO information about
- are they slow ?
- which is slower ?
- performance stats ?
- explain plan ?
- table structure ?
that is pretty much all we can say on it....
Is this answer out of date? If it is, please let us know via a Comment