Re: CLUSTER vs. VACUUM FULL

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: CLUSTER vs. VACUUM FULL
Date: 2024-04-22 15:51:38
Message-ID: 824158e3-58ac-42ec-b77e-60d19564284a@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 4/22/24 08:37, Ron Johnson wrote:
> On Mon, Apr 22, 2024 at 10:25 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us
> <mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>> wrote:
>
> Marcos Pegoraro <marcos(at)f10(dot)com(dot)br <mailto:marcos(at)f10(dot)com(dot)br>> writes:
> > But wouldn't it be good that VACUUM FULL uses that index defined by
> > Cluster, if it exists ?
>
> No ... what would be the difference then?
>
> What the VACUUM docs "should" do, it seems, is suggest CLUSTER on the
> PK, if the PK is a sequence (whether that be an actual sequence, or a
> timestamp or something else that grows monotonically).

Why?

That would, per David Rowley's comments, impose a sort cost on top of
the cost of hitting every heap page and rewriting it. You end up with
sorted table granted, until such time as you start making changes to it.
If you are to the point of running VACUUM FULL that indicates to me the
table has seen a heavy load of changes that you want to clean out. Given
the temporary nature of the effects of a CLUSTER under a change load I
don't see why it would be the way to go to clean up a changing table.

>
> That's because the data is already roughly in PK order.
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Celia McInnis 2024-04-22 16:05:39 adding a generated column to a table?
Previous Message Ron Johnson 2024-04-22 15:37:33 Re: CLUSTER vs. VACUUM FULL