CLONE DATABASE (with copy on write?) - Mailing list pgsql-general

From Clark C. Evans
Subject CLONE DATABASE (with copy on write?)
Date
Msg-id 1321134043.5652.140660998102677@webmail.messagingengine.com
Whole thread Raw
Responses Re: CLONE DATABASE (with copy on write?)  (Igor Polishchuk <igor@powerreviews.com>)
Re: CLONE DATABASE (with copy on write?)  (Simon Riggs <simon@2ndQuadrant.com>)
Re: CLONE DATABASE (with copy on write?)  (Jerry Sievers <gsievers19@comcast.net>)
List pgsql-general
Hello all!

Our company has some headaches in our application development
and deployment process.  The chief problem is, "creating stages",
which to this audience is, cloning a database efficiently,
making and testing a few changes, perhaps recording the
differences between databases, and then dropping the database.

I'm eternally grateful for someone who pointed out that we
should be using "CREATE DATABASE ... WITH TEMPLATE".  However,
this has two big disadvantages.  First, it only works if you
can kick the users off the clone.  Secondly, it still takes
time, uses disk space, etc.  We have some big databases.

I was also thinking about using ZFS with PostgreSQL to do
some sort of copy-on-write.  However, this would require me
to spawn a whole *new* PostgreSQL instance.  In both of these
cases, you lose your cache...

So, I was wondering... could PostgreSQL grow the ability to
"CLONE" a database by re-using existing file system blocks,
sharing them across databases?  This would perhaps be fast,
keep the shared memory cache relevant for both the old copy
and the clone, and remove WAL overhead.  Then, if the block
has to be edited, it'd be cloned in memory, and the clone
would be flushed.

I'm just imagining a world where "deploying" a new version
of our software that makes very small catalog changes and
tweaks a few rows would be... quick.  Quick to try, check,
test, and even deploy on live servers.

Best,

Clark

pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Need Help Installing Dblink…(Desperately…)
Next
From: Cody Caughlan
Date:
Subject: Re: Large values for duration of COMMITs and slow queries. Due to large WAL config values?