Re: Re : Re : Query "top 10 and others"

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Edson Richter <edsonrichter(at)hotmail(dot)com>
Cc: David Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Re : Re : Query "top 10 and others"
Date: 2014-07-08 21:40:20
Message-ID: CAHyXU0xdvo0GesOxcAPGz=g+1b0MiED_4bRyxEWk2Pn27aqeDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Jul 5, 2014 at 8:12 AM, Edson Richter <edsonrichter(at)hotmail(dot)com> wrote:
> Thanks!
>
> I'll investigate (explain) performance for both versions.

also be advised that in most cases when you use SQL 'UNION' you really
should be using 'UNION ALL'. It's a very common mistake:

UNION: form proper set union, combine set and remove tuple duplicates
UNION ALL: append two sets

For large sets, the duplicate removal can be expensive and possibly
introduce subtle data dependent bugs in the worst case.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gavin Flower 2014-07-09 02:04:51 Re: Random-looking primary keys in the range 100000..999999
Previous Message Kynn Jones 2014-07-08 19:04:45 Re: Random-looking primary keys in the range 100000..999999