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

From Scott Marlowe
Subject Re: Overhead of union versus union all
Date
Msg-id dcc563d10907101050t4ae7e12kc3b5f94a8696670c@mail.gmail.com
Whole thread Raw
In response to Re: Overhead of union versus union all  (Greg Stark <gsstark@mit.edu>)
List pgsql-general
On Fri, Jul 10, 2009 at 11:47 AM, Greg Stark<gsstark@mit.edu> wrote:
> 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;

And honestly, I'd rather see development effort go into making complex
queries run faster (the things like bitmap indexes on disk etc) rather
than optimising things that i can optimise myself.

pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Overhead of union versus union all
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: How to trace client sql requests?