Hello experts, I have some questions on query optimisations. assuming the scenario below:
create table #employee (
create table #worker (
create table #manager (
create table #employment_designation(
all employees will have a record in the #employee table. depending on their designation, they will have a record in either #manager or #worker table.
My situation now is that I need to obtain the employee designation descriptions for all employees in the employee table.
I intend to perform the joins as below:
SELECT e.name, ed.emp_dsgn_value
FROM #employee e
LEFT JOIN #manager m
ON e.emp_id = m.emp_id
LEFT JOIN #worker w
ON e.emp_id = w.emp_id
LEFT JOIN #employment_designation ed
ON ISNULL(m.emp_code, w.emp_code) = ed.emp_dsgn_code
for simplicity sake, all emp_id and emp_dsgn_id code are set as primary keys.
My question is, will the ISNULL function cause poorer query plans as compared to joining the employee_designation table 2 times, 1 to get the worker designation and another to get the manager designation?
Thank you for your time and apologies if I sound incoherent (