X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 104A5D1B449 for ; Wed, 10 Dec 2003 19:55:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 11628-03 for ; Wed, 10 Dec 2003 15:54:30 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 1B03DD1B4D4 for ; Wed, 10 Dec 2003 15:54:29 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBAJsE19008001; Wed, 10 Dec 2003 14:54:14 -0500 (EST) To: Josh Berkus Cc: Hartmut Raschick , pgsql-performance@postgresql.org Subject: Re: TRUNCATE veeeery slow compared to DELETE in 7.4 In-reply-to: <200312100918.02501.josh@agliodbs.com> References: <3FD484B6.EF39A92F@ke-elektronik.de> <200312100918.02501.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 10 Dec 2003 09:18:02 -0800" Date: Wed, 10 Dec 2003 14:54:14 -0500 Message-ID: <8000.1071086054@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/171 X-Sequence-Number: 5031 Josh Berkus 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