Re: Two different defs of MAX_TUPLES_PER_PAGE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Two different defs of MAX_TUPLES_PER_PAGE
Date: 2005-09-02 04:06:26
Message-ID: 10240.1125633986@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp> writes:
> I found two different definitions of MAX_TUPLES_PER_PAGE.
> Which is reasonable? Or do they have another meaning?

Hmm, I think those were both my fault at different times :-(.
Right now I am thinking that they are both not quite right,
in particular it ought to be

#define MAX_TUPLES_PER_PAGE ((BLCKSZ - 1) / (MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + sizeof(ItemIdData)) + 1)

That is, the heaptuple space is padded to a MAXALIGN boundary, but the
itemid that points to it isn't. Comments?

(I believe that both modules want a ceiling definition not a floor
definition, ie round up any fraction. The -1 / +1 trick is of course
just one way to get that.)

Also, is this something that should be in a common header file? If so
which one? BLCKSZ, HeapTupleHeaderData, and ItemIdData are all defined
in different places ...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim C. Nasby 2005-09-02 04:34:37 Re: Version number in psql banner
Previous Message Jim C. Nasby 2005-09-02 03:51:31 Re: Additional background daemon (was: Remove xmin and cmin from frozen tuples)