From: Tom Lane <tgl@sss.pgh.pa.us>
To: Hartmut Raschick <hartmut.raschick@ke-elektronik.de>
Cc: pgsql-performance@postgresql.org, Rod Taylor <pg@rbt.ca>
Subject: Re: TRUNCATE veeeery slow compared to DELETE in 7.4
Date: Mon, 15 Dec 2003 13:21:47 -0500
Message-ID: <13898.1071512507@sss.pgh.pa.us> (raw)
In-Reply-To: <3FD99CDA.8161D80A@ke-elektronik.de>
References: <3FD484B6.EF39A92F@ke-elektronik.de>
<200312100918.02501.josh@agliodbs.com>
<8000.1071086054@sss.pgh.pa.us>
<3FD99CDA.8161D80A@ke-elektronik.de>
Hartmut Raschick <hartmut.raschick@ke-elektronik.de> writes:
> [ TRUNCATE is much slower in 7.4 than in 7.3 ]
After looking into this, I think this is because when Rod Taylor
reimplemented TRUNCATE to make it transaction-safe, he essentially
turned it into a variant of CLUSTER. It is slow because it is creating
and deleting dummy tables and indexes. I think this is not really
necessary and it could be done better while still being
transaction-safe. All we really need is to create a new empty table
file, update the table's pg_class row with the new relfilenode, mark
the old file for deletion, and then run REINDEX TABLE (which will
perform similar shenanigans with the indexes).
regards, tom lane
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, hartmut.raschick@ke-elektronik.de, pg@rbt.ca
Subject: Re: TRUNCATE veeeery slow compared to DELETE in 7.4
In-Reply-To: <13898.1071512507@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