Re: Postgres do not support tinyint?
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Ron Johnson <ronljohnsonjr@gmail.com>,
"pgsql-generallists.postgresql.org"
<pgsql-general@lists.postgresql.org>
Date: 2025-01-08T06:53:34Z
Lists: 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