If the union performed index lookups, but the table example performed a full table 
scan it might.  Of course with iterative index usage the point is deprecated.  However 
before they were introduced the first query would perform an FTS even if emp_type was 
the primary key.  Even with  iterative index usage the union statement is often faster.

Ian MacGregor
Stanford Linear Accelerator Center
[EMAIL PROTECTED]

-----Original Message-----
Sent: Thursday, July 31, 2003 5:54 PM
To: Multiple recipients of list ORACLE-L


I'm getting back to work on my union article, and I have yet another union question. 
Are there ever cases where a UNION might be used for performance reasons? For example, 
I could
write:

SELECT *
FROM emp
WHERE emp_type='HOURLY'
   OR emp_type='CONTRACT';

or I could write:

SELECT *
FROM emp
WHERE emp_type='HOURLY'
UNION
SELECT *
FROM emp
WHERE emp_type='CONTRACT';

This is probably too simple of an example, but are there
ever cases where using a UNION like this makes sense from a performance point-of-view?

Best regards,

Jonathan Gennick --- Brighten the corner where you are http://Gennick.com * 
906.387.1698 * mailto:[EMAIL PROTECTED]

Join the Oracle-article list and receive one
article on Oracle technologies per month by 
email. To join, visit http://four.pairlist.net/mailman/listinfo/oracle-article, 
or send email to [EMAIL PROTECTED] and 
include the word "subscribe" in either the subject or body.

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Jonathan Gennick
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, 
include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be 
removed from).  You may also send the HELP command for other information (like 
subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: MacGregor, Ian A.
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to