i have function return employee number integer
CREATE FUNCTION `getUser`(s CHAR(20)) RETURNS char(50) CHARSET latin1
RETURN @user;
when i execute its return with (0.00 sec)
but its execute this
select e.emp_number from hs_hr_employee e where
hie_code_1 in ( select hie_code_1 from hs_hr_emp_level L,hs_hr_users U where L.emp_number=U.emp_number and L.emp_number=getUser2() and ( U.def_level=1 or U.def_level=4 ) )
or
hie_code_3 in ( select hie_code_3 from hs_hr_emp_level L,hs_hr_users U where L.emp_number=U.emp_number and L.emp_number=getUser2() and U.def_level=2 )
or
hie_code_4 in ( select hie_code_4 from hs_hr_emp_level L,hs_hr_users U where L.emp_number=U.emp_number and L.emp_number=getUser2() and U.def_level=3 )
get more slower;
but when i hard coded to
select e.emp_number from hs_hr_employee e where
hie_code_1 in ( select hie_code_1 from hs_hr_emp_level L,hs_hr_users U where L.emp_number=U.emp_number and L.emp_number=5 and ( U.def_level=1 or U.def_level=4 ) )
or
hie_code_3 in ( select hie_code_3 from hs_hr_emp_level L,hs_hr_users U where L.emp_number=U.emp_number and L.emp_number=5 and U.def_level=2 )
or
hie_code_4 in ( select hie_code_4 from hs_hr_emp_level L,hs_hr_users U where L.emp_number=U.emp_number and L.emp_number=5 and U.def_level=3 )
this will return with with (0.00 sec) time. please give solution for optimiste function ;