Re: Question about HeapTupleHeaderData

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Federico <rotellaro(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Question about HeapTupleHeaderData
Date: 2007-05-25 14:30:10
Message-ID: 20070525143010.GF4239@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Marsha Ramsey 2007-05-25 14:49:01 User DB Access - RESTRICTIONS
Previous Message Tom Lane 2007-05-25 13:57:19 Re: Abnormal storage consumption with autovacuum enabled