| От | Tom Lane |
|---|---|
| Тема | Re: Are globally defined constants possible at all ? |
| Дата | |
| Msg-id | 5885.1023639124@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Are globally defined constants possible at all ? ("Nigel J. Andrews" <nandrews@investsystems.co.uk>) |
| Список | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера