Re: Effects of dropping a large table - Mailing list pgsql-general

From Peter J. Holzer
Subject Re: Effects of dropping a large table
Date
Msg-id 20230723102733.shfvgs6dsev2l6xa@hjp.at
Whole thread Raw
In response to Re: Effects of dropping a large table  (Gus Spier <gus.spier@gmail.com>)
Responses Re: Effects of dropping a large table  (Ron <ronljohnsonjr@gmail.com>)
List pgsql-general
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!"

Attachment

pgsql-general by date:

Previous
From: Gus Spier
Date:
Subject: Re: Effects of dropping a large table
Next
From: Ron
Date:
Subject: Re: Effects of dropping a large table