Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?

From: Daniel Lenski <dlenski(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?
Date: 2014-09-24 18:06:21
Message-ID: CAOw_LSHNCbp+zscdXHLHv099Jtwyh0Sx6A5kr=G0GFDqS0un+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Sep 24, 2014 at 10:46 AM, Geoff Montee <geoff(dot)montee(at)gmail(dot)com> wrote:
>
> I believe this blog post contains better examples of the feature he's
> referring to:
>
> http://www.depesz.com/2010/08/08/waiting-for-9-1-recognize-functional-dependency-on-primary-keys/
>
> For example:
>
> SELECT
> p.id,
> p.firstname,
> p.lastname,
> count(*)
> FROM
> people p
> JOIN visits v on p.id = v.person_id
> GROUP BY p.id;
>

Geoff, that's exactly the feature I'm referring to. I see that the
inclusion of UNIQUE NOT NULL constraints was recognized as a logical
next step when this feature was introduced.

Now that I understand PG's current behavior, it doesn't seem like a
huge limitation... but I'm curious about what is preventing the UNIQUE
NOT NULL constraints from being allowed as well. Is there something
different about the internal representation of UNIQUE NOT NULL
constraints compared to PRIMARY KEY constraints?

Thanks,
Dan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Lenski 2014-09-24 18:17:20 Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?
Previous Message Tom Lane 2014-09-24 18:01:09 Re: Transaction completion timing