Re: ON CONFLICT clause NOT working on Partition Table PostgreSQL 12

From: Geri Wright <geri(dot)w123(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Inzamam Shafiq <inzamam(dot)shafiq(at)hotmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Steve Midgley <science(at)misuse(dot)org>, pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: ON CONFLICT clause NOT working on Partition Table PostgreSQL 12
Date: 2022-09-22 10:39:27
Message-ID: CAKSgRY7WQtA2wyFkX-rE6oLMLm=bfr9EphQy2_H6x0Affz528A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

You can create a Constraint trigger to check the new values of the desired
columns when updating or insering them. This trigger will fire for each
partition but checks the data in the entire table. The trigger should
obtain an advisory lock for the unique columns . Here is a blog for more
information.
https://blog.ioguix.net/postgresql/2015/02/05/Partitionning-and-constraints-part-1.html

On Tue, Sep 20, 2022, 5:46 AM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:

> On Fri, 16 Sept 2022 at 19:52, Inzamam Shafiq
> <inzamam(dot)shafiq(at)hotmail(dot)com> wrote:
> > Is there anyway we can create constraint on column only which are not
> part of partition key?
>
> Unfortunately, there is no way to create a unique or primary key
> constraint unless the constraint contains all columns from the
> partition key. This is explained in the limitations section in [1].
>
> If you need such a constraint, then you might want to consider
> changing your partition key.
>
> David
>
> [1] https://www.postgresql.org/docs/12/ddl-partitioning.html
>
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Hendriks 2022-09-23 07:31:17 Delete from locking ordering differences
Previous Message David Rowley 2022-09-20 09:46:07 Re: ON CONFLICT clause NOT working on Partition Table PostgreSQL 12