Re: TOAST Table / Dead Tuples / Free Pages

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Kashif Zeeshan <kashi(dot)zeeshan(at)gmail(dot)com>, "Shenavai, Manuel" <manuel(dot)shenavai(at)sap(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: TOAST Table / Dead Tuples / Free Pages
Date: 2024-06-13 14:38:01
Message-ID: 28102d69-6305-4014-a572-8a29f5a19710@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6/13/24 01:08, Kashif Zeeshan wrote:
> Hi
>
> You can use the CLUSTER command, which will physically reorder the table
> based on index, effectively reducing the size of the table without using
> VACUUM.

From OP:

"I don’t want to use VACUUM FULL due to the exclusive lock."

From here

https://www.postgresql.org/docs/current/sql-cluster.html

"When a table is being clustered, an ACCESS EXCLUSIVE lock is acquired
on it. This prevents any other database operations (both reads and
writes) from operating on the table until the CLUSTER is finished."

>
> CLUSTER your_table USING your_index;
>
> Or you can use the pg_repack extension as well.
>
> pg_repack -d your_database -t your_table
>
> Regards
> Kashif Zeeshan
>
>
>
> On Thu, Jun 13, 2024 at 12:55 PM Shenavai, Manuel
> <manuel(dot)shenavai(at)sap(dot)com <mailto:manuel(dot)shenavai(at)sap(dot)com>> wrote:
>
> Hi everyone,____
>
> __ __
>
> I created a simple scenario to understand the handling of TOASTs
> <https://www.postgresql.org/docs/current/storage-toast.html>: There
> is an empty database with a single table and record. The single
> record gets updated multiple times with 10MB (bytea column). I can
> see that the table/toasttable size is growing (500MB).____
>
> __ __
>
> Now I tried to find a way to get the DB size down again (it should
> be around 10MB instead of 500MB). I don’t want to use VACUUM FULL
> due to the exclusive lock.____
>
> __ __
>
> Is there any way to remove the dead tuples and free the pages?____
>
> __ __
>
> Thanks in advance &____
>
> Best regards,____
>
> Manuel____
>
> __ __
>

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2024-06-13 14:41:59 Re: Oracle Linux 9 Detected RPMs with RSA/SHA1 signature
Previous Message David G. Johnston 2024-06-13 14:25:25 Re: Syntax on BEFORE Trigger - Cascade?