Re: partitioned tables referenced by FKs

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: alvherre(at)2ndquadrant(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: partitioned tables referenced by FKs
Date: 2018-11-05 05:53:33
Message-ID: CADkLM=dPsRUa+CwrP7kf=12ehnxzLCJxsOn2MJo5_8Kp9ZVAwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 2, 2018 at 7:42 PM Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
wrote:

> Here's a patch to allow partitioned tables to be referenced by foreign
> keys. Current state is WIP, but everything should work; see below for
> the expected exception.
>
> The design is very simple: have one pg_constraint row for each partition
> on each side, each row pointing to the topmost table on the other side;
> triggers appear on each leaf partition (and naturally they don't appear
> on any intermediate partitioned table).
>

This is an important and much needed feature!

Based on my extremely naive reading of this code, I have two perhaps
equally naive questions:

1. it seems that we will continue to to per-row RI checks for inserts and
updates. However, there already exists a bulk check in RI_Initial_Check().
Could we modify this bulk check to do RI checks on a per-statement basis
rather than a per-row basis?

2. If #1 is possible, is the overhead of transitions tables too great for
the single-row case?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2018-11-05 05:56:14 "Writing" output lines during make
Previous Message Amit Langote 2018-11-05 05:37:05 ON COMMIT actions and inheritance