Re: DELETE vs TRUNCATE explanation

Поиск
Список
Период
Сортировка
От Daniel Farina
Тема Re: DELETE vs TRUNCATE explanation
Дата
Msg-id CAAZKuFZ9tYeC1K5ZayZgztm3re_7ytbsEYFa0wwXirB6Hfm+EQ@mail.gmail.com
обсуждение исходный текст
Ответ на DELETE vs TRUNCATE explanation  (Craig Ringer <ringerc@ringerc.id.au>)
Ответы Re: DELETE vs TRUNCATE explanation  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: DELETE vs TRUNCATE explanation  (Craig Ringer <ringerc@ringerc.id.au>)
Список pgsql-performance
On Tue, Jul 10, 2012 at 5:37 PM, Craig Ringer <ringerc@ringerc.id.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

В списке pgsql-performance по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: DELETE vs TRUNCATE explanation
Следующее
От: Yan Chunlu
Дата:
Сообщение: Re: how could select id=xx so slow?