Re: Postgres do not support tinyint? - Mailing list pgsql-general

From Tom Lane
Subject Re: Postgres do not support tinyint?
Date
Msg-id 1590896.1736319214@sss.pgh.pa.us
Whole thread Raw
In response to Re: Postgres do not support tinyint?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tuesday, January 7, 2025, Ron Johnson <ronljohnsonjr@gmail.com> wrote:
>> 3. The "bit" type might serve your needs.

> You suggest a type with a minimum size of 6 bytes when the complaint is
> that the otherwise acceptable 2 byte data type is too large?

I think the point here is that there's zero value in trying to pack a
small integer value into 1 byte (let alone 4 bits) if it's all by
its lonesome in the row.  Alignment padding will eat whatever gain
you thought you had.  If you want a win, you need to store a lot of
such values in one field.  Ron's suggesting that you pack them into
bit arrays and manually insert/extract individual values.  That could
be worth doing if you were sufficiently desperate, but you'd have to
value compact storage over access simplicity quite a lot.

Perhaps a "char"[] array (note the quotes) would provide an
intermediate level of compactness versus pain.

            regards, tom lane



pgsql-general by date:

Previous
From: Christophe Pettus
Date:
Subject: Re: Postgres do not support tinyint?
Next
From: shammat@gmx.net
Date:
Subject: Postgres 17 domains with NOT NULL and pg_get_constraintdef()