Re: proposal: CREATE DATABASE vs. (partial) CHECKPOINT

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tv(at)fuzzy(dot)cz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: proposal: CREATE DATABASE vs. (partial) CHECKPOINT
Date: 2014-10-27 22:52:44
Message-ID: 31997.1414450364@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tomas Vondra <tv(at)fuzzy(dot)cz> writes:
> That being said, our CREATE DATABASE docs currently say this

> Although it is possible to copy a database other than template1 by
> specifying its name as the template, this is not (yet) intended as
> a general-purpose "COPY DATABASE" facility. The principal
> limitation is that no other sessions can be connected to the
> template database while it is being copied. CREATE DATABASE will
> fail if any other connection exists when it starts; otherwise, new
> connections to the template database are locked out until CREATE
> DATABASE completes. See Section 21.3 for more information.

> I think that this limitation pretty much means no one should use CREATE
> DATABASE for cloning live databases in production environment (because
> of the locking).

Good point. But the other side of that coin is that if somebody *was*
doing this, the locking would mean that slowing it down would be even
more painful than you might think. Still, personally I'm willing to
accept that downside, given that we've pretty much always had the above
caveat in the docs.

> It also seems to me the "general-purpose COPY DATABASE" described in the
> docs is what we're describing in this thread.

Well, no, because the restriction "nobody can be connected to the source
database" would still apply; relaxing that would be enormously more
complicated, and probably fragile, than what we're talking about here.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2014-10-27 22:57:11 Re: pgcrypto: PGP signatures
Previous Message Adam Brightwell 2014-10-27 21:59:54 Re: Directory/File Access Permissions for COPY and Generic File Access Functions