Re: improve performance of pg_dump with many sequences
Nathan Bossart <nathandbossart@gmail.com>
From: Nathan Bossart <nathandbossart@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>, Euler Taveira <euler@eulerto.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-01-07T23:06:22Z
Lists: pgsql-hackers
I'm still looking into this, but here are some preliminary thoughts. On Mon, Dec 29, 2025 at 12:26:01PM -0500, Tom Lane wrote: > In the no-good-deed-goes-unpunished department: pg_dump's use > of pg_get_sequence_data() (nee pg_sequence_read_tuple()) is > evidently responsible for the complaint in bug #19365 [1] > that pg_dump can no longer survive concurrent sequence drops. This seems to be reproducible on older versions. With a well-timed sleep right before dumpSequenceData()'s pre-v18 query, I can produce a relation-does-not-exist error with a concurrent sequence drop. Perhaps v18 made this easier to reach, but given it moved the sequence tuple access to collectSequences()'s query, I'm not sure why that would be. > BTW, I'm unconvinced that pg_dump behaves sanely when this function > does return nulls. I think the ideal thing would be for it to skip > issuing setval(), but right now it looks like it will issue one with > garbage values. Before v18, pg_dump just ERRORs due to insufficient privileges on a sequence. IMHO that makes sense. If you ask pg_dump to dump something you don't have privileges on, I'd expect it to error instead of silently skipping it. -- nathan
Commits
-
pg_dump: Fix gathering of sequence information.
- 7a485bd641b7 19 (unreleased) landed
- 39d55557661f 18.2 landed
-
Improve performance of dumpSequence().
- 68e962998598 18.0 landed
-
Improve performance of dumpSequenceData().
- bd15b7db489d 18.0 landed
-
Introduce pg_sequence_read_tuple().
- c8b06bb969bf 18.0 landed
-
Parse sequence type and integer metadata in dumpSequence().
- 23687e925f94 18.0 landed