Re: Creating a partition table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Scalia <jayknowsunix(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Creating a partition table
Date: 2020-10-30 18:09:02
Message-ID: 101520.1604081342@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

John Scalia <jayknowsunix(at)gmail(dot)com> writes:
> Ok I tried what Laurent had suggested and now the error is:
> Insufficient columns in PRIMARY KEY constraint definition.

> Now, the attribute the devs want is not a key value in the original table, but if it were that wouldn’t make a great deal of sense for a partition. So, now why did it gripe?

FWIW, we recently rephrased that message as "unique constraint on
partitioned table must include all partitioning columns", because
people were finding it confusing.

The reason for the restriction is that a partitioned index is really
just a collection of separate indexes on the individual leaf partitions
(just as the partitioned table is a collection of plain tables).
So it can't enforce uniqueness across partitions unless such uniqueness
is guaranteed by the partitioning scheme.

Yeah, this is an implementation restriction, but I don't foresee it
ever going away. If the indexes weren't independent then you'd lose
the scalability benefits that partitioning is meant to provide.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Magnus Hagander 2020-11-02 08:24:46 Re: free(): invalid pointer , when to dumping data to a new server
Previous Message John Scalia 2020-10-30 17:48:53 Re: Creating a partition table