Re: Faster data type for one-length values

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: André Volpato <andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Faster data type for one-length values
Date: 2007-05-23 14:17:12
Message-ID: 20197.1179929832@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?ISO-8859-1?Q?Andr=E9_Volpato?= <andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br> writes:
> I need to store one-length values like '1', '2', '3' or '4' .

> Today, this field is indexed with btree and is of type smallint (int2).
> How much performance will be improved if I change it to "char" (1 byte
> length) ?

The improvement will be zero. Because of alignment restrictions, you
don't save any space from making an index entry smaller than 4 bytes.

If you have several such fields adjacent in a table row, making them all
narrower can save space, but it doesn't help for standalone index
entries.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message bruce 2007-05-23 14:24:57 deleting/dropping tables...
Previous Message PFC 2007-05-23 14:10:38 Re: Integrity on large sites