Re: Postgres do not support tinyint?

From: shammat(at)gmx(dot)net
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Postgres do not support tinyint?
Date: 2025-01-10 10:44:29
Message-ID: b6a65a6c-76af-4ab3-a9ee-5ba0019da9ca@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Dominique Devienne schrieb am 10.01.2025 um 10:41:
> On Fri, Jan 10, 2025 at 10:13 AM Vladlen Popolitov
> <v(dot)popolitov(at)postgrespro(dot)ru> wrote:
>> If you really need 1-byte integer, you can use "char" type. Cast it
>> to/from int. See comment at the end of the page
>> https://www.postgresql.org/docs/17/datatype-character.html
>
> Hi. What would be the best online doc to learn about the physical
> storage / format for rows/pages/btree, etc... To understand alignment,
> packing, varint or not, all those things. I'm quite familiar with the
> [SQLite format][1], having read that doc dozens of times, and I'd like
> a better low-level understanding for PostgreSQL as well. TIA, --DD

The alignment requirement of each type is available in pg_type

https://www.postgresql.org/docs/current/catalog-pg-type.html

The physical layout on disk is described here:

https://www.postgresql.org/docs/current/storage.html

And the "Postgres intenrals" site might be helpful as well:

https://www.interdb.jp/pg/pgsql01.html

There are various (blog) posts on how to optimize space considering alignment

* https://stackoverflow.com/a/7431468
* https://www.enterprisedb.com/blog/rocks-and-sand

The "postgres_dba" toolset has a little SQL script to evaluate the space savings:

https://github.com/NikolayS/postgres_dba/blob/master/sql/p1_alignment_padding.sql

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Verite 2025-01-10 12:49:40 Re: Display Bytea field
Previous Message Dominique Devienne 2025-01-10 09:41:12 Re: Postgres do not support tinyint?