Alternative to COALESCE
446249Sep 14 2006 — edited Sep 14 2006Hi. We've got a query being called from a web page, where users can provide two different kinds of IDs to search on in the same text field. Each one is on a different table. We pass it in as prm_id in this query,
select substr(e.email_address,
1,
instr(e.email_address, '@') - 1)
into chr_email
from email e
join user u on e.id = u.id
join personal p on u.id = p.id
where ((u.secondary_id = coalesce(prm_id, u.secondary_id)) or
(p.ssn = coalesce(prm_id, p.ssn)));
The query is slow (11 seconds) and I've heard that COALESCE can be slow. Is there a PL/SQL alternative short of writing two queries?