Re: Are globally defined constants possible at all ? - Mailing list pgsql-general

From Tom Lane
Subject Re: Are globally defined constants possible at all ?
Date
Msg-id 5885.1023639124@sss.pgh.pa.us
Whole thread Raw
In response to Re: Are globally defined constants possible at all ?  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
List pgsql-general
"Nigel J. Andrews" <nandrews@investsystems.co.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

pgsql-general by date:

Previous
From: "Nigel J. Andrews"
Date:
Subject: Re: Are globally defined constants possible at all ?
Next
From: Darren Ferguson
Date:
Subject: Re: Are globally defined constants possible at all ?