Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Alternative to COALESCE

446249Sep 14 2006 — edited Sep 14 2006
Hi. 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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 12 2006
Added on Sep 14 2006
7 comments
1,037 views