pg_dump without explicit table locking

From: Jürgen Strobel <juergen+pg(at)strobel(dot)info>
To: pgsql-hackers(at)postgresql(dot)org
Subject: pg_dump without explicit table locking
Date: 2014-03-17 11:52:19
Message-ID: 5326E1F3.7060008@strobel.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi,

at work at my company I inherited responsibility for a large PG 8.1 DB,
with a an extreme number of tables (~300000). Surprisingly this is
working quite well, except for maintenance and backup. I am tasked with
finding a way to do dump & restore to 9.3 with as little downtime as
possible.

Using 9.3's pg_dump with -j12 I found out that pg_dump takes 6 hours to
lock tables using a single thread, then does the data dump in 1 more
hour using 12 workers. However if I patch out the explicit LOCK TABLE
statements this only takes 1 hour total. Of course no one else is using
the DB at this time. In a pathological test case scenario in a staging
environment the dump time decreased from 5 hours to 5 minutes.

I've googled the problem and there seem to be more people with similar
problems, so I made this a command line option --no-table-locks and
wrapped it up in as nice a patch against github/master as I can manage
(and I didn't use C for a long time). I hope you find it useful.

regards,
Jürgen Strobel

Attachment Content-Type Size
pg_dump_nolock.diff text/plain 4.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2014-03-17 11:53:31 Re: Various typos
Previous Message Andres Freund 2014-03-17 11:27:06 Re: Changeset Extraction v7.9.1