by SPBS · 3y ago · 0 comments
CREATE TABLE my_enum ( name TEXT PRIMARY KEY );
CREATE TABLE foo ( my_enum TEXT REFERENCES my_enum (name) );
The reason is because a SELECT * FROM foo showing cryptic enum ordinals is a headache, and having to join the enum table every time is potentially slower than just reading from the column directly. An ASCII character only takes 1 byte, so an INT enum is just as space efficient as using 4 characters, which affords way more descriptiveness than a meaningless ordinal number.Even 4 characters (which perform just as fast as Postgres’ native enums) is enough if you develop a system of abbreviations. The airline industry gets by with just three characters!