Re: Overhead of union versus union all - Mailing list pgsql-general

From Greg Stark
Subject Re: Overhead of union versus union all
Date
Msg-id 407d949e0907101047l39aff5d8h428c044a849da6d3@mail.gmail.com
Whole thread Raw
In response to Re: Overhead of union versus union all  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Overhead of union versus union all
Re: Overhead of union versus union all
List pgsql-general
On Fri, Jul 10, 2009 at 6:37 PM, Jeff Davis<pgsql@j-davis.com> wrote:
>
> -- foo has a primary key
> SELECT * FROM foo UNION SELECT * FROM foo;
>
> That's logically equivalent to:
>
> SELECT * FROM foo;
>
> But postgresql will add a sort anyway.


Well no, it's equivalent to SELECT DISTINCT * FROM foo;


--
greg
http://mit.edu/~gsstark/resume.pdf

pgsql-general by date:

Previous
From: "James B. Byrne"
Date:
Subject: How to trace client sql requests?
Next
From: artacus@comcast.net
Date:
Subject: Re: XML import with DTD