Home > Database > The overhead size for each tuple in a Postgresql table

The overhead size for each tuple in a Postgresql table

August 17th, 2011

A quick take-away message: in version 9.0.4 of Postgresql, every tuple has an overhead of 24 bytes. I think this is mostly the size of OID (object ID).

I didn’t dig the source code. I just used module pgstattuple. Follow the instructions on this page about how to install contributed modules.

Then initdb, and createdb.

Next, “create table tb1(f1 int)”. and insert (1), or whatever int value. Use “SELECT * FROM pgstattuple(‘tb1′);” to find out the tuple_len of this table. You will find it to be 28. This is 24 + 4. A 24-byte OID, and a 4 bytes int.

Now, “create table tb2(f1 int, f2 int)”. and insert (1, 2). You will find the tuple_len to be 32, which is 24+4+4.

If you create a table of (f1 int, f2 int, f3 int), and insert a tuple, the tuple_len will become 36.

This page verifies that the size of a int has a size of 4 bytes.

Mr. One Database

  1. No comments yet.
  1. No trackbacks yet.