Re: How much size saved by updating column to NULL ?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Sébastien TANIERE <seb(dot)taniere(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How much size saved by updating column to NULL ?
Date: 2024-01-12 13:58:48
Message-ID: CAKFQuwYq2YF7dX0CvkoGJQze76J2hZx5Zima47AxabpiO+GQig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday, January 12, 2024, Sébastien TANIERE <seb(dot)taniere(at)gmail(dot)com>
wrote:

> Hello,
> in my company, some columns rarely used in a PG database 14.8 have been
> set to NULL in order to save disk space (datecreation & acteurcreation in
> following table) .
>
> create table example
> (
> id varchar(25) not null,
> datecreation timestamp(6),
> acteurcreation varchar(50),
> valeurunit smallint
> )
>
> I am wondering if it is really useful for every type of column.
> Intuitively, i would say that it does not save space for fixed field
> datecreation as it is a fixed size column.
>
> Do we save 8 bytes by timestamp column updated to NULL or not ?
>
>
You probably should just measure it yourself. But yes, the representation
of null in a tuple is the absence of data and a bit in the nulls bitmap.
So there is overhead but also savings. The net effect is case specific.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kiran K V 2024-01-12 15:23:06 Issue with loading unicode characters with copy command
Previous Message Jeremiah Bauer 2024-01-12 12:34:37 Re: [EXTERNAL]Re: Refresh Materialized View Issue