Re: DELETE vs TRUNCATE explanation

From: Shaun Thomas <sthomas(at)optionshouse(dot)com>
To: Craig James <cjames(at)emolecules(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Daniel Farina <daniel(at)heroku(dot)com>, Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: DELETE vs TRUNCATE explanation
Date: 2012-07-11 20:47:21
Message-ID: 4FFDE659.7040104@optionshouse.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

On 07/11/2012 03:18 PM, Craig James wrote:

> It strikes me as a contrived case rather than a use case. What sort of
> app repeatedly fills and truncates a small table thousands of times ...
> other than a test app to see whether you can do it or not?

Test systems. Any company with even a medium-size QA environment will
have continuous integration systems that run unit tests on a trash
database hundreds or thousands of times through the day. Aside from
dropping/creating the database via template, which would be *really*
slow, truncate is the easiest/fastest way to reset between tests.

If TRUNCATE suddenly started defaulting to DELETE on small table-sets
and several iterations led to exponential index growth, that would be
rather unfortunate.

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604
312-444-8534
sthomas(at)optionshouse(dot)com

______________________________________________

See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2012-07-11 20:52:29 Re: [PATCH] lock_timeout and common SIGALRM framework
Previous Message Peter Eisentraut 2012-07-11 20:44:40 Re: has_language_privilege returns incorrect answer for non-superuser

Browse pgsql-performance by date

  From Date Subject
Next Message Andrew Dunstan 2012-07-11 21:04:39 Re: DELETE vs TRUNCATE explanation
Previous Message Craig James 2012-07-11 20:18:32 Re: DELETE vs TRUNCATE explanation