pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Wilkinson <w.kevin.wilkinson@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Methods to quickly spin up copies of an existing databases
Date: Fri, 1 Mar 2019 11:57:30 -0800
Message-ID: <d042d137-1888-6040-4cd7-e498941ea15e@gmail.com> (raw)
In-Reply-To: <CANrrCRxLYcoXw_VWD10jEYCAwYb-wX8AKSFxe8vaFDUHpnYS_Q@mail.gmail.com>
References: <CANrrCRxLYcoXw_VWD10jEYCAwYb-wX8AKSFxe8vaFDUHpnYS_Q@mail.gmail.com>

if you are able/willing to use ZFS (rather than ext4, xfs, ...) to store 
your database, then it might work for you. ZFS is copy-on-write so it 
can very quickly clone a database.

kevin

On 3/1/2019 12:08 PM, Arjun Ranade wrote:
> I'm working on a project that requires on-demand creation of a fresh 
> database as quick as possible (seconds). Essentially, this is a build 
> server that will require a cloned instance of Postgres to run unit 
> tests on.  So the pattern of use would be:
>
>   * Build is triggered
>   * New postgres instance is created and connection details are
>     provided to build server
>   * Build runs unit tests that connect to the database
>   * Build completes, database is no longer needed and can be thrown away
>
> The "template" database will be approximately 50gb in size so my 
> question is what is the fastest way to spin up new instances of this 
> database?  I've thought of using "CREATE DATABASE WITH TEMPLATE..." 
> but that takes too long. I've also thought about cloning the $PGDATA 
> directory, changing the port number in postgresql.conf, and starting a 
> new instance of postgres pointing to the cloned data directory.
>
> Both of these methods take longer than I'd like, so I'm wondering if 
> anyone else has this use case and what methods they've used to solve this.
>
> Thanks,
> Arjun

view thread (7+ messages)  latest in thread

Message-ID: <d042d137-1888-6040-4cd7-e498941ea15e@gmail.com>
Permalink:  ../d042d137-1888-6040-4cd7-e498941ea15e@gmail.com/
Also on:    postgresql.org/message-id/d042d137-1888-6040-4cd7-e498941ea15e@gmail.com

 · 

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: w.kevin.wilkinson@gmail.com
  Subject: Re: Methods to quickly spin up copies of an existing databases
  In-Reply-To: <d042d137-1888-6040-4cd7-e498941ea15e@gmail.com>
  References: <CANrrCRxLYcoXw_VWD10jEYCAwYb-wX8AKSFxe8vaFDUHpnYS_Q@mail.gmail.com> <d042d137-1888-6040-4cd7-e498941ea15e@gmail.com>

* 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