Re: Question on creating keys on partitioned tables

2023-04-03 Thread Laurenz Albe
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 inherita

Re: Question on creating keys on partitioned tables

2023-03-31 Thread Siddharth Jain
On Fri, Mar 31, 2023 at 9:07 AM Tom Lane wrote: > Siddharth Jain writes: > > I think the two are equivalent. If not, could you please explain why? > > Well, they're formally equivalent if you require there to be only one > X value per partition (ie, PARTITION BY LIST with only one listed value >

Re: Question on creating keys on partitioned tables

2023-03-31 Thread Tom Lane
Siddharth Jain writes: > I think the two are equivalent. If not, could you please explain why? Well, they're formally equivalent if you require there to be only one X value per partition (ie, PARTITION BY LIST with only one listed value per partition); if there's more, they're not the same thing.

Re: Question on creating keys on partitioned tables

2023-03-31 Thread Siddharth Jain
Thanks Laurenz. I think the two are equivalent. If not, could you please explain why? On Fri, Mar 31, 2023 at 6:46 AM Laurenz Albe wrote: > On Thu, 2023-03-30 at 17:05 -0700, Siddharth Jain wrote: > > I have this question. Say I create a partitioned table on column X. > > > > Option 1: > > > >

Re: Question on creating keys on partitioned tables

2023-03-31 Thread Laurenz Albe
On Thu, 2023-03-30 at 17:05 -0700, Siddharth Jain wrote: > I have this question. Say I create a partitioned table on column X. > > Option 1: > > I add a primary key on (X,Y). Y is another column. Even though Y is a > globally unique PK (global meaning it is unique across partitions, not just >

Question on creating keys on partitioned tables

2023-03-30 Thread Siddharth Jain
Hi All, I have this question. Say I create a partitioned table on column X. Option 1: I add a primary key on (X,Y). Y is another column. Even though Y is a globally unique PK (global meaning it is unique across partitions, not just in one partition), Postgres does not allow me to create a PK on