Re: Observation with Postgres table size

From: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
To: Sabyasachi Mukherjee <mukherjee(dot)sabyasachi(at)outlook(dot)com>
Cc: "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Observation with Postgres table size
Date: 2024-05-10 14:00:51
Message-ID: A261A0D0-9868-4096-8F64-C966C8DB129C@elevated-dev.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

> On May 10, 2024, at 7:57 AM, Sabyasachi Mukherjee <mukherjee(dot)sabyasachi(at)outlook(dot)com> wrote:
>
> Can any body please advise, how to reduce the size of the table?

VACUUM FULL

Read the docs to understand what it does. Deleting a row does not shrink the table.

Think about it, what happens when you delete a row that's first in the file on disk? Do you expect the rest of the table to be rewritten? Do you expect the file to be rewritten every time a row is deleted? On commit of any transaction that included a delete?

Postgres will eventually reuse the space left behind by deleted rows (read the docs for VACUUM), so under most use cases this is not a problem.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Laurenz Albe 2024-05-10 14:01:03 Re: Observation with Postgres table size
Previous Message Sabyasachi Mukherjee 2024-05-10 13:57:23 Observation with Postgres table size