pgsql.hackers
[Top] [All Lists]

Question regarding the database page layout.

Subject: Question regarding the database page layout.
From: "Ryan Bradetich"
Date: Mon, 11 Aug 2008 01:07:00 -0700
Newsgroups: pgsql.hackers
Hello all,

I have been digging into the database page layout (specifically the tuples)
to ensure the unsigned integer types were consuming the proper storage.
While digging around, I found one thing surprising:

It appears the heap tuples are padded at the end to the MAXALIGN distance.

Below is my data that I used to come to this conclusion.
(This test was performed on a 64-bit system with --with-blocksize=32).

The goal was to compare data from comparable type sizes.
The first column indicates the type (char, uint1, int2, uint2, int4, and
uint4),
the number in () indicates the number of columns in the table.

The Length is from the .lp_off field in the ItemId structure.
The Offset is from the .lp_len field in the ItemId structure.
The Size is the offset difference.

char (1)        Length      Offset  Size            char (9)
Length       Offset   Size
                            25      32736
32                                         33      32728      40
                            25      32704
32                                         33      32688      40
                            25      32672
32                                         33      32648      40
                            25
32640                                                  33      32608

uint1 (1)       Length       Offset   Size            uint1 (9)
Length       Offset  Size
                             25      32736
32                                        33      32728     40
                             25      32704
32                                        33      32688     40
                             25      32672
32                                        33      32648     40
                             25      32640
                33      32608

int2 (1)         Length       Offset   Size            int2 (5)
Length       Offset  Size
                             26      32736
32                                        34      32728     40
                             26      32704
32                                        34      32688     40
                             26      32672
32                                        34      32648     40
                             26
32640                                                  34      32608

uint2 (1)        Length      Offset   Size            unt2 (5)
Length       Offset  Size
                             26      32736
32                                        34      32728     40
                             26      32704
32                                        34      32688     40
                             26      32672
32                                        34      32648     40
                             26
32640                                                  34      32608

int4 (1)           Length      Offset  Size            int4 (3)
Length     Offset  Size
                             28      32736
32                                          36     32728     40
                             28      32704
32                                          36     32688     40
                             28      32672
32                                          36     32648     40
                             28
32640                                                   36     32608

uint4 (1)         Length       Offset  Size            uint4 (3)
Length      Offset  Size
                              28      32736
32                                         36     32728     40
                              28      32704
32                                         36     32688     40
                              28      32672
32                                         36     32648     40
                              28
32640                                                  36     32608

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy