pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Effects of dropping a large table
Date: Sun, 23 Jul 2023 12:27:33 +0200
Message-ID: <20230723102733.shfvgs6dsev2l6xa@hjp.at> (raw)
In-Reply-To: <CAG8xnidWNPmc4e1W13dzm9ByR3HDEekn8Jv39vhMNSBmx8YJmw@mail.gmail.com>
References: <c9fea9c6-807c-474f-d698-968d3ac2a901@gmail.com>
	<430335C4-3803-4F88-9042-96BA65166043@gmail.com>
	<20230723095138.vrlw4jlbafy6iktn@hjp.at>
	<CAG8xnidWNPmc4e1W13dzm9ByR3HDEekn8Jv39vhMNSBmx8YJmw@mail.gmail.com>

On 2023-07-23 06:09:03 -0400, Gus Spier wrote:
> Ah! Truncating a table does not entail all of WAL processes. From the
> documentation, "TRUNCATE quickly removes all rows from a set of tables. It has
> the same effect as an unqualified DELETE on each table, but since it does not
> actually scan the tables it is faster. Furthermore, it reclaims disk space
> immediately, rather than requiring a subsequent VACUUM operation. This is most
> useful on large tables." https://www.postgresql.org/docs/14/sql-truncate.html

I assumed that by "deleting the now empty table" you meant DROPing it.
(Performing a «DELETE FROM t» just after a «TRUNCATE t» would obviously
be pointless).

So let me rephrase the question:

What's the advantage of 

    TRUNCATE t
    DROP t

over just

    DROP t

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (10+ messages)  latest in thread

Message-ID: <20230723102733.shfvgs6dsev2l6xa@hjp.at>
Permalink:  ../20230723102733.shfvgs6dsev2l6xa@hjp.at/
Also on:    postgresql.org/message-id/20230723102733.shfvgs6dsev2l6xa@hjp.at

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: Effects of dropping a large table
  In-Reply-To: <20230723102733.shfvgs6dsev2l6xa@hjp.at>
  References: <c9fea9c6-807c-474f-d698-968d3ac2a901@gmail.com> <430335C4-3803-4F88-9042-96BA65166043@gmail.com> <20230723095138.vrlw4jlbafy6iktn@hjp.at> <CAG8xnidWNPmc4e1W13dzm9ByR3HDEekn8Jv39vhMNSBmx8YJmw@mail.gmail.com> <20230723102733.shfvgs6dsev2l6xa@hjp.at>

* 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