pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
HeapTupleHeaderData Layout description
4+ messages / 2 participants
[nested] [flat]

* HeapTupleHeaderData Layout description
@ 2021-01-22 13:50  benj.dev@laposte.net
  0 siblings, 1 reply; 4+ messages in thread

From: benj.dev@laposte.net @ 2021-01-22 13:50 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org

<div style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">‌Hi,<br>
<br>
In https://www.postgresql.org/docs/13/storage-page-layout.html<br;
we can find on § 68.6.1. Table Row Layout<br>
the Table 68.4. HeapTupleHeaderData Layout<br>
<br>
When additionning Length of differents Fields taht are present we obtain&nbsp; atotal of<br>
4+4+4+4+6+2+2+1 = 27<br>
<br>
What doesn't seem to fit with previous indication "There is a fixed-size header (occupying 23 bytes on most machines)"<br>
<br>
Researching in old doc shows that in 8.2 the documentation<br>
https://www.postgresql.org/docs/8.2/storage-page-layout.html<br;
indicate 27 bytes (with the same detailled Table)<br>
<br>
Number 23 appears from Postgres 8.3<br>
<br>
In some thread like https://stackoverflow.com/questions/2966524/calculating-and-saving-space-in-postgresql/7431468<br;
It's possible to read that<br>
Overhead per tuple (row)<br>
... And at least 24 bytes (23 + padding) for the tuple header ...<br>
<br>
As there is several thread about this point I suppose there is an evolution between 8.2 and 8.3 with a missdocumentation for an evolution of detailled Table "HeapTupleHeaderData Layout"<br>
<br>
IS it right ? And in this case what is the real detailled Table ?<br>
<br>
Thanks for any explanations<br>
Regards</div>

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

* Re: HeapTupleHeaderData Layout description
@ 2021-01-22 16:49  Tom Lane <tgl@sss.pgh.pa.us>
  parent: benj.dev@laposte.net
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2021-01-22 16:49 UTC (permalink / raw)
  To: benj.dev@laposte.net; +Cc: pgsql-docs@lists.postgresql.org

benj.dev@laposte.net writes:
> In https://www.postgresql.org/docs/13/storage-page-layout.html<br;
> we can find on § 68.6.1. Table Row Layout<br>
> the Table 68.4. HeapTupleHeaderData Layout<br>
> <br>
> When additionning Length of differents Fields taht are present we obtain&nbsp; atotal of<br>
> 4+4+4+4+6+2+2+1 = 27<br>

I think you missed the point that t_cid overlays with t_xvac.

			regards, tom lane





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

* Re: HeapTupleHeaderData Layout description
@ 2021-01-22 18:08  benj.dev@laposte.net
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: benj.dev@laposte.net @ 2021-01-22 18:08 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org

Le 22/01/2021 à 17:49, Tom Lane a écrit :
> benj.dev@laposte.net writes:
>> In https://www.postgresql.org/docs/13/storage-page-layout.html<br;
>> we can find on § 68.6.1. Table Row Layout<br>
>> the Table 68.4. HeapTupleHeaderData Layout<br>
>> <br>
>> When additionning Length of differents Fields taht are present we obtain&nbsp; atotal of<br>
>> 4+4+4+4+6+2+2+1 = 27<br>
> 
> I think you missed the point that t_cid overlays with t_xvac.
> 
> 			regards, tom lane
> 

Hi,
Thank you for this point. It's more clear.

So in fact the error (with number 27) was in the documentation for
version before postgres 8.3.

In version >=8.3, the overlays precision could be added into sentence
"XID for VACUUM operation moving a row version" => "XID for VACUUM
operation moving a row version (overlays with t_cid)"
or
Maybe show t_cid and t_xvac in the same cell into the array could be
more clear
Example :
|===========|===============|=========|================================|
|Field      |Type           |Length   |Description                     |
|===========|===============|=========|================================|
|t_xmin     |TransactionId  |4 octets |insert XID stamp                |
|-----------|---------------|---------|--------------------------------|
|t_xmax     |TransactionId  |4 octets |delete XID stamp                |
|-----------|---------------|---------|--------------------------------|
|t_cid      |CommandId      |         |insert and/or delete CID stamp  |
|t_xvac     |TransactionId  |         |XID for VACUUM operation moving |
|           |               |         |a row version                   |
|           |               |4 octets |(t_cid and t_xvax are overlayed)|
|-----------|---------------|---------|--------------------------------|
|t_ctid     |ItemPointerData|6 octets |current TID of this or newer row|
|           |               |         |version                         |
|-----------|---------------|---------|--------------------------------|
|t_infomask2|uint16         |2 octets |number of attributes, plus      |
|           |               |         |various flag bits               |
|-----------|---------------|---------|--------------------------------|
|t_infomask |uint16         |2 octets |various flag bits               |
|-----------|---------------|---------|--------------------------------|
|t_hoff     |uint8          |1 octet  |offset to user data             |
|===========|===============|=========|================================|

Thanks,
Regards





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

* Re: HeapTupleHeaderData Layout description
@ 2021-01-22 18:10  Tom Lane <tgl@sss.pgh.pa.us>
  parent: benj.dev@laposte.net
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2021-01-22 18:10 UTC (permalink / raw)
  To: benj.dev@laposte.net; +Cc: pgsql-docs@lists.postgresql.org

benj.dev@laposte.net writes:
> Le 22/01/2021 à 17:49, Tom Lane a écrit :
>> I think you missed the point that t_cid overlays with t_xvac.

> So in fact the error (with number 27) was in the documentation for
> version before postgres 8.3.

No, the pre-8.3 docs are also correct, for their time.

			regards, tom lane





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


end of thread, other threads:[~2021-01-22 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 13:50 HeapTupleHeaderData Layout description benj.dev@laposte.net
2021-01-22 16:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-01-22 18:08   ` benj.dev@laposte.net
2021-01-22 18:10     ` Tom Lane <tgl@sss.pgh.pa.us>

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