Re: Query with NULL

From: jefftyzzer <jefftyzzer_at_sbcglobal.net>
Date: Tue, 29 Dec 2009 13:39:06 -0800 (PST)
Message-ID: <52867f9b-fab0-4b7c-86b5-e7f14927f75a_at_d32g2000yqf.googlegroups.com>



On Dec 29, 12:19 pm, "bob123" <bob..._at_gmail.com> wrote:
> Hi,
>
> I have a lot of queries like below:>select * from bxat.no5
> >WHERE (no0_session_id = :wp18 OR :wp18 IS NULL)
> >AND (tbname = :wp19 OR :wp19 IS NULL)
>
> so an access full on no5
>
> How can I speed up this query ?
> Thanks in advance
> (Oracle 9.2.0.6)

Bob,

If the issue is that the optimizer is choking on the ORs you might, barring adding indexes, want to consider changing your query from the present set of ORs to a set of simpler UNIONs, e.g.,

select *
from bxat.no5
WHERE no0_session_id = :wp18
UNION
select *
from bxat.no5
WHERE
wp18 IS NULL
UNION

.
.
.


--Jeff Received on Tue Dec 29 2009 - 15:39:06 CST

Original text of this message