pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedSpeeding up adding fky on a very large table
3+ messages / 2 participants
[nested] [flat]
* Speeding up adding fky on a very large table
@ 2022-10-19 13:31 Ravi Krishna <s_ravikrishna@aol.com>
2022-10-19 14:49 ` Re: Speeding up adding fky on a very large table Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Ravi Krishna @ 2022-10-19 13:31 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
AWS Aurora based on PG 13.
Large partitioned table of 5+ billion rows and 7TB in size.
ALTER TABLE abc ADD CONSTRAINT fk_123 FOREIGN KEY (a,b,c) REFERENCES xyz(1,2,3);
It seems this is not parallelized. Is there a way. Or directly going into each partition is the only way ( not even sure it is possible).
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Speeding up adding fky on a very large table
2022-10-19 13:31 Speeding up adding fky on a very large table Ravi Krishna <s_ravikrishna@aol.com>
@ 2022-10-19 14:49 ` Ron <ronljohnsonjr@gmail.com>
2022-10-19 20:44 ` Re: Speeding up adding fky on a very large table Ravi Krishna <s_ravikrishna@aol.com>
0 siblings, 1 reply; 3+ messages in thread
From: Ron @ 2022-10-19 14:49 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 10/19/22 08:31, Ravi Krishna wrote:
> AWS Aurora based on PG 13.
>
>
> Large partitioned table of 5+ billion rows and 7TB in size.
>
> ALTER TABLE abc ADD CONSTRAINT fk_123 FOREIGN KEY (a,b,c) REFERENCES
> xyz(1,2,3);
>
> It seems this is not parallelized. Is there a way. Or directly going into
> each partition is the only way ( not even sure it is possible).
In vanilla Postgresql (including RDS Postgresql) you can add the FK to each
partition and then ALTER TABLE ONLY the parent table.
Don't know about Aurora, though.
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Speeding up adding fky on a very large table
2022-10-19 13:31 Speeding up adding fky on a very large table Ravi Krishna <s_ravikrishna@aol.com>
2022-10-19 14:49 ` Re: Speeding up adding fky on a very large table Ron <ronljohnsonjr@gmail.com>
@ 2022-10-19 20:44 ` Ravi Krishna <s_ravikrishna@aol.com>
0 siblings, 0 replies; 3+ messages in thread
From: Ravi Krishna @ 2022-10-19 20:44 UTC (permalink / raw)
To: ronljohnsonjr@gmail.com; pgsql-general@lists.postgresql.org
Our issue is that it takes 20hrs to index the full table. Hopefully we can add FK in multiple child partitions concurrently, otherwise doing it per partition offers no advantage from performance pov.
Need to test. Hopefully PG should not lock the referred table during the first build, stopping concurrent execution of other partitions.
In vanilla Postgresql (including RDS Postgresql) you can add the FK to each partition and then ALTER TABLE ONLY the parent table.
Don't know about Aurora, though
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-10-19 20:44 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 13:31 Speeding up adding fky on a very large table Ravi Krishna <s_ravikrishna@aol.com>
2022-10-19 14:49 ` Ron <ronljohnsonjr@gmail.com>
2022-10-19 20:44 ` Ravi Krishna <s_ravikrishna@aol.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox