Re: Single character bitfields

From: "Andrew Maclean" <a(dot)maclean(at)cas(dot)edu(dot)au>
To: "'Tomasz Ostrowski'" <tometzky(at)batory(dot)org(dot)pl>
Cc: "'General'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Single character bitfields
Date: 2008-08-21 22:04:51
Message-ID: 018801c903d9$f027b350$d07719f0$@maclean@cas.edu.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----Original Message-----
From: Tomasz Ostrowski [mailto:tometzky(at)batory(dot)org(dot)pl]
Sent: Thursday, 21 August 2008 18:46
To: a(dot)maclean(at)cas(dot)edu(dot)au
Cc: General
Subject: Re: Single character bitfields

On 2008-08-21 05:29, Andrew Maclean wrote:

> Is char(1) one byte in size?

No. It will also depend on database encoding, etc.

I think you should go with smallint, which is exactly 2 bytes. You'll
have 15 bits of storage (16 if you'd want to implement the special case
of minus sign).

IMHO the only smaller field are:
- one byte boolean, but it can only store 1 bit.
- one byte "char" (with quotes), but it is a non standard, integral
type, will cause interface problems and I don't know if it will not be
deprecated some time.

Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
Winnie the Pooh

Thankyou for this, after reading around I have also come to the same
conclusion that smallint is the better option.

Andrew

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill 2008-08-21 22:09:13 Text field truncated using ADO/ODBC?
Previous Message Travis Smith 2008-08-21 20:49:48 Re: [ADMIN] Query performance difference