pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Berkus <josh@agliodbs.com>
Cc: Hartmut Raschick <hartmut.raschick@ke-elektronik.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: TRUNCATE veeeery slow compared to DELETE in 7.4
Date: Wed, 10 Dec 2003 14:54:14 -0500
Message-ID: <8000.1071086054@sss.pgh.pa.us> (raw)
In-Reply-To: <200312100918.02501.josh@agliodbs.com>
References: <3FD484B6.EF39A92F@ke-elektronik.de>
	<200312100918.02501.josh@agliodbs.com>

Josh Berkus <josh@agliodbs.com> writes:
> Incidentally, I believe that TRUNCATE has always been slightly slower than 
> DROP TABLE.

Well, it would be: it has to delete the original files and then create
new ones.  I imagine the time to create new, empty indexes is the bulk
of the time Hartmut is measuring.  (Remember that an "empty" index has
at least one page in it, the metadata page, for all of our index types,
so there is some actual I/O involved to do this.)

It does not bother me that TRUNCATE takes nonzero time; it's intended
to be used in situations where DELETE would take huge amounts of time
(especially after you factor in the subsequent VACUUM activity).
The fact that DELETE takes near-zero time on a zero-length table is
not very relevant.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <8000.1071086054@sss.pgh.pa.us>
Permalink:  ../8000.1071086054@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8000.1071086054@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, hartmut.raschick@ke-elektronik.de
  Subject: Re: TRUNCATE veeeery slow compared to DELETE in 7.4
  In-Reply-To: <8000.1071086054@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox