Unix Technical Forum

Two different defs of MAX_TUPLES_PER_PAGE

This is a discussion on Two different defs of MAX_TUPLES_PER_PAGE within the pgsql Hackers forums, part of the PostgreSQL category; --> Hi, I found two different definitions of MAX_TUPLES_PER_PAGE. Which is reasonable? Or do they have another meaning? backend/commands/vacuumlazy.c #define ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 06:33 AM
ITAGAKI Takahiro
 
Posts: n/a
Default Two different defs of MAX_TUPLES_PER_PAGE

Hi,

I found two different definitions of MAX_TUPLES_PER_PAGE.
Which is reasonable? Or do they have another meaning?

backend/commands/vacuumlazy.c
#define MAX_TUPLES_PER_PAGE ((int) (BLCKSZ / sizeof(HeapTupleHeaderData)))

backend/nodes/tidbitmap.c
#define MAX_TUPLES_PER_PAGE ((BLCKSZ - 1) / MAXALIGN(offsetof(HeapTupleHeaderData, t_bits) + sizeof(ItemIdData)) + 1)

---
ITAGAKI Takahiro
NTT Cyber Space Laboratories


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 06:33 AM
Tom Lane
 
Posts: n/a
Default Re: Two different defs of MAX_TUPLES_PER_PAGE

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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-11-2008, 06:33 AM
ITAGAKI Takahiro
 
Posts: n/a
Default Re: Two different defs of MAX_TUPLES_PER_PAGE

Tom Lane <tgl@sss.pgh.pa.us> wrote:
> #define MAX_TUPLES_PER_PAGE ((BLCKSZ - 1) / (MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + sizeof(ItemIdData)) + 1)
> (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.)


Don't you think about PageHeaderData? Also I guess a floor definition is ok
because 'number of tuples' is an integer. How about the following?

((BLCKSZ - offsetof(PageHeaderData, pd_linp)) /
(MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + sizeof(ItemIdData)))


> 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 ...


Considering include-hierarchy, I think bufpage.h is a good place.

---
ITAGAKI Takahiro
NTT Cyber Space Laboratories



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-11-2008, 06:34 AM
Tom Lane
 
Posts: n/a
Default Re: Two different defs of MAX_TUPLES_PER_PAGE

ITAGAKI Takahiro <itagaki.takahiro@lab.ntt.co.jp> writes:
> Don't you think about PageHeaderData?


I doubt it's really worth taking into account ... we can though.

> Also I guess a floor definition is ok
> because 'number of tuples' is an integer.


Right, now that I'm more awake I agree with 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 ...


> Considering include-hierarchy, I think bufpage.h is a good place.


No, that's a pretty bad place because it violates the module hierarchy:
access is on top of storage. None of the include/storage files know
what a HeapTupleHeader looks like.

I think we can just put it in htup.h, since that includes bufpage.h
already. Will make it happen.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:35 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com