Christoph Schiessl sorts things out:
Custom
ENUMtypes in PostgreSQL are an excellent tool for enforcing certain database constraints, but you must be careful if you useSELECTqueries and want toORDER BYthese columns. Recently, I had to fix a bug whose root cause was a misunderstanding of this behavior. It’s just a contrived example, but imagine a table of people with their marital status, which is implemented as a customENUMtype.
Read on to learn more about the misunderstanding and some of the unexpected trickiness involved in getting a good query plan.