Re: Data TYPE Creation - Mailing list pgsql-general

From Tom Lane
Subject Re: Data TYPE Creation
Date
Msg-id 6028.1047912125@sss.pgh.pa.us
Whole thread Raw
In response to Re: Data TYPE Creation  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-general
Bruno Wolff III <bruno@wolff.to> writes:
>   Houssay Guillaume <ghoussay@noos.fr> wrote:
>> What about the disk space ? By defining an INT2 with a constraint of 1 byte, how much space will be used in the
memory(1 byte or 2 bytes). This is really one of my concern. 

> The extra disc space won't be that much because there is other information
> being stored besides that raw data. So that int2 won't take up twice as much
> space as int1 (note postgres doesn't have that type).

If the OP is desperate to feel that he's saving space, there's always
the "char" type (note the quotes) --- it's got an impoverished set of
operations and the I/O format is maybe not quite what's wanted, but it
does store as a single byte.

But Bruno is correct to point out that actual space savings is another
question.  Unless you have quite a few such columns appearing
consecutively in a table, it's not worth worrying about, because in any
context except adjacent "char" columns, the space will disappear into
alignment padding for the next field anyway.

            regards, tom lane

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Data TYPE Creation
Next
From: Dmitry Tkach
Date:
Subject: Re: newbie question