Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: AND or UNION

Re: AND or UNION

From: Lun Wing San (Oracle) <wslun_at_qrcsun.qrc.org>
Date: 1997/02/14
Message-ID: <3304824D.25AD@qrcsun.qrc.org>#1/1

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US