Boris Sagadin <boris@infosplet.com> writes:
> restoring a 1.5TB database with about 800k tables on i3.4xlarge AWS
> instace, PgSQL V12.15 on Ubuntu.
> Running pg_restore with -j 16, I noticed the pg_restore is busy for an hour
> or so with IO at 80%+ and then most of processes start idling and only a
> few doing some work, disk IO at 1-2%, pg_stat_activity is mostly idle, same
> goes for CPU, and this state proceeds for further 6 hours, disk space
> increases very slowly.
Yeah, this seems like a performance bug in pg_restore, per analysis at
[1]. Until somebody gets around to doing something about that, I'd
counsel not bothering with parallelized restore for this many tables.
If the tables are mostly small, it'd likely be more useful to use
--single-transaction mode; though you'd have to make sure that
max_locks_per_transaction is set high enough to allow creating all
those tables in one transaction.
regards, tom lane
[1] https://www.postgresql.org/message-id/3612876.1689443232%40sss.pgh.pa.us