Re: Skip WAL in ALTER TABLE

Lists: pgsql-hackers
From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Skip WAL in ALTER TABLE
Date: 2009-10-13 02:39:49
Message-ID: 20091013113410.A6F8.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

We can skip writing WAL during COPY and CLUSTER if archive_mode is off,
but we don't use the skipping during tables rewrites in ALTER TABLE.
Also we don't use BulkInsertState there.

Is it possible to use WAL-skipping and BulkInsertState in ATRewriteTable() ?
If ok, I'll submit a patch for the next commitfest.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Skip WAL in ALTER TABLE
Date: 2009-10-13 08:22:07
Message-ID: 1255422127.15590.1269.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 2009-10-13 at 11:39 +0900, Itagaki Takahiro wrote:

> We can skip writing WAL during COPY and CLUSTER if archive_mode is off,
> but we don't use the skipping during tables rewrites in ALTER TABLE.
> Also we don't use BulkInsertState there.
>
> Is it possible to use WAL-skipping and BulkInsertState in ATRewriteTable() ?
> If ok, I'll submit a patch for the next commitfest.

Yes

--
Simon Riggs www.2ndQuadrant.com


From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org, Simon Riggs <simon(at)2ndQuadrant(dot)com>
Subject: Re: Skip WAL in ALTER TABLE
Date: 2009-10-15 04:18:31
Message-ID: 20091015131605.A2C3.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Simon Riggs <simon(at)2ndQuadrant(dot)com> wrote:

> > Is it possible to use WAL-skipping and BulkInsertState in ATRewriteTable() ?
> > If ok, I'll submit a patch for the next commitfest.
>
> Yes

Patch attached.
This patch skip WAL writes during table rewrites from ALTER TABLE.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

Attachment Content-Type Size
nowal-on-alter-table_20091015.patch application/octet-stream 2.2 KB

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Skip WAL in ALTER TABLE
Date: 2009-10-15 07:19:46
Message-ID: 1255591186.30088.1060.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, 2009-10-15 at 13:18 +0900, Itagaki Takahiro wrote:
> Simon Riggs <simon(at)2ndQuadrant(dot)com> wrote:
>
> > > Is it possible to use WAL-skipping and BulkInsertState in ATRewriteTable() ?
> > > If ok, I'll submit a patch for the next commitfest.
> >
> > Yes
>
> Patch attached.
> This patch skip WAL writes during table rewrites from ALTER TABLE.

Looks fine to me, apart from

if (!XLogArchivingActive() || newrel->rd_istemp)
hi_options |= HEAP_INSERT_SKIP_WAL;

I think the second condition is unnecessary, so just

if (!XLogArchivingActive())
hi_options |= HEAP_INSERT_SKIP_WAL;

which is what COPY does. Temp tables are excluded in heap_insert()

--
Simon Riggs www.2ndQuadrant.com


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Skip WAL in ALTER TABLE
Date: 2009-11-04 12:25:13
Message-ID: 4AF172A9.4020202@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs wrote:
> On Thu, 2009-10-15 at 13:18 +0900, Itagaki Takahiro wrote:
>> Simon Riggs <simon(at)2ndQuadrant(dot)com> wrote:
>>
>>>> Is it possible to use WAL-skipping and BulkInsertState in ATRewriteTable() ?
>>>> If ok, I'll submit a patch for the next commitfest.
>>> Yes
>> Patch attached.
>> This patch skip WAL writes during table rewrites from ALTER TABLE.
>
> Looks fine to me, apart from
>
> if (!XLogArchivingActive() || newrel->rd_istemp)
> hi_options |= HEAP_INSERT_SKIP_WAL;
>
> I think the second condition is unnecessary, so just
>
> if (!XLogArchivingActive())
> hi_options |= HEAP_INSERT_SKIP_WAL;
>
> which is what COPY does. Temp tables are excluded in heap_insert()

Yep.

Committed with the above and some other small changes. I moved the
initialization of BulkInsertState and hi_options outside the if-block.
Feels clearer this way, and they're only needed if newrel==true, not if
only needscan==true.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com