Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: AND or UNION
Wong Chung Yin wrote:
> Which one is more efficient?
>
> 1. select * from empdemo where empdemo = 0 and empdemo = 1;
> 2. select * from empdemo where empdemo = 0
> union
> select * from empdemo where empdemo = 1;
It depends on the several factors such as the selectivity, the indexed columns or the optimizer_mode.
In general, (1) seems to be more effective especially when you have set an index on empdemo. It can use index access. On the other hand, (2) requires sorting. It is time consuming.
--- Name : Lun Wing San Title : Oracle Application Developer of Hong Kong Productivity Council Oracle Database Administrator and System Administrator of QRC Phone : (852)27885841 This posting represents the personal opinions of the author. It is not the official opinion or policy of the author's employer. Warranty expired when you opened this article and I will not be responsible for its contents or use.Received on Fri Feb 14 1997 - 00:00:00 CST
![]() |
![]() |