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!

use UNION instead of OR

jr323216anMay 3 2007 — edited May 4 2007
I see the advice of using UNION in place of OR in many tuning articles but I can't find any Metalink articles that explain what is going on.

I still find in 10g "UNION" / "UNION ALL" will often out perform: "OR".

Why? Where is this documented?

Thanks!

example:

select * from foo where id in(n) OR id in (m);
-vs-
select * from foo where id in (n)
UNION
select * from foo where id in (m);

where n & m are in the form
select id from bar where ....

col id in foo is indexed and NOT NULL the index can be unique or nonunique

UNION can be in the form UNION or UNION ALL

I already understand that this works, I see this in many tuning books (google: "use union instead of or")
my question is WHY it works, WHERE is it documented in Oracle.

thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 31 2007
Added on May 3 2007
3 comments
472 views