Re: Question about HeapTupleHeaderData - Mailing list pgsql-admin

From Alvaro Herrera
Subject Re: Question about HeapTupleHeaderData
Date
Msg-id 20070525143010.GF4239@alvh.no-ip.org
Whole thread Raw
In response to Question about HeapTupleHeaderData  (Federico <rotellaro@gmail.com>)
List pgsql-admin
Federico escribió:
> Hi,
> I'm writing some papers about PostgreSQL physical storage and I'm
> bumping into the  HeapTupleHeaderData layout as descripted here
> http://www.postgresql.org/docs/8.2/static/storage-page-layout.html
>
> Reading the source code in src/include/access/htup.h I got a question.
>
> The t_cmin and t_cmax stores the insert and delete CID stamps.
> the CID (command that operate on item id?) is similar to XID? where I
> can find some docs about CID and its meaning?

CID is shorthand for CommandId.  Each tuple created or destroyed in a
transaction is marked with the creation CommandId (cmin) and the
destruction CommandId (cmax).  A later command in the transaction should
not be able to see a tuple destroyed by an earlier command; and an
earlier command should not be able to see a tuple created by a later
command.

This mechanism is there to solve the so-called Halloween Problem.
http://blogs.ittoolbox.com/database/technology/archives/what-is-the-halloween-problem-in-databases-12618

The current CommandId in a transaction is incremented each time an
UPDATE/INSERT/SELECT/DELETE (etc) operation is performed.  Some utility
commands (CREATE TABLE, etc) may increment the command counter more than
once (internal implementation detail you should not care about).

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: Abnormal storage consumption with autovacuum enabled
Next
From: Marsha Ramsey
Date:
Subject: User DB Access - RESTRICTIONS