Re: BIG files - Mailing list pgsql-novice

From Tom Lane
Subject Re: BIG files
Date
Msg-id 6806.1119278206@sss.pgh.pa.us
Whole thread Raw
In response to BIG files  (rabt@dim.uchile.cl)
List pgsql-novice
rabt@dim.uchile.cl writes:
> Tom, this is my table definition including domains:

The problem appears to be that you have defined all the columns as NOT
NULL with defaults that are obviously NULL substitutes, eg

> CREATE DOMAIN f29.tipo_idcomuna
>   AS int4
>   DEFAULT 99999
>   NOT NULL
>    CONSTRAINT tipo_idcomuna_check CHECK ((VALUE <= 99999) AND (VALUE >= 0));

That means that every one of the 99 columns is actually present, with a
value, in every row.  According to VACUUM FULL VERBOSE the actual
on-disk widths of your three sample rows range from 816 to 828 bytes,
which works out to an average column width of 8 or so bytes, which seems
reasonable.

Had you allowed the missing columns to go to NULL there would only be a
dozen or so actual values stored in each of these sample rows, so
(allowing for an extra 12 bytes for the nulls bitmap) the stored width
ought to be in the vicinity of 140-150 bytes.  Which more than accounts
for the bloat you are seeing.

In short: use NULL the way it was intended to be used, that is, to
indicate missing values.

            regards, tom lane

pgsql-novice by date:

Previous
From: sara simoes
Date:
Subject: Data Migration from Access to Postgresql
Next
From: "Mace, Richard"
Date:
Subject: