aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2025-04-04 14:51:08 -0500
committerNathan Bossart <nathan@postgresql.org>2025-04-04 14:51:08 -0500
commite3cc039a7d930ffe86e706944a2b3368bd3ef506 (patch)
treeb706ccf7a4f8a8d09bad99e6ac4206362c1926f3 /src
parentd9c7911e1a5f354b7c34b7f53a52e0a690e7ebc9 (diff)
downloadpostgresql-e3cc039a7d930ffe86e706944a2b3368bd3ef506.tar.gz
postgresql-e3cc039a7d930ffe86e706944a2b3368bd3ef506.zip
Skip second WriteToc() call for custom-format dumps without data.
Presently, "pg_dump --format=custom" calls WriteToc() twice. The second call updates the data offset information, which allegedly makes parallel pg_restore significantly faster. However, if we're not dumping any data, there are no data offsets to update, so we can skip this step. Reviewed-by: Jeff Davis <pgsql@j-davis.com> Discussion: https://postgr.es/m/Z9c1rbzZegYQTOQE%40nathan
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index e44b887eb29..f7c3af56304 100644
--- a/src/bin/pg_dump/pg_backup_custom.c
+++ b/src/bin/pg_dump/pg_backup_custom.c
@@ -755,9 +755,11 @@ _CloseArchive(ArchiveHandle *AH)
* If possible, re-write the TOC in order to update the data offset
* information. This is not essential, as pg_restore can cope in most
* cases without it; but it can make pg_restore significantly faster
- * in some situations (especially parallel restore).
+ * in some situations (especially parallel restore). We can skip this
+ * step if we're not dumping any data; there are no offsets to update
+ * in that case.
*/
- if (ctx->hasSeek &&
+ if (ctx->hasSeek && AH->public.dopt->dumpData &&
fseeko(AH->FH, tpos, SEEK_SET) == 0)
WriteToc(AH);
}