8/23/2026 at 2:52:33 PM
Some overlap here with some of my favorite essays on why SQL is lacking:https://www.scattered-thoughts.net/writing/against-sql
That particular post ends with a wish-list of items so it's the most similar to the OP. But there are others on the site that I quite enjoy (click on the home icon and search "SQL" on the page).
My personal take is that SQL will continue to reign for a long time because of the how monumental the task of replacing it is due to the inherent complexity of databases. LLMs make this worse because they're really good at translating prose to SQL. Now that it matters less how annoying SQL is to programmers, SQL will become more like assembly over time: something mostly computers write because it's complicated for humans to deal with directly. This is deeply ironic given that SQL was ostensibly designed to read like prose, i.e. to be easy for humans.
by scythmic_waves
8/23/2026 at 4:00:02 PM
Rawdogging SQL when you're not a seasoned DB administrator basically makes an arcane art look occult.Most people reach out towards an ORM or query building engine and otherwise don't really go far beyond the basic CRUD, joins, and some simple aggregations with groups. Since they try to be DB agnostic you'll rarely get an adaptor over CTEs or window functions or partitioning.
An LLM is great at exposing what a database is capable of doing with SQL and might even manage to navigate the most poorly designed of schemas. And it might even manage to design one to an acceptable standard if it has enough domain knowledge in its context.
by ljm
8/23/2026 at 5:25:05 PM
The problem in my view is that there aren't good tools to debug advanced SQL stuff within the context of the whole system which is usually written in a higher level language. I just spent a few weeks modifying some code where the original dev put a lot of logic into stored procedures. That's in principle fine but it's really hard to figure the actual business logic when it's spread out over C# and then also SQL. It doesn't help that the SQL code looks like FORTRAN code from 1985.Personally I think we need ORMs that allow expressing advanced SQL stuff with other high level languages. Or even better: The ORM detects where advanced SQL makes sense and uses it.
by vjvjvjvjghv
8/23/2026 at 7:18:14 PM
If I had to pick, I'd try to make the ORM redundant by making 'lower level' SQL easier to deploy rather than depending on sending strings of SQL queries and mutations over the wire.I haven't worked in a single setup where raw SQL has been encouraged, because it always requires DB migrations and not all of them are safe. Nobody dares touch the DB server's resources by setting up stored procedures, materialised views, etc. etc. and instead people are blowing money on Redis instances and caching and shit.
I don't have an answer to this but I've hit a lot of issues in my career where I think, "this could have been solved months ago by pivoting a couple of tables or creating a new function." You have been able to 'script' the DB for decades but you lose a lot of what you gain from the traditional SDLC at the app layer.
by ljm
8/24/2026 at 4:03:14 AM
For me, one of the primary benefits of ORMs is that they can parameterize requests which then prevents SQL injection attacks.Passing raw SQL to the database needs very careful attention to the dynamic parts, and it's too easy for user-generated data to be included.
Yes, it's possible to pass user generated text through a sanitizer but now you just have an arms race between the sanitizer and "clever" users.
by bruce511
8/24/2026 at 7:28:37 PM
It’s not that hard to pass values as query parameters of a manually written query. With inferior databases that don’t support array parameters it’s a bit more work to construct the correct number of $ parameters in the query, but still not that hardby jedwards1211
8/25/2026 at 3:03:57 AM
"Can it be done?" is one question. "Is it done dilligently by all the programmers on the team?" is quite another.by bruce511
8/23/2026 at 10:17:05 PM
Dapper in .net is fantastic to deal with raw sql, to the point I think I’m delusional because it’s so damn simple to send outrageous queries to the database and have those multiple mixed results turned into objects very simply.I’ve never had an issue of raw SQL requiring migrations? Unless you’re talking of changing database engine? In which case I think it’s a bit of folly to imagine changing the database engine will not mean changes to your stack higher up the chain.
by grebc
8/24/2026 at 1:49:57 AM
> Rawdogging SQL when you're not a seasoned DB administrator basically makes an arcane art look occult.Isn't that true of most languages? SQL has pretty simple syntax; I think the only reason it's sometimes seen as arcane is that fewer and fewer people bother to learn it.
by sgarland
8/24/2026 at 3:39:38 AM
dba here and I really don't get why SQL is so feared... I get that it requires very different way to think about data but it is quite simple in terms of you tell it what to do, and if it does it badly you probably told it wrong so just try something different...by alliao
8/24/2026 at 9:49:18 AM
Because:1. SQL isn't composable (you can't assign fragments to variables except for CTEs) so you can't easily test out subparts and build them up incrementally without just copy/pasting stuff around.
2. Joins are an unnatural way to dereference pointers.
3. SQL is more than SELECT. Once you get into updates you encounter lots of scary edge cases and traps. How many engineers really understand isolation levels? Why doesn't skipping the column list in an INSERT substitute nulls for the nullable columns that aren't provided? What changes can you make to a schema that are 'safe' for your environment (won't take table locks)? What locks are being taken by the RDBMS behind your back - sometimes it matters!
4. Site outages caused by optimizer plan shifts are scary because people don't feel in control.
Good databases have features to ameliorate these issues, but most people's experience is of databases that are merely OK and not good.
by mike_hearn
8/24/2026 at 11:28:25 AM
> 2. Joins are an unnatural way to dereference pointers.There's gotta be a simple & clear alternative to this obstruction. Maybe it just hasn't been invented yet.
by euroderf
8/24/2026 at 11:55:44 AM
Most query languages do fix that. GraphQL is one example.by mike_hearn
8/24/2026 at 7:31:51 PM
GraphQL joins are entirely up to the underlying resolvers, it has no syntax for expressing different kinds of joins or filter conditions on values from multiple joined relationsby jedwards1211
8/24/2026 at 3:09:37 PM
> How many engineers really understand isolation levels?I feel like there’s no excuse for this one. You need to know how your data store will interact with your query and others.
The problem, I think, is what the tail end of that is, and is what you hinted at when discussing locks: RDBMS interaction. I have come around on this recently (quite recently - after reading and re-reading this article, and the comments), so forgive me if any past comments in my history indicate otherwise.
It is unreasonable to expect a developer to administer an RDBMS. If you're a small startup, you kind of have to out of necessity; maybe if you're lucky, you hire a dev who's also done infra work, and if the stars align, they've specifically administered an RDBMS at scale. But what counts as administration? Let's look at adding a secondary index, possibly the most common DDL.
AFAIK, no ORMs / frameworks (I am assuming here that most devs are using some kind of abstraction for RDBMS access) default to "safe" builds - no `CONCURRENTLY` for Postgres, and no reducing `lock_wait_timeout` to something sane for MySQL (I've no idea about MSSQL nor Oracle, though I also assume that if you're running one of those, you probably have a DB team). So already, there is an implicit assumption that they've read the pertinent manual section[s] for their RDBMS, which seems unlikely. Even if they did, there's a chance they would also need to have read and understood the paragraphs on handling invalid index builds (Postgres), or the impact that foreign key constraints can have on metadata locks (MySQL).
Let's say the line gets drawn at "devs should be able to understand that they [probably] need secondary indices," with implementing those being entirely on another team or service. OK - how much do they need to understand? I think it's reasonable to expect a developer to understand B+trees; after all, they're just a data structure. Should they need to be able to internalize that such that they can understand why doing a range scan on a column in the middle of a multi-column index removes everything to the right of it from B+tree filtering? Probably, but now we're significantly deeper into specifics. Should they know that there are different kinds of indices, like GIN? Maybe. What about different operator classes (Postgres) for them? Maybe, maybe not. What about knowing about its `fastupdate` option, and the related `gin_pending_list_limit` configuration item? I'd love to say no, those are squarely in the world of ops, but then why should they be allowed to create the index at all if it's going to increase someone else's operational burden?
For all these reasons, I don't think it's prudent to have dev teams managing their own DBs. But then, you get into the fight that most places seem to be in, where the devs want to do something to the DB that the ops team knows will be a headache later, they push back, product gets mad that they aren't shipping, ops capitulates, and then the headache predictably becomes real months down the road. Rinse and repeat.
I have no clue how to fix this while maintaining the modern trend of velocity dominating everything else.
by sgarland
8/24/2026 at 6:54:39 PM
Some of it can be fixed by automation, but yes it's a problem. The NoSQL trend was partly I think a reaction against the complex feature sets and quirks of SQL databases. But then those features existed for good reasons, and just saying "we do less" isn't really a simplification, it's just ... doing less. MongoDB also distinguishes between concurrent and non-concurrent index builds, requiring you to pick up front. And it's not fully concurrent anyway.by mike_hearn
8/24/2026 at 3:11:10 AM
> Rawdogging SQL when you're not a seasoned DB administrator basically makes an arcane art look occult.This is kind of a hot take. Most devs I know know PostGreSQL well. They know how to write complex queries with CTAS, joins, etc, know how to create indexes, views, and add user defined functions.
by catlifeonmars
8/24/2026 at 1:18:06 AM
The end of that article ends with a pertinent quote [1] by Michael Stonebraker [2]. I've included more of the original quote here:> My biggest complaint about System R is that the team never stopped to clean up SQL. [...] All the annoying features of the language have endured to this day. SQL will be the COBOL of 2020, a language we are stuck with that everybody will complain about.
> My second biggest complaint is that System R used a subroutine call interface (now ODBC) to couple a client application to the DBMS. I consider ODBC among the worst interfaces on the planet. To issue a single query, one has to open a data base, open a cursor, bind it to a query and then issue individual fetches for data records. It takes a page of fairly inscrutable code just to run one query. [...] Only recently with the advent of Linq and Ruby on Rails are we seeing a resurgence of cleaner language-specific enbeddings (sic).
by Rendello
8/24/2026 at 2:26:43 AM
I was with him until he mentioned Ruby on Rails, is he talking about something other than the fairly ugly activerecord pattern?by wredcoll
8/23/2026 at 4:17:54 PM
LLMs are also very good at writing code for newly invented languages, especially if they can execute it and iterate. I strongly believe the barrier to switch languages is lowered in a post LLM world.Ten years ago I was at a startup where we used Datomic, and it was okay, but six months in the sales team was like “ok how do I run SQL queries so I can triage leads”. We had no answer of course.
Today it would simply be: type what you want in natural language and we’ll generate the query with Claude.
I just tried one representative query from that startup against a hypothetical datalog query tool in Rust and it did just fine.
by reitzensteinm
8/24/2026 at 3:16:03 AM
I did this with our team: I created a schema.md document with an LLM-friendly explanation of the schema, and walked the whole team through how to create a Grafana query using an LLM and this document.Within a couple of weeks we have totally non-technical folks with very sophisticated queries in their dashboards. It works fine.
It was very cut-and-paste, though, and I'm working (when I get the chance) on doing this via a chat interface where the LLM can interact directly with the database and Grafana to make it smoother.
So I think the answer is not necessarily new languages, just better integration with the final interface. In an ideal world we should be able to ask in chat "what were the sales numbers for last quarter for APAC excluding the three largest customers?" and get an answer near-instantly, and then we don't really need to deal with queries or languages at all.
by marcus_holmes
8/24/2026 at 3:40:59 AM
did you use llm to create the llm-friendly schema.md? This sounds like a brilliant idea I might need to steal it... thanks!by alliao
8/25/2026 at 12:33:32 AM
Yeah, but it was a lot of questioning and refining to get it to understand the wrinkles and edge cases. I think we're on about version 5 of the doc nowby marcus_holmes
8/23/2026 at 8:08:50 PM
I agree that an LLM could also generate the code for a new query language. But my point is that fewer people will attempt to author a new query language in the first place because an LLM will be writing the queries either way. So the effort would be less impactful.by scythmic_waves
8/23/2026 at 8:45:22 PM
You're right, I was talking past you.I have an implicit belief that SQL isn't the most effective low level language we could have and LLMs will free us up to explore that space, similar to asm.js -> WASM. But I'm open to being wrong about that.
by reitzensteinm
8/24/2026 at 3:42:41 AM
I think it strikes a good balance between still human-readable and low-ish.. any lower I suspect you'd need to dedicate a lot more documentation else where..by alliao
8/24/2026 at 2:36:01 AM
Datalog exists and there are so many implementations.by huahaiy
8/24/2026 at 2:35:17 AM
Agree. Especially when Datalog queries are simpler to write and faster to run than SQL, there is a strong reason to at least try it.by huahaiy