Attached is a patch that removes undesired paddings from b-tree indexes.

The tuples of b-tree index consist of BTItemData and index keys. BTItemData
should be placed only 2 byte alignment, so if the alignment of keys are less
than MAXIMUM_ALIGNOF, we can place them with their minimum alignment instead
of MAXALIGN.


I tested this patch with pgbench on the machine where MAXIMUM_ALIGNOF is 8.
It saved 20% of index file sizes, because accounts_pkey is btree index on
an integer (4 bytes), so the size for one tuple changed as follows:
 - original : 20 bytes = ItemIdData(4) + BTItemData(8) + key(4) + padding(4)
 - patched  : 16 bytes = ItemIdData(4) + BTItemData(8) + key(4)

./pgbench -i -s 100
# select relpages from pg_class where relname='accounts_pkey';
- original : relpages = 27422
- patched  : relpages = 21899

---
ITAGAKI Takahiro
NTT Cyber Space Laboratories

Attachment: index-padding.patch
Description: Binary data

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to