public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Postgres do not support tinyint?
3+ messages / 3 participants
[nested] [flat]

* Re: Postgres do not support tinyint?
@ 2025-01-10 09:41  Dominique Devienne <[email protected]>
  0 siblings, 2 replies; 3+ messages in thread

From: Dominique Devienne @ 2025-01-10 09:41 UTC (permalink / raw)
  To: Vladlen Popolitov <[email protected]>; +Cc: Igor Korot <[email protected]>; Christophe Pettus <[email protected]>; David G. Johnston <[email protected]>; Ron Johnson <[email protected]>; pgsql-generallists.postgresql.org <[email protected]>

On Fri, Jan 10, 2025 at 10:13 AM Vladlen Popolitov
<[email protected]> 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

[1]: https://www.sqlite.org/fileformat.html






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Postgres do not support tinyint?
@ 2025-01-10 10:44  [email protected]
  parent: Dominique Devienne <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: [email protected] @ 2025-01-10 10:44 UTC (permalink / raw)
  To: [email protected]


Dominique Devienne schrieb am 10.01.2025 um 10:41:
> On Fri, Jan 10, 2025 at 10:13 AM Vladlen Popolitov
> <[email protected]> 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








^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Postgres do not support tinyint?
@ 2025-01-10 15:04  Vladlen Popolitov <[email protected]>
  parent: Dominique Devienne <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: Vladlen Popolitov @ 2025-01-10 15:04 UTC (permalink / raw)
  To: Dominique Devienne <[email protected]>; +Cc: Igor Korot <[email protected]>; Christophe Pettus <[email protected]>; David G. Johnston <[email protected]>; Ron Johnson <[email protected]>; pgsql-generallists.postgresql.org <[email protected]>

Dominique Devienne писал(а) 2025-01-10 16:41:
> On Fri, Jan 10, 2025 at 10:13 AM Vladlen Popolitov
> <[email protected]> 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
> 
> [1]: https://www.sqlite.org/fileformat.html

I would recommend "PostgreSQL Internals" of Egor Rogov (Chapter 3 about 
tuples,
other chapters also great)
Free download from https://postgrespro.com/community/books/internals

Also PostgreSQL source code is officially the part of the documentation.
It is not joke. PostgreSQL source has clear comments in functions code
and in structure declarations. You can compare with other sources, it is 
hard to find better
comments made with love.

Heap tuple information is in source file 
src/include/access/htup_details.h (HeapTupleHeaderData
structure), but I recommend to read above book first, it simplier 
explains many
internal concepts.
-- 
Best regards,

Vladlen Popolitov.






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-01-10 15:04 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-01-10 09:41 Re: Postgres do not support tinyint? Dominique Devienne <[email protected]>
2025-01-10 10:44 ` [email protected]
2025-01-10 15:04 ` Vladlen Popolitov <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox