Live data from Hacker News

New In Postgres 12: Generated Columns

pgdash.io

1–10 of 199 posts

Re: New In Postgres 12: Generated Columns

#2
As a developer I always hated this feature in other rdbms. The idea of your app saving a row and retrieving it only to have more data in it.

IMO these types of calcs are better done in your app, where you can at least write a test and assert it's doing the right thing. It also makes it a lot easier to reason about your code if the logic is in the app rather than bits of it stuck in column definitions.

Perhaps there are legitimate uses of this, maybe for DBs that aren't just repositories for apps?

Re: New In Postgres 12: Generated Columns

#3
At first, I thought; /hey pretty cool feature!/

But after contemplating it, is this really necessary? I fear for putting business logic and meanings into the wrong the layer; There are use and abuse, and my consideration fears the latter.

Re: New In Postgres 12: Generated Columns

#4
I tend to follow the Postgres releases and I am always impressed by the cool things SQL databases can do. But for programmers like me who are used to code in C++/C# I always find the transition from these languages to SQL too harsh. Especially if you don’t have to do SQL daily it’s really hard to remember the syntax and read complex SQL code. Also the transition from SQL results to typed languages is tedious. ORMs help a little but they have their own set of problems.

Not sure what I am trying to say other than that I wish it was easier for regular programmers to use advanced SQL features...

Re: New In Postgres 12: Generated Columns

#5

As a developer I always hated this feature in other rdbms. The idea of your app saving a row and retrieving it only to have more data in it. IMO these types of calcs are better done in your app, where you can at least write a test and assert it's doing the right thing. It also makes it a lot easier to reason about your code if the logic is in the app rather than bits of it stuck in column definitions. Perhaps there a…

Maybe there is a performance benefit to calculating values once at update time vs millions of times during query?

Re: New In Postgres 12: Generated Columns

#7

As a developer I always hated this feature in other rdbms. The idea of your app saving a row and retrieving it only to have more data in it. IMO these types of calcs are better done in your app, where you can at least write a test and assert it's doing the right thing. It also makes it a lot easier to reason about your code if the logic is in the app rather than bits of it stuck in column definitions. Perhaps there a…

It is great for geospacial.

You want centroids and bounding boxes precalced for all the geom you are pushing?

Now you can. Otherwise these can be pretty expensive operations.

Re: New In Postgres 12: Generated Columns

#8
post #3

At first, I thought; /hey pretty cool feature!/ But after contemplating it, is this really necessary? I fear for putting business logic and meanings into the wrong the layer; There are use and abuse, and my consideration fears the latter.

If your database contains objects like "customer ID", "address" and the like, you already have business considerations (if not logic) inside it. In fact, businesses using databases for business stuff is probably 95% of DB use cases.

If it's something that's not application-specific and fits nicely into the query language (like in the example given) it makes sense to have it inside the DB, because for queries involving sorting, limiting, etc. you can do all that stuff inside the DB and return the few values that interest you, instead of transferring all the data and having to write code to do that inside your app.

Re: New In Postgres 12: Generated Columns

#9

I tend to follow the Postgres releases and I am always impressed by the cool things SQL databases can do. But for programmers like me who are used to code in C++/C# I always find the transition from these languages to SQL too harsh. Especially if you don’t have to do SQL daily it’s really hard to remember the syntax and read complex SQL code. Also the transition from SQL results to typed languages is tedious. ORMs he…

Indeed. SQL concepts are insanely powerful, but the language itself feels a little bit old.

Re: New In Postgres 12: Generated Columns

#10

As a developer I always hated this feature in other rdbms. The idea of your app saving a row and retrieving it only to have more data in it. IMO these types of calcs are better done in your app, where you can at least write a test and assert it's doing the right thing. It also makes it a lot easier to reason about your code if the logic is in the app rather than bits of it stuck in column definitions. Perhaps there a…

One legitimate use case could be calculated values that you want to use in several apps (written in different languages) and in SQL reporting.
Post reply on HN