Re: WAL logging volume and CREATE TABLE

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WAL logging volume and CREATE TABLE
Date: 2011-08-02 15:32:57
Message-ID: 201108021532.p72FWvQ29530@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Merlin Moncure wrote:
> On Tue, Aug 2, 2011 at 8:34 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > Our docs suggest an optimization to reduce WAL logging when you are
> > creating and populating a table:
> >
> > ? ? ? ?http://www.postgresql.org/docs/9.0/static/runtime-config-wal.html#RUNTIME-CONFIG-WAL-SETTINGS
> >
> > ? ? ? ?In minimal level, WAL-logging of some bulk operations, like CREATE
> > ? ? ? ?INDEX, CLUSTER and COPY on a table that was created or truncated in the
> > ? ? ? ?same transaction can be safely skipped, which can make those operations
> > ? ? ? ?much faster (see Section 14.4.7). But minimal WAL does not contain
> > ? ? ? ?enough information to reconstruct the data from a base backup and the
> > ? ? ? ?WAL logs, so either archive or hot_standby level must be used to enable
> > ? ? ? ?WAL archiving (archive_mode) and streaming replication.
> >
> > I am confused why we issue significant WAL traffic for CREATE INDEX?
> > Isn't the index either created or removed if the transaction fails?
> > What crash recovery activity state do we need WAL logging for? ?I
> > realize we have to do WAL logging for streaming replication, but CREATE
> > TABLE isn't going to affect that. ? I also realize the index has to be
> > on disk on commit, but the same is true for doing the CREATE TABLE in
> > the same transaction block.
> >
> > Does this optimization work for INSERT ... SELECT?
>
> I don't think so -- insert/select doesn't take a full table lock and
> it writes to the heap. The optimization only works when other

My question is whether INSERT ... SELECT is/could be optimized when the
CREATE TABLE happens in the same transaction block.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-08-02 15:54:24 Re: WAL logging volume and CREATE TABLE
Previous Message Bruce Momjian 2011-08-02 15:30:30 Re: WAL logging volume and CREATE TABLE