Live data from Hacker News

Learn SQL Once, Use It for 30 Years

fagnerbrack.com

171–180 of 243 posts

Re: Learn SQL Once, Use It for 30 Years

#171
post #164

Earlier quoted context omitted.

The breakthrough for me was thinking in terms of sets and not in terms of "how would I do this imperatively." If you see SQL where someone wrote a SELECT and is then using a cursor to loop through those results and do other queries, you've found the person who is still thinking imperatively.

> If you see SQL where someone wrote a SELECT and is then using a cursor to loop through those results and do other queries, you've found the person who is still thinking imperatively. To a first approximation, yes. But 'client-side joins' can be a valuable tool when the database engine won't cooperate. For some queries and some engines, you can do a select with a join to get everything you need in one query, but a s…

I'm not sure I follow. Fetching the data in one query should almost always be faster and more efficient - the same work is being done regardless, except now you have the additional overhead involved with a second query (network and connection overhead, parsing etc.)

Re: Learn SQL Once, Use It for 30 Years

#172
post #166
post #145

Earlier quoted context omitted.

So AI also thinks people somehow get away only with ORM without understanding SQL? Funny thing is, that is always argument of „anti ORM” people. I yet have to see someone actually argue that you don’t need to understand SQL and ORM will suffice in the wild. Then also find devs who can’t do a simple join as joins and index usage is not some black magic and is still required to use ORM properly.

> I yet have to see someone actually argue that you don’t need to understand SQL and ORM will suffice Well that's because decades of bitter experience has told us all that object graphs rarely map cleanly to sets of relationships. However, I do think that must have been the original idea as tools such as Hibernate tried so hard to obscure the underlying SQL and database. As a result all Hibernate objects have their o…

I would still like some kind of proof.

Like an early article having headline "ORM will replace SQL knowledge".

I am professional dev for 15 years and hobbyist for 20 years and I might have missed something. But only thing I do remember was "anti ORM" people nagging how "one should really know SQL" - where I never heard anyone saying "don't learn SQL" maybe only NoSQL hype... but no one else.

Re: Learn SQL Once, Use It for 30 Years

#173
post #164

Earlier quoted context omitted.

> If you see SQL where someone wrote a SELECT and is then using a cursor to loop through those results and do other queries, you've found the person who is still thinking imperatively. To a first approximation, yes. But 'client-side joins' can be a valuable tool when the database engine won't cooperate. For some queries and some engines, you can do a select with a join to get everything you need in one query, but a s…

I'm not sure I follow. Fetching the data in one query should almost always be faster and more efficient - the same work is being done regardless, except now you have the additional overhead involved with a second query (network and connection overhead, parsing etc.)

Depends on how the database engine sets up the join. I've seen queries where the join ends up spilling into a temp table and it takes a lot longer to do it that way. IIRC, this can happen especially if you've asked the database engine to sort things.

Same with UNION vs IN. If you union 10 queries for one row each by id, it'll hit the index every time; but if you do it with IN, maybe it decides to do an index scan which takes longer.

You could say well the database engine is broken if client-side join works better than database-side join, and sure it probably is, but given the choice of fix the database engine or do a client-side join, I know which one is feasible in the short term.

Re: Learn SQL Once, Use It for 30 Years

#174
post #168

Earlier quoted context omitted.

I was reacting to the parent post. And F and LL are very different. I'd say F is a more subjective metric.

I was reacting to the parent post as well, suggesting that they should have used “fundamental” rather than “low-level”, and that “fundamental” would also match the article picture.

Dunno. I think the pic is useless. SQL is not in the foundation of all those langs.

SQL is still very useful after all these years: that's the point that anyone will agree on.

Not low level. Not "fundamental" (by most definitions I can think of).

Re: Learn SQL Once, Use It for 30 Years

#175

But you cannot learn it “once”. You need to continuously use it (over those 30 years, for example) to be proficient at it. It’s not that you can study sql for let’s say, 30 days, and never touch/study it again. I did “learn” sql at uni… but had to study it again at every company i worked for (different problems triggered different solutions). Im still learning it.

That hasn't matched my experience. I read a fundamentals book on it, fully; a practical one (think it was T-SQL fundamentals, which was 90% ANSI sql). I did the problems, some were hard. Then its just kind of stuck around in my head, now nearly 15 years later. I use it often and am continuously shocked to understand it better than some of my colleagues, still, since I rarely use it. It also seems to have infected how I think, such that I'm often thinking in terms of SQL (or I guess, set theory really) when I"m reasoning about data and processing it. That's likely why it sticks, its just not that far removed from the operations that are happening (at the basic level), and then also not that complex. You aren't making new abstractions or layers with it, its a pretty limited set of features ultimately, and generally speaking it changes little if at all over time. Its great in that way, especially in this everything-changing-constantly industry.

Re: Learn SQL Once, Use It for 30 Years

#176
I also feel like giving a shout out to the PDF version of the official PostgreSQL manual. It was one of the most enjoyable and engaging tech books I've ever read, and seems like pretty much the gold standard in what official documentation can look like. It took me a while to figure this out though, because the UX of the standard HTML version of the manual is pretty clunky.

Re: Learn SQL Once, Use It for 30 Years

#177

Strong agreement. Also applies to regular expressions.

Eh... yes but, I can write a sql query and come back a year later and understand it at first glance, or maybe if its really complicated a minute or two.

Writing a regex involves always looking up the syntax, and being unable to read it an hour later without having to carefully disect it. I say this with 20+ YOE and I think I am better than the average bear with them.

That said, knowing what they can do is important and very useful. Its just the implementation that never quite sticks.

Re: Learn SQL Once, Use It for 30 Years

#178
post #30

> If you are a junior developer, “learn SQL properly” is the most valuable 40 hours you can spend. Not a tutorial. Not an ORM. Actual SQL: joins, subqueries, window functions, query plans. That investment pays you back at every job, in every stack, for decades This is the power of low-level reasoning. Today, even for a junior developers, even if they have AI that solves syntax problems, SQL teaches you to reason and…

The breakthrough for me was thinking in terms of sets and not in terms of "how would I do this imperatively." If you see SQL where someone wrote a SELECT and is then using a cursor to loop through those results and do other queries, you've found the person who is still thinking imperatively.

How is a cursor different from a jdbc call that fetches all records after executing a query? What advantages doez the cursor have that a recordset does not?

Re: Learn SQL Once, Use It for 30 Years

#179

Earlier quoted context omitted.

> Not a tutorial. Not an ORM. Actual SQL ah, this is an Ai article

It's always AI until proven otherwise... even then I'm skeptical.

Ellipses where a comma would suffice? Definitely AI. Not even a good model.

Re: Learn SQL Once, Use It for 30 Years

#180
post #30

> If you are a junior developer, “learn SQL properly” is the most valuable 40 hours you can spend. Not a tutorial. Not an ORM. Actual SQL: joins, subqueries, window functions, query plans. That investment pays you back at every job, in every stack, for decades This is the power of low-level reasoning. Today, even for a junior developers, even if they have AI that solves syntax problems, SQL teaches you to reason and…

I'm actually learning SQL now and finding it HIGHLY enjoyable.

I'm by no means a senior dev, but I don't know if I fit in the box of a junior either.

Regardless, SQL is proving enjoyable. But I really like logic, so it fits.

Post reply on HN