importing postgres tar file throws parallel not supported in postgres 12
-
10-03-2021 - |
Domanda
I'm trying to import a db that someone sent me: testdb.tar (43GB size) First I've imported using:
pg_restore --host localhost --port 5432 --username postgres --dbname testdb --role postgres --no-password --verbose testdb.tar
It took 23 hours to complete. I supose it used just a single core. Now, trying to do it faster, using the available 16 cores, I tried:
pg_restore --host localhost --port 5432 --username postgres --dbname testdb --role postgres --no-password -j 16 --verbose testdb.tar
However, it throws the following error:
pg_restore: error: parallel restore is not supported with this archive file format
Not really sure why it complains.
Soluzione 2
I managed to make it work by using "-Fd" and the the directory source name, instead of the tar source file. Exported directory contains files like: 3235.dat.gz ... 3300.dat.gz, log.txt and toc.dat So, it works by using:
pg_restore --host localhost --port 5432 --username postgres --dbname testdb --role postgres --no-password -Fd -j 16 --verbose /path/to/testdb_directory
Altri suggerimenti
Because the "tar" format cannot be restored in parallel.
Use the "custom" or "directory" format of pg_dump
so that it can be restored with parallel processes.
But Jeff had a good idea (see the comment): If you untar the backup into a directory, you can then do a parallel restore by pointing pg_restore to that directory.