From: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
---|---|
To: | Siddharth Jain <siddhsql(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Question on creating keys on partitioned tables |
Date: | 2023-04-03 09:53:40 |
Message-ID: | 8f38668f92ce878b63998aee42d47dd5a91dd653.camel@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 2023-03-31 at 10:35 -0700, Siddharth Jain wrote:
> Is following correct?
>
> when a PK is created on (X,Y) on the parent table what happens internally is that the
> command is run individually on each of the child tables. nothing more. nothing less.
If you are talking about inheritance, no. Creating a constraint on the parent table
has no effect on a child table.
If you are talking about partitioning: If you create a primary key on the partitioned
table, that will be implemented by a partitioned index. That partitioned index consists
of a unique index for each partition. So I guess that is more or less what you mean.
There are some differences between a primary key on the partitioned table and a unique
index on each partition:
- the primary key is a constraint, so it can be the target of a foreign key
- the primary key will force a unique index on each new partition
- the primary key keeps you from dropping the unique index on the partitions
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Dominique Devienne | 2023-04-03 11:18:44 | DEFINER / INVOKER conundrum |
Previous Message | Laurenz Albe | 2023-04-03 09:45:00 | Re: PostgreSQL |