Re: ERROR: insufficient columns in the PRIMARY KEY constraint definition
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Nagaraj Raj <nagaraj.sf@yahoo.com>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Date: 2020-09-29T22:05:42Z
Lists: pgsql-bugs
On Wed, 30 Sep 2020 at 10:36, Nagaraj Raj <nagaraj.sf@yahoo.com> wrote: > Is it mandatory/necessary that the `partition column` should be a primary key? cause if I include `load_dttm` as `PK` then its working fine. Yes, this is required. There is no concept of an index over all partitions in PostgreSQL. The requirement of having the partition key a subset of the primary key allows us to implement primary keys by just having individual unique indexes on each partition. The fact that it does not work is not a bug. There's mention in [1] section 5.10.2.3. "Unique constraints on partitioned tables must include all the partition key columns. This limitation exists because PostgreSQL can only enforce uniqueness in each partition individually.". That text likely should also mention PRIMARY KEY constraints. That probably should be changed David [1] https://www.postgresql.org/docs/11/ddl-partitioning.html
Commits
-
Reword partitioning error message
- f669ba7bdb00 12.5 landed
- 9fc212271289 14.0 landed
- 5b76e8fb675e 11.10 landed
- 49433744ff65 13.1 landed
-
Doc: Improve clarity on partitioned table limitations
- ab0c9c073563 11.10 landed
- 5c7afb4a29aa 12.5 landed
- 5610ffaf00a5 13.1 landed
- 2b888647d864 14.0 landed