select
m.*
from
MEDICALHIERARCHY_LEAF_LEVEL_V_5_0_LC_1 m
inner join
(select synid
from SYNID_PROFILE_MAP_5
where upper(map_type) = upper('primary')
and upper(map_to_profile) = upper('Diagnostic Tests & Exams'))
map on m.name = map.synid
where
m.Depth is null
Above query is taking 5-20 seconds depending on data. What can further improved in it for better tuning.