Re: parallel pg_restore blocks on heavy random read I/O on all children processes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dimitrios Apostolou <jimis(at)gmx(dot)net>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: parallel pg_restore blocks on heavy random read I/O on all children processes
Date: 2025-03-20 19:17:17
Message-ID: 1095774.1742498237@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Dimitrios Apostolou <jimis(at)gmx(dot)net> writes:
> I noticed the weird behaviour that doing a pg_restore of a huge database
> dump, leads to constant read I/O (at about 15K IOPS from the NVMe drive
> that has the dump file) for about one hour. I believe it happens with
> any -j value>=2.

> In particular, I get output like the following in the pg_restore log, only
> a few seconds after running it:

> pg_restore: launching item 12110 TABLE DATA yyy
> pg_restore: processing data for table "public.yyy"
> [ long pause ...]
> pg_restore: finished item 12110 TABLE DATA yyy

I am betting that the problem is that the dump's TOC (table of
contents) lacks offsets to the actual data of the database objects,
and thus the readers have to reconstruct that information by scanning
the dump file. Normally, pg_dump will back-fill offset data in the
TOC at completion of the dump, but if it's told to write to an
un-seekable output file then it cannot do that.

> And here is the pg_dump command which has created the dump file, executed
> on PostgreSQL 16.

> pg_dump -v --format=custom --compress=zstd --no-toast-compression $DBNAME | $send_to_remote_storage

Yup, writing the output to a pipe would cause that ...

> What do you think causes this? Is it something that can be improved?

I don't see an easy way, and certainly no way that wouldn't involve
redefining the archive format. Can you write the dump to a local
file rather than piping it immediately?

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Dimitrios Apostolou 2025-03-20 19:57:45 Re: parallel pg_restore blocks on heavy random read I/O on all children processes
Previous Message Dimitrios Apostolou 2025-03-19 18:46:58 parallel pg_restore blocks on heavy random read I/O on all children processes