pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Demitri Muna <postgresql@demitri.com>
To: pgsql-general@lists.postgresql.org
Subject: CLUSTER, VACUUM, and TABLESPACEs (oh my)
Date: Sun, 24 Jan 2021 19:38:08 -0500
Message-ID: <959B953F-6882-4ED1-A560-4B0335C39CFD@demitri.com> (raw)

Hi,

I would like to request a little clarification on the CLUSTER and VACUUM commands. My use case here (partially) is when my disk runs out of space and I want to move a table to a newly created tablespace. These questions somewhat overlap. Let’s say I am starting with a table that is not CLUSTERed on a given index, but I want it to be.

* If I run “CLUSTER table USING idx” on a table, is VACUUM FULL required/useful afterwards, or should I assume that the cluster operation did the equivalent of a VACUUM FULL?

* If I have previously run a CLUSTER command on a table, will future VACUUM FULL commands rewrite the table in the order specified in the previous CLUSTER?

* If I want to move a table to a new tablespace, is it possible to CLUSTER+VACUUM in the same step since the whole table will be rewritten anyway? This would be very useful in low-disk space scenarios. I did find this answer, but it’s dated several years ago and was hoping for something better supported. https://dba.stackexchange.com/a/87457/121020

The documentation is somewhat silent on these details, so I thought I’d ask here. Right now I move a table to a new tablespace, cluster on an index, and then do a full vacuum which results in three full copies of the table being written, which seems less than optimal where one should only be needed as far as I understand things.

Cheers,
Demitri




view thread (6+ messages)  latest in thread

Message-ID: <959B953F-6882-4ED1-A560-4B0335C39CFD@demitri.com>
Permalink:  ../959B953F-6882-4ED1-A560-4B0335C39CFD@demitri.com/
Also on:    postgresql.org/message-id/959B953F-6882-4ED1-A560-4B0335C39CFD@demitri.com

 · 

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: postgresql@demitri.com
  Subject: Re: CLUSTER, VACUUM, and TABLESPACEs (oh my)
  In-Reply-To: <959B953F-6882-4ED1-A560-4B0335C39CFD@demitri.com>
  References: <959B953F-6882-4ED1-A560-4B0335C39CFD@demitri.com>

* 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