News for hackers. Stuff that matters.
Re:New In Postgres 12: Generated Columns by dewey on Wednesday October 02, 2019 @05:28AM (#21134665)
I found this book to be very helpful, I'm not done yet but so far I'm really enjoying it.

"Perfectly intelligent programmers often struggle when forced to work with SQL. Why? Joe Celko believes the problem lies with their procedural programming mindset, which keeps them from taking full advantage of the power of declarative languages. The result is overly complex and inefficient code, not to mention lost productivity."

https://www.amazon.com/Joe-Celkos-Thinking-Sets-Management/d...

Re:New In Postgres 12: Generated Columns by Ididntdothis on Wednesday October 02, 2019 @05:55AM (#21134774)
I think it’s not only the procedural vs declarative difference but also just the plain syntax. To me SQL is just hard on the eyes. It feels a little like FORTRAN in the good old days.
Re:New In Postgres 12: Generated Columns by misterdoubt on Wednesday October 02, 2019 @07:25AM (#21135246)
Well it doesn't help that people continue using ALL CAPS for SQL keywords as a preferred style. In this century.
Re:New In Postgres 12: Generated Columns by zo1 on Wednesday October 02, 2019 @07:59AM (#21135455)
I find that it helps differentiate the different components of the query. Same way we use all-caps for constants, etc. If it's lower-case, or camel-case, then it just sort of "melts" into the rest of the query.
Re:New In Postgres 12: Generated Columns by icebraining on Wednesday October 02, 2019 @11:17AM (#21137359)
Also nice for differentiating it from the rest of non-SQL code.
Re:New In Postgres 12: Generated Columns by pletnes on Wednesday October 02, 2019 @09:17AM (#21136044)
Not with syntax highlighting.
Re:New In Postgres 12: Generated Columns by preommr on Wednesday October 02, 2019 @11:45AM (#21137712)
The tooling around sql is pretty awful. I was looking for a vscode plugin to get some syntax highlighting and linting for postgres yesterday, and just gave up. There are plenty of administrative tools that help with connecting to dbs and showing the results in a nice table, but nothing that really helps with writing it (or at least nothing of high quality that I could find).
Re:New In Postgres 12: Generated Columns by dewey on Wednesday October 02, 2019 @11:59AM (#21137872)
https://www.jetbrains.com/datagrip/ and Postico are pretty great for PG I think. I'm using them every day and having the option to attach DataGrip to a directory of queries in your code and directly executing them from there with set variables is pretty sweet.

It's helping you write queries by auto formatting and good auto completion.

Re:New In Postgres 12: Generated Columns by timrichard on Wednesday October 02, 2019 @10:03AM (#21136530)
Over the years, I must have annoyed various DBAs by saying "Is that a query, or a ransom note?"
Re:New In Postgres 12: Generated Columns by _jal on Wednesday October 02, 2019 @10:17AM (#21136688)
I so very wish this convention would die.

Also, leading a new line with the comma.

Re:New In Postgres 12: Generated Columns by tmd83 on Thursday October 03, 2019 @10:06AM (#21147078)
I actually like them both a lot for someone who is a developer who has spend hours fixing/optimizing large queries. As someone mentioned in another comment good syntax highlighting is often not available for sql (if any) so having the keywords separated is very helpful. When fixing and improving things I mostly care about 10% of the query, the JOINS and WHERE clause and CAPS keyword make those much easier to grasp. And the comma at the line start is very helpful (even though it looks odd for me) when you are adding/removing columns and sections on the fly. If the comma is at the start of the line you can simply comment, if it's at line end you need to edit two lines when removing a particular line from the query.
Re:New In Postgres 12: Generated Columns by ken on Wednesday October 02, 2019 @11:21AM (#21137408)
I've read one of Celko's books (not that one), and I confess I didn't find it very helpful. And hearing "think in sets" is the worst.

In all the algebra classes I've taken, one nice thing about sets is you can arrange them in any order you like, and you'll get the same answer any way you slice it. There's no inherently correct orientation of mathematics. That's kind of the point. It's fully generic, by default. "x" can mean anything (at least, in the algebraic structure we've assumed).

With SQL, the experts drone "think in sets!" as a way to mean "you happened to pick a different order than me, so your query will run 1000 times slower". Well, mine is still sets. I'm not writing a for-loop here (and I'm pretty sure my SQL dialect has those by now).

I've actually had the most luck with SQL by thinking about it in terms of looping first. Figure out the most efficient loop over your biggest table, and then write a query in a way that makes it easy for the optimizer to loop over that.

Then again, nobody ever accused me of being "perfectly intelligent".

Re:New In Postgres 12: Generated Columns by Buttons840 on Wednesday October 02, 2019 @11:53AM (#21137799)
For me, it's because I've never studied my database the way I do my programming language. I'll read a thousand pages to master a new language, and I'll take it all to heart. Meanwhile, I begrudgingly read a few pages about PostgreSQL (let's say) and move on to the next task ASAP.

PostgreSQL has great documentation, and I will give it a serious read one day.

Re:New In Postgres 12: Generated Columns by spacemanmatt on Thursday October 03, 2019 @07:48AM (#21145892)
Spending a few professional years using/learning PostgreSQL hard have paid off like crazy for me. It's a great server, doing my own devops for it is not much burden, and it doesn't hurt to have it splashed all over my resume.
Re:New In Postgres 12: Generated Columns by noir_lord on Wednesday October 02, 2019 @07:40AM (#21135332)
Book looks interesting but the reviews are a bit of a mixed bag mostly about copy editing, has that been your experience?
Re:New In Postgres 12: Generated Columns by dewey on Wednesday October 02, 2019 @08:01AM (#21135467)
So far I didn't notice anything.