3 ms·
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 = ’
by jpalomaki 3y ago
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 3y agoThe "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 https://dba.stackexchange.com/a/258591/50410
- Too 3y agoIsn’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?