Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
jpalomaki
on June 20, 2023
|
parent
|
context
|
favorite
| on:
Representing Enums in PostgreSQL
Native enums can be used in queries like strings, but with type checking:
select * from cust where type = ’company’ -- ok select * from cust where type = ’c0mpany’ -- error
As mentioned, they take less space. Important if you use these columns in index and have millions of rows.
ceving
on June 21, 2023
|
next
[–]
The "less space" argument does not seem to be true in every situation. Enums may suffer from alignments. See here:
https://dba.stackexchange.com/a/258591/50410
Too
on June 22, 2023
|
prev
[–]
Isn’t index size more proportional to number of distinct values and number of rows. With few distinct enum options, the size of each shouldn’t have big impact?
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: