From: | Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Sami Imseih <samimseih(at)gmail(dot)com> |
Cc: | Amul Sul <sulamul(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Bug in detaching a partition with a foreign key. |
Date: | 2025-01-20 17:23:47 |
Message-ID: | 202501201723.72ixsyt5gua5@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2025-Jan-20, Sami Imseih wrote:
> The patch that Amul and I wrote both achieve the same result.
> The approach that Amul took builds a list of constraint OIDs,
> which could grow with the number of partitions and foreign keys
> on those partitions. Maybe not a big deal?
Nope, not a big deal. It would be a big deal if we were talking about
268 million partitions (>1GB palloc size), but that's impractical for
other reasons.
> In my suggestion [1], I just do one extra pg_constraint lookup
> to determine If the relation on the parent and child constraint match,
> and in that case we can skip the rest of the work to cut the
> link as it's not needed.
A pg_constraint lookup is going to be a lot slower.
I attach Amul's patch again with the comments I added and your test
case. Needs adaptation for backpatching to 16 and 15.
Thanks!
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
Attachment | Content-Type | Size |
---|---|---|
0001-Fix-detach-of-a-partition-that-has-a-toplevel-FK-to-.patch | text/x-diff | 5.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | vignesh C | 2025-01-20 17:30:45 | Re: create subscription with (origin = none, copy_data = on) |
Previous Message | Robert Haas | 2025-01-20 17:21:57 | Re: Bypassing cursors in postgres_fdw to enable parallel plans |