Re: ENUM type size

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Олег Самойлов <olleg(at)mipt(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ENUM type size
Date: 2017-09-02 22:06:31
Message-ID: 1038.1504389991@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?UTF-8?Q?=D0=9E=D0=BB=D0=B5=D0=B3_?= =?UTF-8?Q?=D0=A1=D0=B0=D0=BC=D0=BE=D0=B9=D0=BB=D0=BE=D0=B2?= <olleg(at)mipt(dot)ru> writes:
> May I ask the question here or I must go to the pgsql-hackers?
> Why does ENUM type have 4 byte size?

Because it's really an OID under the hood.

> In any use cases, that I know,
> ENUM 255 values (1 byte) more then enough.

Only if you consider each enum type in isolation (and even then, I'd
dispute your argument that nobody has use for more than 255 values).
In our implementation, enum types are essentially all foreign keys into
the same pg_enum catalog, so you definitely need more space.

Other ways of doing it would have created problems of their own. But
you can certainly build your own enum type if you don't like the tradeoffs
the core code made.

regards, tom lane

In response to

  • ENUM type size at 2017-09-02 20:23:07 from Олег Самойлов

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Олег Самойлов 2017-09-02 23:13:43 Re: ENUM type size
Previous Message Олег Самойлов 2017-09-02 21:25:05 Re: Numeric numbers