From: | Manfred Koizar <mkoi-pg(at)aon(dot)at> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | HeapTupleHeader withoud oid |
Date: | 2002-07-01 10:40:35 |
Message-ID: | qaa0iu4akjm4aqc10m45hsg4k3v49r70lk@4ax.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
We have been discussing heap tuple header changes for a while now.
Here is my proposal for omitting the oid, when it is not needed:
First let's eliminate t_oid from HeapTupleHeaderData.
Then add the oid to the end of the structure, if and only if it is
needed. The tricky part here is that there is a variable length field
(t_bits) and the oid has to be properly aligned.
This pseudo code snippet illustrates what I plan to do:
len = offsetof(HeapTupleHeaderData, t_bits); /* 23 */
if (hasnulls) {
len += BITMAPLEN(NumberOfAttributes);
}
if (hasoid) {
len += sizeof(Oid);
}
len = MAXALIGN(len);
hoff = len;
oidoff = hoff - sizeof(Oid);
#define HeapTupleHeaderGetOid(hth) \
( *((Oid *)((char *)(hth) + (hth)->t_hoff - sizeof(Oid))) )
And this is how the structure would look like:
1 2 3
0 4 0 0 34 78 2
now oooo<---------fix--------->.x___X___
+oid <---------fix--------->.oooox___ MAXALIGN 4
+oid <---------fix--------->.....ooooX___ MAXALIGN 8
-oid <---------fix--------->.X___
1:
now oooo<---------fix--------->bx___X___
+oid <---------fix--------->boooox___ MAXALIGN 4
+oid <---------fix--------->b....ooooX___ MAXALIGN 8
-oid <---------fix--------->bX___
2:
now oooo<---------fix--------->bb...X___
+oid <---------fix--------->bb...ooooX___ MAXALIGN 4 und 8
-oid <---------fix--------->bb...x___X___
3 4
6: 2 6 0
now oooo<---------fix--------->bbbbbb...x___X___
+oid <---------fix--------->bbbbbb...oooox___ MAXALIGN 4
+oid <---------fix--------->bbbbbb.......ooooX___ MAXALIGN 8
-oid <---------fix--------->bbbbbb...X___
where
<---------fix---------> fixed sized part without oid, 23 bytes
oooo oid, 4 bytes
b one bitmap byte
. one padding byte
x start of data area (= hoff) with 4-byte-alignment
X start of data area (= hoff) with 8-byte-alignment
Bytes saved on architectures with 4/8 byte alignment:
hoff bytes
natts bitmaplen hoff72 oidoff woo saved
0 28/32 24 24/24 4/8
1-8 1 28/32 24 24/24 4/8
9-40 2-5 32/32 28 28/32 4/0
41-72 6-9 36/40 32 32/32 4/8
As a first step I've already posted a patch that eliminates direct
access to t_oid. The final patch will change not much more than the
getter and setter macros.
Problems I have identified so far:
. heap_formtuple needs a parameter bool withoid
. Does heap_addheader *always* create a header with oid?
. Have to check heap_xlog_xxxx routines
. Occasionally a heap tuple header is copied by memmove.
Comments?
Servus
Manfred
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-07-01 13:28:30 | Re: [PATCHES] Changes in /contrib/fulltextindex |
Previous Message | Hannu Krosing | 2002-07-01 10:31:28 | Re: DROP COLUMN Proposal |