Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tnngN-002Bnt-SP for pgsql-admin@arkaria.postgresql.org; Thu, 27 Feb 2025 23:52:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tnngO-008XsC-ID for pgsql-admin@arkaria.postgresql.org; Thu, 27 Feb 2025 23:52:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tnngO-008XnA-4M for pgsql-admin@lists.postgresql.org; Thu, 27 Feb 2025 23:52:46 +0000 Received: from mail-ay.bbox.fr ([194.158.98.9]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tnngJ-0004aV-0Y for pgsql-admin@lists.postgresql.org; Thu, 27 Feb 2025 23:52:46 +0000 Received: from mail.jpp.fr (unknown [176.187.84.182]) by mail-ay.bbox.fr (Postfix) with ESMTP id 723A23D; Fri, 28 Feb 2025 00:51:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mail-ay.bbox.fr 723A23D Received: from localhost (localhost [127.0.0.1]) by mail.jpp.fr (Postfix) with ESMTP id 61F02C006C; Fri, 28 Feb 2025 00:51:42 +0100 (CET) Received: from mail.jpp.fr ([127.0.0.1]) by localhost (mail.jpp.fr [127.0.0.1]) (amavis, port 10032) with ESMTP id Pe8OMm5GLzlP; Fri, 28 Feb 2025 00:51:42 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.jpp.fr (Postfix) with ESMTP id 3764DC006D; Fri, 28 Feb 2025 00:51:42 +0100 (CET) X-Amavis-Modified: Mail body modified (using disclaimer) - mail.jpp.fr X-Virus-Scanned: amavis at jpp.fr Received: from mail.jpp.fr ([127.0.0.1]) by localhost (mail.jpp.fr [127.0.0.1]) (amavis, port 10026) with ESMTP id Azdyh7kcbxrZ; Fri, 28 Feb 2025 00:51:42 +0100 (CET) Received: from mail.jpp.fr (localhost [127.0.0.1]) by mail.jpp.fr (Postfix) with ESMTP id 06610C006C; Fri, 28 Feb 2025 00:51:42 +0100 (CET) Date: Fri, 28 Feb 2025 00:51:41 +0100 (CET) From: Jean-Paul POZZI To: Ron Johnson Cc: Pgsql-admin Message-ID: <1030640143.483.1740700301871.JavaMail.zextras@jpp.fr> In-Reply-To: References: Subject: RE: delete and pg_toast = shrink database? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_c22ee23f-d246-4e4c-a786-ec688ac09575" X-Originating-IP: [192.168.2.8] X-Mailer: Carbonio 24.12.4_ZEXTRAS_202501 (CarbonioWebClient - Firefox 134.0 (Linux)/24.12.4_ZEXTRAS_202501 carbonio 20250123-1547 FOSS) Thread-Topic: delete and pg_toast = shrink database? Thread-Index: zSofcoXrtLYXLrJ/cis2AJWT7nzVEA== X-VADE-SPAMSTATE: clean X-VADE-SPAMSCORE: 0 X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekkeekhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceuqfgfjgfifgfgufdpucfqfgfvpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefkjghfufggtghiofhtsegrtdgtreertdejnecuhfhrohhmpeflvggrnhdqrfgruhhlucfrqfgkkgfkuceojhhprdhpohiiiihisehiiiiiohhprdhnvghtqeenucggtffrrghtthgvrhhnpeetgeetteeuuefhjeffieevieeiffefuefhtefhtdehheekueejgfelvdefffelveenucfkphepudejiedrudekjedrkeegrddukedvpdduledvrdduieekrddvrdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudejiedrudekjedrkeegrddukedvpdhhvghlohepmhgrihhlrdhjphhprdhfrhdpmhgrihhlfhhrohhmpehjphdrphhoiiiiihesihiiiihophdrnhgvthdpnhgspghrtghpthhtohepvddprhgtphhtthhopehrohhnlhhjohhhnhhsohhnjhhrsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqrggumhhinheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_c22ee23f-d246-4e4c-a786-ec688ac09575 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, As a precaution, save the data to be purged so that you can possibly use it= in the future. Regards JP P De: "Ron Johnson" =C3=80: "Pgsql-admin" Envoy=C3=A9: vendredi 28 f=C3=A9vrier 2025 00:39 Objet: Re: delete and pg_toast =3D shrink database? On Thu, Feb 27, 2025 at 4:19=E2=80=AFPM Edwin UY wrote= : Hi, DB is currently 500G. About 75% of this is pg_toast. Had advised the application team to check for data purging as there are som= e very old data. I've been in that same situation.=C2=A0 Had to write the purge job myself..= . Is it correct to assume that doing so should shrink the database size? No. DELETE=C2=A0+ VACUUM=C2=A0frees space in the data files.=C2=A0 (This is= good once you get a regular purge process running, since the post-purge va= cuum will free up space for the next records.=C2=A0 The tables' free space = percentages will then hover between relatively high and low ranges, unless = insert volume is growing.) I believe I have to run vacuum full/table at some stage to really shrink it= ? Also, no.=C2=A0 But then yes. VACUUM FULL (use pg_repack instead!) 1.=C2=A0copies=C2=A0the remaining data to a new (temporary) table and rebui= lds the indices, 2. deletes the old files, 3. renames the temporary table to the original name. Thus, you'll temporarily need=C2=A0more=C2=A0disk space. -- Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --=_c22ee23f-d246-4e4c-a786-ec688ac09575 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

Hello,

 

As a precaution, save the data to be purged so that you can p= ossibly use it in the future.

 

 

Regards

 
JP P




De: "Ron Johnson" <ronljohnsonjr@= gmail.com>
=C3=80: "Pgsql-admin" <pgsql-admin@li= sts.postgresql.org>
Envoy=C3=A9: vendredi 28 f=C3= =A9vrier 2025 00:39
Objet: Re: delete and pg_toast =3D= shrink database?

On Thu, Feb 27, 2025 at 4:19=E2=80=AFPM Edwin UY <edwin.uy@gmail.com> wrote:
Hi,
 
DB is currently 500G. About 75= % of this is pg_toast.
Had advised the application te= am to check for data purging as there are some very old data.
 
I've been in that same situation.  Had to write the purge job mys= elf...
 
Is it correct to assume that d= oing so should shrink the database size?
 
No. DELETE + VACUUM frees space in the data files.  (Th= is is good once you get a regular purge process running, since the post-pur= ge vacuum will free up space for the next records.  The tables' free s= pace percentages will then hover between relatively high and low ranges, un= less insert volume is growing.)
 
I believe I have to run vacuum= full/table at some stage to really shrink it?
 
Also, no.  But then yes.
 
VACUUM FULL (use pg_repack instead!)
1. copies the remaining data to a new (temp= orary) table and rebuilds the indices,
2. deletes the old files,
3. renames the temporary table to the original name.
 
Thus, you'll temporarily need more disk spa= ce.
 
--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!
--=_c22ee23f-d246-4e4c-a786-ec688ac09575--