Re: TRUNCATE SERIALIZABLE and frozen COPY

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TRUNCATE SERIALIZABLE and frozen COPY
Date: 2012-11-09 10:28:20
Message-ID: CABRT9RAy5Fcexfq6fVMJ=i7R4Q9Qr9sRjWaSZiewZ6Cxkcq6rA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 7, 2012 at 5:34 PM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> I was unhappy with changing the behaviour of TRUNCATE, and still am.
> So the proposal here is to have a specific modifier on TRUNCATE
> command that makes it MVCC safe by throwing a serialization error.
> That new behaviour should be requestable by adding the SERIALIZABLE
> keyword.
> i.e. TRUNCATE foo SERIALIZABLE;
> This then allows a new style of TRUNCATE, yet without modiying
> behaviour of earlier programs (ugh!).

Personally I think the behavior should be dictated by the *reader*.
The one doing the truncation may not know about the consistency
requirements of particular readers. Especially when you do the
truncate via pg_restore or some other generic tool. And indeed
different readers may have different consistency requirements.

So I'd prefer if it were a GUC variable; readers that accept relaxed
consistency can set truncate_conflict=off

Granted, making this part of the TRUNCATE statement does give you
table-level granularity. But if a reader can already handle
serialization conflicts, it doesn't really matter which table they
came from.

But making TRUNCATE behave in a MVCC-safe way, like proposed by Hannu,
would be much better.

Regards,
Marti

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2012-11-09 13:22:17 Re: TRUNCATE SERIALIZABLE and frozen COPY
Previous Message Hannu Krosing 2012-11-09 10:24:54 Re: TRUNCATE SERIALIZABLE and frozen COPY