Re:New In Postgres 12: Generated Columns
by ddorian43 on Wednesday October 02, 2019 @06:35AM
(#21134951)
Make a function ?
[ Parent
| on HN ]
Re:New In Postgres 12: Generated Columns
by aidos on Wednesday October 02, 2019 @06:45AM
(#21135000)
Do you mean an application layer function, or a dB one? And if a dB one, you also need to create an index to go with it. And then there are dragons that you don’t need in life. If an application one, then people need to know to call it, so, yeah.
I know there are things you can do, but having better tools available is always a win (especially when they remove later maintenance from the equation).
Re:New In Postgres 12: Generated Columns
by ddorian43 on Wednesday October 02, 2019 @06:56AM
(#21135071)
In DB. You can keep it with migrations.
You can have a functional index without creating a new column.
Make a trigger
From the article:
> ” Such functionality was earlier usually achieved with triggers, but with generated columns this becomes much more elegant and cleaner.”
"much more elegant and cleaner" is a bit of an overstatement in my opinion...
Sounds like the generated column implementation is faster than a PL/pgSQL trigger.
https://news.ycombinator.com/item?id=21134706
I don’t have a link at hand from a discussion on the mailing list, but I’ll take Peter’s word for it.
Re:New In Postgres 12: Generated Columns
by mobilemidget on Wednesday October 02, 2019 @02:59PM
(#21139668)
I miss the why its more elegant and cleaner too.
"Indexes: Generated columns can be used in indexes, but cannot be used as a partition key for partitioned tables."
I also hope it can be used for a partition key in the future.