Index padding optimization

From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
To: pgsql-patches(at)postgresql(dot)org
Subject: Index padding optimization
Date: 2006-01-13 04:12:37
Message-ID: 20060113122933.4E1E.ITAGAKI.TAKAHIRO@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

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 Content-Type Size
index-padding.patch application/octet-stream 32.3 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-01-13 04:23:25 Re: patch to create system view that lists cursors
Previous Message Christopher Kings-Lynne 2006-01-13 02:02:35 Re: patch to create system view that lists cursors