Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OR Statement causes long runtime

Status
Not open for further replies.

roedelfroe

Programmer
Jan 7, 2004
30
DE
Hi all,

following problem:

Statement:

select * from some_table
where (A OR B)
AND C
AND D

This statement was running 5 hours. In my opinion (A OR B) is causing this problem.

select * from some_table
where
A
AND C
AND D
OR
B
AND C
AND D

which is logically the same will take only a few seconds to execute.

After all, I would prefer the first statemnt (because of legibility and to keep the code as small as possible).

Any hints, how I could make the first statement faster?

Thx in advance

Roland
 
What is your OR statement in the first example? Can you consider using DECODE or IN, or is it more complex?
 
There are many possiblilities based on your indexes. Without more information all I can offer is to try:
Code:
select * from some_table
  where A
  AND C
  AND D
union all
select * from some_table
  where B
  AND C
  AND D
Hope this helps!


Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant/Custom Forms & PL/SQL - Oracle 8i & 9i - Windows 2000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top