Search code examples
databasepostgresqlpg-dump

Force postgres dump to use copy rather than INSERTS


While restoring some database backups I noticed that pg_dump is actually using INSERTS rather than COPY. I am not even specifying -d flag but it's still using INSERTS for every database / table I try to dump which is why restores take hours rather than minutes.

According to the pg docs pg_dump should use COPY by default but in my case it's not. Is there a way to ensure pg_dump uses COPY ?

Here's the pg_dump command:

pg_dump -Fp -t some_table -h localhost -d thisDB -f /some_dir/bkup

Any ideas ?

Thx.


Solution

  • you are specifying -d !!!!!:

    pg_dump -Fp -t some_table -h localhost -d thisDB -f /some_dir/bkup
                                          ^^^^
    

    Luckily -d is no more.