Re: DELETE vs TRUNCATE explanation

From: Matthew Woodcraft <matthew(at)woodcraft(dot)me(dot)uk>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: DELETE vs TRUNCATE explanation
Date: 2012-07-11 18:10:37
Message-ID: 20120711181037.GF11608@golux.woodcraft.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

Tom Lane wrote:
> (3) The performance of the truncation itself should not be viewed in
> isolation; subsequent behavior also needs to be considered. An example
> of possible degradation is that index bloat would no longer be
> guaranteed to be cleaned up over a series of repeated truncations.
> (You might argue that if the table is small then the indexes couldn't
> be very bloated, but I don't think that holds up over a long series.)
>
> IOW, I think it's fine as-is. I'd certainly wish to see many more
> than one complainant before we expend effort in this area.

I think a documentation change would be worthwhile.

At the moment the TRUNCATE page says, with no caveats, that it is faster than
unqualified DELETE.

It surprised me to find that this wasn't true (with 7.2, again with small
tables in a testsuite), and evidently it's still surprising people today.

-M-

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2012-07-11 18:13:58 Re: Synchronous Standalone Master Redoux
Previous Message Tom Lane 2012-07-11 18:06:55 Re: Support for array_remove and array_replace functions

Browse pgsql-performance by date

  From Date Subject
Next Message Craig James 2012-07-11 20:18:32 Re: DELETE vs TRUNCATE explanation
Previous Message Midge Brown 2012-07-11 17:25:26 Re: moving tables