Re: How to do a "CREATE DATABASE" and then connect to it? - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: How to do a "CREATE DATABASE" and then connect to it?
Date
Msg-id 20060604214530.GB9271@svana.org
Whole thread Raw
In response to Re: How to do a "CREATE DATABASE" and then connect to it?  (Joseph Brenner <doom@kzsu.stanford.edu>)
List pgsql-general
On Sun, Jun 04, 2006 at 02:24:32PM -0700, Joseph Brenner wrote:
> I think there are two different "connects" we're talking about here,
> one is the connection to the postgresql, the other is the "connection"
> to the "database" (i.e. the "dbname", which probably should've been
> called the "catalog").
>
> My guess (and it's only a guess) is that connecting to the postmaster
> is relatively expensive, and that a (hypothetical) "CONNECT <dbname>"
> command would be much faster.

You'd think that, but it's not as straight-forward as all that. Quite a
bit of code assume the current database, for example the cache of
system for tables and attributes. The same tables with will have the
same OIDs but different data.

Once you get around to clearing all the caches and reloading them,
flushing data from buffers, etc, it's not all that clear what you're
saving over a full backend restart. It's been considered but just
no-ones tried it yet.

And in the mean time, something like pgpool will beat the pants off you
because the shutdown of the old database and the connection of the new
can overlap, and you'll be talking to the new database before the old
has even noticed you're gone...

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: Joseph Brenner
Date:
Subject: Re: How to do a "CREATE DATABASE" and then connect to it?
Next
From: "Chris Velevitch"
Date:
Subject: Re: create view problem