From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Hannu Krosing <hannuk(at)google(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Horribly slow pg_upgrade performance with many Large Objects |
Date: | 2025-05-07 14:51:19 |
Message-ID: | aBtzZ4PyccUVCcyA@nathan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, May 05, 2025 at 02:23:25PM -0500, Nathan Bossart wrote:
> That leaves pg_shdepend. For now, I've just instructed pg_upgrade to COPY
> the relevant pg_shdepend rows as an independent step, but perhaps there's a
> reasonably straightforward way to put that in pg_dump, too.
It turns out there is. TableDataInfo's filtercond field can be used to
easily add a WHERE clause to the data dumping command. On my laptop,
upgrading with --jobs=8 with 10M large objects evenly distributed across 10
databases (each with a non-bootstrap-superuser owner and another role with
select rights) takes ~100 seconds without this patch and ~30 seconds with
it.
I've also added dependency tracking, version checks (this only works for
upgrades from >=v12 for now), a hack to ensure the columns for
pg_largeobject_metadata/pg_shdepend are collected, and comments. I'm sure
there's something I've missed, but this patch has worked well in my tests
thus far.
Taking a step back, I'm a little disappointed in the gains here. A 3-9x
speedup is nice, but I guess I was hoping to find another order of
magnitude somewhere. To do any better, I think we'd need to copy the files
for pg_largeobject_metadata directly for upgrades from >= v16, but that
would have to fit somewhere between when pg_restore creates the database
and when it restores any large object comments/seclabels. I'm not wild
about the amount of hackery required to get that working.
--
nathan
Attachment | Content-Type | Size |
---|---|---|
v2-0001-pg_upgrade-Use-COPY-for-large-object-metadata.patch | text/plain | 8.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Álvaro Herrera | 2025-05-07 14:56:01 | Re: pg_dump does not dump domain not-null constraint's comments |
Previous Message | jian he | 2025-05-07 14:37:27 | Re: pg_dump does not dump domain not-null constraint's comments |