A faster way to copy a postgresql database (or the best way)

后端 未结 4 1534
礼貌的吻别
礼貌的吻别 2021-01-29 22:12

I did a pg_dump of a database and am now trying to install the resulting .sql file on to another server.

I\'m using the following command.

psql -f databa         


        
4条回答
  •  感动是毒
    2021-01-29 23:10

    The usage of pg_dump is generally recommended to be paired with pg_restore, instead of psql. This method can be split among cores to speed up the loading process by passing the --jobs flag as such:

    $ pg_restore --jobs=8 dump.sql
    

    Postgres themselves have a guide on bulk loading of data.

    I also would recommend heavily tuning your postgresql.conf configuration file and set appropriately high values for the maintenance_work_mem and checkpoint_segments values; higher values on these may dramatically increase your write performance.

提交回复
热议问题