Speeding Up PostgreSQL Database Imports
Instead of using one process to import data, you can use multiple with the --jobs=N
flag, where N
is the number of logical cores you have. It looks something like this:
pg_restore --clean --no-acl --no-owner --jobs=4 -h localhost -d my_app_development production-data.dump
Using -j N
also works.
Don’t know how many logical cores you have?
- On a Mac:
sysctl -n hw.ncpu
- On a Windows:
WMIC CPU Get DeviceID,NumberOfLogicalProcessors
- On a Unix:
nproc --all