Re: Add primary key/unique constraint using prefix columns of an index

From: Vik Reykja <vikreykja(at)gmail(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add primary key/unique constraint using prefix columns of an index
Date: 2012-05-22 19:58:11
Message-ID: CALDgxVs9N3K4sD_oOs5Wjt3neyNHE2U=_3AV6c3QW2=BaJiD+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, May 22, 2012 at 1:36 PM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:

> On 22 May 2012 18:24, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> > Now that there are index only scans, there is a use case for having a
> > composite index which has the primary key or a unique key as the
> > prefix column(s) but with extra columns after that. Currently you
> > would also need another index with exactly the primary/unique key,
> > which seems like a waste of storage and maintenance.
> >
> > Should there be a way to declare a "unique" index with the unique
> > property applying to a prefix of the indexed columns/expression? And
> > having that, a way to turn that prefix into a primary key constraint?
> >
> > Of course this is easier said then done, but is there some reason for
> > it not to be a to-do item?
>
> +1
>
> Very useful
>
>
Semi-private note to Simon: isn't this pretty much what I was advocating at
the London meetup last month?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Farina 2012-05-22 20:15:45 Re: Changing the concept of a DATABASE
Previous Message Jeff Janes 2012-05-22 19:49:45 Re: Add primary key/unique constraint using prefix columns of an index