To improve the performance duration of pg_restore on your Azure PostgreSQL server, consider the following best practices:
- Use Parallel Restore: Utilize multiple concurrent jobs during the restore process. The number of jobs can be equal to or less than the number of vCPUs allocated for the target server. For example, if you have 4 vCores, you can set the
-joption to 4 or fewer. - Optimize Server Parameters: Before running
pg_restore, you can optimize certain server parameters:- Set
work_memto a higher value (e.g., 32 MB). - Increase
max_wal_sizeto 64 GB. - Set
checkpoint_timeoutto 60 minutes. - Adjust
maintenance_work_memto 2 GB. - Disable
autovacuumduring the restore process. - Enable
wal_compression. After the restore, ensure to revert these parameters to their appropriate values based on your workload requirements.
- Set
- Disable High Availability (HA): If HA is enabled, consider disabling it before running
pg_restoreto reduce overhead. - Analyze Tables Post-Restore: After the restore is complete, analyze all tables to ensure that statistics are updated, which can improve query performance.
- Review Logs for Errors: Always check the
errors.logfile after the restore process to address any issues that may have occurred during the operation.
By implementing these strategies, you should be able to reduce the duration of your pg_restore process significantly.
References: