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

From Daniel Lenski
Subject Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?
Date
Msg-id CAOw_LSHNCbp+zscdXHLHv099Jtwyh0Sx6A5kr=G0GFDqS0un+Q@mail.gmail.com
Whole thread Raw
In response to Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?  (Geoff Montee <geoff.montee@gmail.com>)
Responses Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Wed, Sep 24, 2014 at 10:46 AM, Geoff Montee <geoff.montee@gmail.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


pgsql-general by date:

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