HNHacker News
TopNewBestAskShowJobs

jpmelos

8 karma · joined November 23, 2017

submissionscomments
jpmelos··on Representing Enums in PostgreSQL
I don't like this approach much because getting cryptic integers when you do a `SELECT` in the database is really cumbersome.
jpmelos··on Representing Enums in PostgreSQL
An enum stores a small reference to the enum value in the tuples, and the constraint approach stores the string itself. The constraint approach takes more space with (a) larger enum values, (b) more columns using them, and (c) more rows in the tables that use them. The difference depends on the characteristics of the database we're talking about.
jpmelos··on Representing Enums in PostgreSQL
> Is there a reason ALTER TYPE name ADD VALUE new_enum_value wouldn't Just Work for the first example for 99% of use cases?

I'm sorry, we don't have any examples in the article about adding values to enums, so I don't know to what you are referring here.

> Yes, that's true, but also very rare?

It is rare, indeed, but we just have a strong inclination towards having a clean schema, so we do prefer to clean up things that would otherwise be unused. But I understand that many people would prefer to leave them hanging there, even if they are not going to be used in any way.

jpmelos··on Representing Enums in PostgreSQL
That would be an improvement on the `CHECK` constraint approach if the same `CHECK` constraint is used in multiple columns, to DRY it up. The `DOMAIN` types offer the same commands for `CHECK` constraints, namely `NOT VALID` when updating the constraint, and `VALIDATE CONSTRAINT` to make sure it is valid after having updated it.
jpmelos··on Ask HN: What overlooked class of tools should a self-taught programmer look into
If understanding how Linux works interests you: http://www.linuxfromscratch.org/
jpmelos··on Ask HN: What was your greatest accomplishment in 2018?
This is something I really want to implement in 2019: a routine, and a general attitude, strategy, tactics and actions to "get my act together".
jpmelos··on Ask HN: Books on specific topics that have applied to many areas of your life?
"Mindset: The New Psychology of Success". By Carol Dweck, PhD. This is a game-changer. It taught me what we believe is what really defines what we can or cannot do.