pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Torsten Förtsch <tfoertsch123@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: Is there a way to speed up WAL replay?
Date: Wed, 31 Oct 2018 11:30:49 -0400
Message-ID: <20181031153049.GX4184@tamriel.snowman.net> (raw)
In-Reply-To: <CAKkG4_nRs+wiDpBrhAU=76XHMBFi08Hb47HD_Fvn0q-+U-h5-A@mail.gmail.com>
References: <CAKkG4_nRs+wiDpBrhAU=76XHMBFi08Hb47HD_Fvn0q-+U-h5-A@mail.gmail.com>

Greetings,

* Torsten Förtsch (tfoertsch123@gmail.com) wrote:
> I am working on restoring a database from a base backup + WAL. With the
> default settings the database replays about 3-4 WAL files per second. The
> startup process takes about 65% of a CPU and writes data with something
> between 50 and 100 MB/sec.

What are you using for a restore_command..?  You can typically get some
improvement by using a restore_command that's faster or pre-stages files
locally to minimize the time required to run, or dumping all the WAL
into the xlog, but that's not something I typically recommend.

> Is there a way to speed that up? The disk can easily sustain 400-500 MB/sec.

Kind of depends what you're ultimately going for..  If you've made
everything else faster and you're still only seeing 65% CPU utilization
on the one CPU, then maybe there's just enough latency to the disks to
be an issue, in which case you could possibly restore on to a ramdisk if
you've got enough memory/space and don't mind that.

There's other things that can be done too, like adjusting the amount of
shared buffers; depending on what you're doing that can also make a
difference in replay speed (we've been working to improve that though).

I tend to find that it's better to just reduce the amount of WAL that
needs to be replayed by taking incremental backups more frequently and
using things like pgbackrest's delta restore ability for doing repeated
restores to the same location.  Of course, that's not likely to help you
out much here.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (6+ messages)  latest in thread

Message-ID: <20181031153049.GX4184@tamriel.snowman.net>
Permalink:  ../20181031153049.GX4184@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20181031153049.GX4184@tamriel.snowman.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sfrost@snowman.net, tfoertsch123@gmail.com
  Subject: Re: Is there a way to speed up WAL replay?
  In-Reply-To: <20181031153049.GX4184@tamriel.snowman.net>
  References: <CAKkG4_nRs+wiDpBrhAU=76XHMBFi08Hb47HD_Fvn0q-+U-h5-A@mail.gmail.com> <20181031153049.GX4184@tamriel.snowman.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox