Re: Are globally defined constants possible at all ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: Andrew Sullivan <andrew(at)libertyrms(dot)info>, Darren Ferguson <darren(at)crystalballinc(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Are globally defined constants possible at all ?
Date: 2002-06-09 16:12:04
Message-ID: 5885.1023639124@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Nigel J. Andrews" <nandrews(at)investsystems(dot)co(dot)uk> writes:
> ... I still can't see how use of CHECK makes the mapping from a textual type
> to integer.

It doesn't. The point people are making is that storing a (short) text
string is a perfectly respectable way to do this.

If you're feeling a compulsion to micro-optimize, though, I'd recommend
the trick I used to use: use datatype "char" (note the quotes). This is
*one* byte on disk, even smaller than integer, and you can still choose
characters with some mnemonic value for your different states. This
method works pretty well up to a dozen or two possible states, after
which it starts to get hard to choose values; but beyond that point
I'd think a separate table is the way to go anyway.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Darren Ferguson 2002-06-09 17:03:03 Re: Are globally defined constants possible at all ?
Previous Message Nigel J. Andrews 2002-06-09 15:48:28 Re: Are globally defined constants possible at all ?