Re: Two different defs of MAX_TUPLES_PER_PAGE - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Two different defs of MAX_TUPLES_PER_PAGE
Date
Msg-id 10240.1125633986@sss.pgh.pa.us
Whole thread Raw
In response to Two different defs of MAX_TUPLES_PER_PAGE  (ITAGAKI Takahiro <itagaki.takahiro@lab.ntt.co.jp>)
Responses Re: Two different defs of MAX_TUPLES_PER_PAGE
List pgsql-hackers
ITAGAKI Takahiro <itagaki.takahiro@lab.ntt.co.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


pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Additional background daemon (was: Remove xmin and cmin from frozen tuples)
Next
From: "Jim C. Nasby"
Date:
Subject: Re: Version number in psql banner