Re: [GENERAL] ENUM type size - Mailing list pgsql-general

From Tom Lane
Subject Re: [GENERAL] ENUM type size
Date
Msg-id 1038.1504389991@sss.pgh.pa.us
Whole thread Raw
In response to [GENERAL] ENUM type size  (Олег Самойлов <olleg@mipt.ru>)
Responses Re: [GENERAL] ENUM type size  (Олег Самойлов <olleg@mipt.ru>)
List 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@mipt.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


pgsql-general by date:

Previous
From: Олег Самойлов
Date:
Subject: Re: [GENERAL] Numeric numbers
Next
From: Олег Самойлов
Date:
Subject: Re: [GENERAL] ENUM type size