Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6C1A91337BD0 for ; Tue, 19 Apr 2011 06:22:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 54069-09 for ; Tue, 19 Apr 2011 09:22:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iy0-f174.google.com (mail-iy0-f174.google.com [209.85.210.174]) by mail.postgresql.org (Postfix) with ESMTP id B7F7E1337B82 for ; Tue, 19 Apr 2011 06:22:05 -0300 (ADT) Received: by iyb14 with SMTP id 14so4602690iyb.19 for ; Tue, 19 Apr 2011 02:22:05 -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 :content-transfer-encoding; bh=qwXgBoVjtIc/tZvkehDYPhOcPwXIz2siPEghimcG3is=; b=gLgzyno54Iw8NL6SC4SOtQ8v4Nt5G1vcSLOOnWRQL2UbzQB0kIPYQTaTg4bJYRM+HL poyOX7umjTk+eic5ov2IEie7u+Qu+Kx0aJDOw1vF5p07c2iO21iDeI/akQ5Xu6OM4skL kEmDSvew/zGTwgEdKg8y3d7QiSx8XCPP8g/Lw= 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:content-transfer-encoding; b=Y18udvKSWd0wjrB6IFpZdPIthOs8HZU43cV5g0E2QdnJkPbLIJyxwhnWbi/lrXBWoZ K30Xb5pgxmtJqWw5zCdCaytsRZgoQf5OKpOVnOlS9HshiluztH7Hnsp8PqR8mOyLw04b 5ry86+df5ZKwoqmwtEDLbPMzZZ3xiq/PDDj4I= MIME-Version: 1.0 Received: by 10.42.72.131 with SMTP id o3mr7397228icj.234.1303204925540; Tue, 19 Apr 2011 02:22:05 -0700 (PDT) Received: by 10.42.138.199 with HTTP; Tue, 19 Apr 2011 02:22:05 -0700 (PDT) In-Reply-To: References: Date: Tue, 19 Apr 2011 11:22:05 +0200 Message-ID: Subject: Re: big distinct clause vs. group by From: Claudio Freire To: Robert Klemme Cc: Uwe Bartels , pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201104/265 X-Sequence-Number: 43327 On Tue, Apr 19, 2011 at 11:07 AM, Robert Klemme wrote: > I find that slightly contradictory: either you do care about the > values then your business requirements dictate the aggregate function. > =A0If you only want to pick any value actually in the table but do not > care about which one (e.g. MIN or MAX or any other) then you don't > actually care about the value. =A0Because "SELECT a, MAX(b) ... GROUP BY > a" and "SELECT a, MIN(b) ... GROUP BY a" are not equivalent. =A0And, if > you do not care then there is probably no point in selecting them at > all. =A0At best you could use a constant for any legal value then. I know it sounds weird, but there are at times when you only want one of the actual values - but don't care which one precisely. It happened to me at least once. So, it may sound as nonsense, but it is probably not. Just uncommon.