Re: UNION vs UNION ALL

From: Tim Bower <jtbower_at_santeecooper.com>
Date: 1996/08/29
Message-ID: <3225A9B1.18D4_at_santeecooper.com>#1/1


Danny Roosens wrote:
>
> Hi,
>
> is it fair to say that one should use
>
> 'UNION ALL' as default
> and use 'UNION' only when duplicates are expected and not wanted
>
> because it's faster.

I wouldn't necessarily say UNION ALL as a default, because it depends on the problem you are trying to solve. You are correct, however, in observing that UNION incurs additional overhead (possibly a sort) to eliminate duplicates.

I would say use UNION ALL anytime you can be sure that the answer sets from the queries on either side of the UNION operator will be mutually exclusive.

Regards,

Tim
jtbower_at_smtp.santeecooper.com

Any opinions expressed are exclusively my own, and not those of my employer.... Received on Thu Aug 29 1996 - 00:00:00 CEST

Original text of this message