From: | Daniel Farina <daniel(at)heroku(dot)com> |
---|---|
To: | Craig Ringer <ringerc(at)ringerc(dot)id(dot)au> |
Cc: | "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: DELETE vs TRUNCATE explanation |
Date: | 2012-07-11 05:22:27 |
Message-ID: | CAAZKuFZ9tYeC1K5ZayZgztm3re_7ytbsEYFa0wwXirB6Hfm+EQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-performance |
On Tue, Jul 10, 2012 at 5:37 PM, Craig Ringer <ringerc(at)ringerc(dot)id(dot)au> wrote:
> Hi
>
> After seeing a few discussions here and on Stack Overflow I've put together
> a quick explanation of why "DELETE FROM table;" may be faster than "TRUNCATE
> table" for people doing unit testing on lots of tiny tables, people who're
> doing this so often they care how long it takes.
>
> I'd love it if a few folks who know the guts were to take a look and verify
> its correctness:
I haven't said this before, but think it every time someone asks me
about this, so I'll say it now:
This is a papercut that should be solved with improved mechanics.
TRUNCATE should simply be very nearly the fastest way to remove data
from a table while retaining its type information, and if that means
doing DELETE without triggers when the table is small, then it should.
The only person who could thwart me is someone who badly wants their
128K table to be exactly 8 or 0K, which seems unlikely given the 5MB
of catalog anyway.
Does that sound reasonable? As in, would anyone object if TRUNCATE
learned this behavior?
--
fdr
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuo Ishii | 2012-07-11 05:23:26 | Re: Patch: add conversion from pg_wchar to multibyte |
Previous Message | Tom Lane | 2012-07-11 05:07:11 | Re: Patch: add conversion from pg_wchar to multibyte |
From | Date | Subject | |
---|---|---|---|
Next Message | Yan Chunlu | 2012-07-11 06:24:24 | Re: how could select id=xx so slow? |
Previous Message | Craig Ringer | 2012-07-11 00:37:24 | DELETE vs TRUNCATE explanation |