Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8B5741337B9C for ; Mon, 25 Apr 2011 11:22:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 11076-03 for ; Mon, 25 Apr 2011 14:22:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qw0-f46.google.com (mail-qw0-f46.google.com [209.85.216.46]) by mail.postgresql.org (Postfix) with ESMTP id 01160133740B for ; Mon, 25 Apr 2011 11:22:22 -0300 (ADT) Received: by qwk3 with SMTP id 3so961036qwk.19 for ; Mon, 25 Apr 2011 07:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=O4q4Z7wkSnRN3Qm/gOuDkfuvQRHp77utuGNPUdVI5H0=; b=p6Gs5kWRx7/zLVLwxTx0I2pdG0PI5DuBq7Y78PQ3gyiVyqywyBXxiFAUit22NWP5wK LVq1mqigUtwZqn4lI+dMcFu+Ky1HKVitRIi7/i/wwjQP3S/nQkyS2yyPUbSCeTrL22AZ BfWmplcJEzYRDnbEo1H4JvI0Ni1+e4ZnT61Tk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=X05vA4heH1AE2bJ0MJc+BF/59goeqdK1M+Nd4nViyydsDWakUCCkSXTbq6ZoJQDGDY Eyf/WSexj3BmimHf5FWPAVaol4HqVALtlZhf+M1cbdodyxDVAQI/ytuljesnSDAXpd3z Zx//Ay1QSROP5Xe77xCy/4Kcsdrf5aY16svEk= MIME-Version: 1.0 Received: by 10.229.102.73 with SMTP id f9mr2730670qco.168.1303741343407; Mon, 25 Apr 2011 07:22:23 -0700 (PDT) Received: by 10.229.230.71 with HTTP; Mon, 25 Apr 2011 07:22:23 -0700 (PDT) In-Reply-To: <4B594466-0554-4AF8-A8BC-8FDA9C393DF9@gmail.com> References: <4B594466-0554-4AF8-A8BC-8FDA9C393DF9@gmail.com> Date: Mon, 25 Apr 2011 17:22:23 +0300 Message-ID: Subject: Re: big distinct clause vs. group by From: =?KOI8-U?B?96bUwcymyiD0yc3eydvJzg==?= To: Robert Haas Cc: Uwe Bartels , "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=002354471dd8a71f4604a1beef5c X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.344 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201104/341 X-Sequence-Number: 43403 --002354471dd8a71f4604a1beef5c Content-Type: text/plain; charset=ISO-8859-1 2011/4/23 Robert Haas > On Apr 18, 2011, at 1:13 PM, Uwe Bartels wrote: > > Hi Robert, > > > > thanks for your answer. > > the aggregate function I was talking about is the function I need to use > for the non-group by columns like min() in my example. > > There are of course several function to choose from, and I wanted to know > which causes as less as possible resources. > > Oh, I see. min() is probably as good as anything. You could also create a > custom aggregate that just always returns its first input. I've occasionally > wished we had such a thing as a built-in. > > I've once done "single" grouping function - it checks that all it's input values are equal (non-null ones) and returns the value or raises an error if there are two different values. Best regards, Vitalii Tymchyshyn -- Best regards, Vitalii Tymchyshyn --002354471dd8a71f4604a1beef5c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

2011/4/23 Robert Haas = <robertmhaas@gmail.com><= /span>
On Apr 18, 2011, at 1:13 PM, Uwe Bartels <uwe.bartels@gmail.com> wrote:
> Hi Robert,
>
> thanks for your answer.
> the aggregate function I was talking about is the function I need to u= se for the non-group by columns like min() in my example.
> There are of course several function to choose from, and I wanted to k= now which causes as less as possible resources.

Oh, I see. min() is probably as good as anything. You could also crea= te a custom aggregate that just always returns its first input. I've oc= casionally wished we had such a thing as a built-in.


I've once done "single" grouping function= - it checks that all it's input values are equal (non-null ones) and r= eturns the value or raises an error if there are two different values.=A0

Best regards, Vitalii Tymchyshyn=A0



--
Best regards,
=A0Vitalii Tymchyshyn
--002354471dd8a71f4604a1beef5c--