Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 04FD29FBE03 for ; Wed, 11 Jul 2007 19:16:01 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 78754-03 for ; Wed, 11 Jul 2007 19:15:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from oxford.xeocode.com (unknown [87.127.95.196]) by postgresql.org (Postfix) with ESMTP id F2AAF9FBE70 for ; Wed, 11 Jul 2007 19:15:57 -0300 (ADT) Received: from localhost.enta.net ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.67) (envelope-from ) id 1I8kTR-0001Hl-0P; Wed, 11 Jul 2007 23:15:53 +0100 From: Gregory Stark To: "Adriaan van Os" Cc: Subject: Re: TRUNCATE TABLE In-Reply-To: <46953949.3030201@microbizz.nl> (Adriaan van Os's message of "Wed, 11 Jul 2007 22:10:49 +0200") Organization: EnterpriseDB References: <46953949.3030201@microbizz.nl> X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.performance" 1510) Date: Wed, 11 Jul 2007 23:15:52 +0100 Message-ID: <87ps2ypox3.fsf@oxford.xeocode.com> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/127 X-Sequence-Number: 25811 "Adriaan van Os" writes: > Recently, I have been doing extensive profiling of a version 8.1.4 Postgres DB > with about 175 tables and 5 GB of data (the server running on Fedora Linux and > the clients on Windows XP). Surprisingly, one of the bottlenecks is TRUNCATE > TABLE and that command is really slow as compared to other operations. For > example, we have operations like: What filesystem is this? Some filesystems are notoriously slow at deleting large files. The mythtv folk who face this problem regularly recommend either JFS or XFS for this purpose. Postgres generally doesn't really need to be able to delete large files quickly. The only times files are deleted which come to mind are when you DROP or TRUNCATE or possibly when you VACUUM a table. > I noticed, by the way, that removing records in general is painfully slow, but > I didn't do a detailed analysis of that issue yet. That's strange. Deleting should be the *quickest* operation in Postgres. Do you perchance have foreign key references referencing this table? Do you have any triggers? -- Gregory Stark EnterpriseDB http://www.enterprisedb.com