pg_restoreを高速化するオプション等
pg_dump -h ipアドレス -p 5432 -F c -f sample.db.car -U postgres DB名
pg_restore -h ipアドレス -p 5432 -U postgres -d postgres -c -C -F c -j 8 sample.db.car
削除(-c)、再作成(-C)、並列8(-j 8 ※コア数と同じにするべき。)、カスタムアーカイブ(-F c)で動くようにしている。
コマンド以外の注意点として、
- 速度向上のためpg_restore前にpostgresql.confのfsyncをoffにすること。
- pg_restore後はpostgresql.confのfsyncを元の設定に戻して、再起動すること。