Re: Yet another "drop table vs delete" question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christophe <xof(at)thebuild(dot)com>
Cc: PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Yet another "drop table vs delete" question
Date: 2009-04-21 20:20:31
Message-ID: 11492.1240345231@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Christophe <xof(at)thebuild(dot)com> writes:
> On Apr 21, 2009, at 12:28 PM, Peter Eisentraut wrote:
>> Yes, but if you are asking that question, you probably really want
>> to use TRUNCATE.

> The advantage of DROP TABLE being, of course, that DROP TABLE is
> transactionally-safe, while TRUNCATE is not.

The above is complete nonsense. They're both going to drop data that
might conceivably be visible in the snapshot of some concurrent
transaction that hasn't yet touched the table (else it would have lock)
but might wish to do so later.

If you use DELETE, you'll be transactionally safe, but the cost is
concomitantly a lot higher than either DROP or TRUNCATE.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Crawford 2009-04-21 20:26:15 Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff'
Previous Message Chris Browne 2009-04-21 20:13:39 Re: Yet another "drop table vs delete" question