6 ms·
Against SQL (2021)
- janpio 11mo ago(2021)
- j45 11mo agoTrying to understand how the year is relevant - still new to folks and still seems relevant.
- bruce511 11mo agoIt's helpful to include the year in the article header because; Everything may have been true at the time of writing, but details may be obsolete. For example this article refers to Neo4j. Knowing the article is 4 years old helps me understand that comment is not current. The landscape can change quickly. The older an article the more one takes that into account. Given that this article promotes an alternative technique, Knowing the article is old allows me to wonder if any of the suggestions were gelled, and if so to what success. In this case, since SQL has been around since the 70s, it's not surprising that the complaints are not novel, and are all likely to be true for years to come. SQL has truly enormous inertia on its side though.
- j45 11mo agoThe year can help for sure - is the article's content still relevant and current in your mind? On one hand SQL, is the most established relational db. Not sure what might drastically change about. Python and Javascript are from the 90’s and have evolved as a language in their own way like SQL and others. I was asking about the year as an individual comment here to understand what significance the year relative to the content of the topic it bore.
- Izkata 11mo agoIt's a HN convention for all posts: If it wasn't from within the past year or so, the year it was posted gets added to the title. Having to think about it per-topic is just making it more complicated for no good reason. Especially since SQL does get new additions. People posts comments like that as a reminder because the title originally didn't have it in there, someone edited it in after the comment.
- mitchbob 11mo agoDiscussion in 2021 (346 comments): https://news.ycombinator.com/item?id=27791539 https://news.ycombinator.com/item?id=27791539
- dang 11mo agoThanks! Macroexpanded: Against SQL (2021) - https://news.ycombinator.com/item?id=43777515 https://news.ycombinator.com/item?id=43777515 - April 2025 (1 comment) Against SQL - https://news.ycombinator.com/item?id=40454627 https://news.ycombinator.com/item?id=40454627 - May 2024 (1 comment) Against SQL (2021) - https://news.ycombinator.com/item?id=39777515 https://news.ycombinator.com/item?id=39777515 - March 2024 (1 comment) Against SQL - https://news.ycombinator.com/item?id=27791539 https://news.ycombinator.com/item?id=27791539 - July 2021 (339 comments)
- procaryote 11mo agoTL;DR; * a list of things they don't like in sql * a list of traits they think a replacement should exhibit by negating the first list I was kind of hoping for some example of what this much better language should look like
- cess11 11mo agoMaybe I'm holding TFA wrong but to me it seems like they're hinting at wanting a Prolog-as-database that could also become widely used, unlike actual Prolog. It's not hyper-performant and mega web scale but the object database and Prolog like query language that comes with Picolisp is quite fun and sometimes rather useful, and has helped me think differently about how to model things in the default SQL database engines.
- procaryote 11mo agoIt sounds interesting, although I have learnt both SQL and prolog and one was a lot easier
- cess11 11mo agoI'm actually uncertain whether you likely consider SQL or Prolog easier. To me both of them have a kind of late seventies feel that is kind of foreign compared to a lot of software stuff from the last quarter of a century. Pilog is similar to both, the basics are kind of easy to learn, it's basically a bit of Lisp:ish syntax and keywords for 'give me a subset from these sets'. But it's a graph of objects instead of tables or atoms.
- Spivak 11mo agoI think the much better language would be the "no language" database. Throw portability to the wind and just have the client ship the query plan directly. The frontend to the database is howerver you want to expose it in your language of choice. I don't think there's any hope of getting disparate db vendors to agree on a compatible frontend language. It seems easier to externalize it. The closest existing database to this ideal is probably FoundationDB although it also externalizes the query planner, which I don't necessarily consider a downside.
- j45 11mo agoI'm agnostic between relational/non-relational. SQL isn't for everything. Neither is starting with NOSQL thinking it might be better and then proceeding to spend way too many man years making it a relational database, when learning a bit of SQL would have handled it fine.
- jampekka 11mo agoThe post is not against the relational model. It's against SQL. > The relational model is great ... but SQL is the only widely-used implementation of the relational model ...
- YZF 11mo agoIn my day job the question of SQL and its role keeps coming up. Some people want to propagate SQL all the way to clients like web browsers. Perhaps operating over some virtual/abstract data and not the real physical underlying data (that's a whole other layer of complexity). This seems like a bad idea/API in general. I'm not too familiar with GraphQL but on the surface it seems like another bad idea. Shouldn't you always have some proper API abstraction between your components? My sense for this has been like GraphQL was invented out of the frustration of the frontend team needing to rely on backend teams for adding/changing APIs. But the answer can't be have no APIs? All that said there might be some situations where your goal is to query raw/tabular data from the client. If that's your application then APIs that enable that can make sense. But most applications are not that. EDIT: FWIW I do think SQL is pretty good at the job it is designed to do. Trying to replace it seems hard and with unclear value.
- nesarkvechnep 11mo agoI hold a very unpopular opinion of GraphQL. I think it’s a great internal querying API. Every web backend project I’ve worked on tries to implement an API for querying data and it’s usually either fast and inflexible or flexible but slow. GraphQL allows to strike a balance, flexible and reasonably fast, with ways to optimise further.
- RedShift1 11mo agoI love GraphQL, it's great. It takes away the ambiguous way to organize REST APIs (don't we all love the endless discussion about which HTTP status code to use...), and at the top level separates operations into query/mutation/subscription instead of trying to segment everything into HTTP keywords. It takes a bunch of decision layers away and that means faster development.
- nevertoolate 11mo agoQuestion is: do you need that flexibility if you have the backend for frontend? Can you design such a flexible api which makes it possible to iterate faster? If not, you just pay, in the best case, a constant overhead, or worst case, exponential overhead for each request! If you need to spend time optimizing because you have monitoring for slow queries or downtime caused by never terminating queries than most likely you’ve already eaten implementation speed advantage - if it exists at all in the first place.
- GuinansEyebrows 11mo agoQuestion for people who actually write app and SQL code: besides convenience, what is the upside of working with JSON in SQL over having your app construct and parse JSON objects, but storing the data in a database using more primitive types? My relatively inexperienced brain is telling me that it’s probably over complex to store and manipulate JSON objects at the DB level.
- YZF 11mo agoI've occasionally stored JSON directly in a database. It really depends on what you do with this data. If you do need to query and manipulate the internals of that JSON object then you should extract that data into a proper schema. But sometimes e.g. this is just something the frontend uses and you never (or rarely) have to query the internals, i.e. you treat it as an opaque blob.
- taffer 11mo agoI use Postgres JSON functions to return nested results. The database itself contains no JSON; just a well-normalised data model. However, the queries return nested JSON in the format required by the application, e.g. for rendering an HTML template or returning JSON to the client in a single round trip. Check out the old dogs can sort of learn new tricks in this great article: https://www.scattered-thoughts.net/writing/sql-needed-structure/ https://www.scattered-thoughts.net/writing/sql-needed-struct...
- gavinray 11mo ago> JSON functions to return nested results. The database itself contains no JSON; just a well-normalised data model. However, the queries return nested JSON in the format required by the application Entirely valid usecase, since the client application is likely going to parse some cartesian product of tabular relationship data into "normalized" JSON array of objects anyways. Generally, generating the JSON response directly for consumption in the DB is faster.
- gavinray 11mo ago> what is the upside of working with JSON in SQL over having your app construct and parse JSON objects, but storing the data in a database using more primitive types? You use map-like structures (JSON/HStore, etc) for semi-structured user data that you CAN'T define/know a rigid schema for, ahead-of-time. Think usescases like: Allowing users to write configuration rules, or lists of custom tag <-> value pairs for (whatever), things of these sorts
- zkmon 11mo agoSo I guess the author is trying to help a decision maker to make a decision when faced with a question of whether to use SQL or not. But in reality that question would be settled by other factors and contextual reasons rather than the arguments provided by the author. For instance, analytics usecases favor SQL stores, as slicing and dicing is better done with row or column stores instead of document databases. Also, Postgres is getting more popular for lot of usecases, so SQL is here to stay.
- geysersam 11mo ago> So I guess the author is trying to help a decision maker to make a decision when faced with a question of whether to use SQL or not. That's not my impression. A decision maker today should typically make the decision to use SQL. I'm pretty sure the author would agree with that. I think the target audience is language designers and tool builders. The author is urging people to envision and build new better interfaces to interact with relational data.
- tqi 11mo agoMost of these arguments against seem like personal preferences? For example, I understand it would be convenient to give special treatment to foreign key joins, but i personally find `fk_join(foo, 'bar_id', bar, 'quux_id', quux)` less easy to understand on it's own, without having to look up the underlying table structures to know which tables have which (ie is quux_id a column in foo or bar?). Not to mention I've never worked anywhere where foreign keys were consistently used, mostly for perf reasons.
- thom 11mo ago[flagged]
- throwaway894345 11mo agoSQL itself doesn't generate any value, relational databases generate value. SQL is just a frontend for them. Anyway, your snark could be applied to _literally any change_. Are you angry that cars are replacing horses? "Horses generate such incomparable value that there's a steady supply of pro-car posts, like fumes from the vast ocean of their constantly boiling piss". Don't like the cotton gin? "Slave labor generates such incomparable value...". There's not really anything of substance in this kind of comment.
- thom 11mo agoIf, after 100 years of cars being available, everybody still rode horses and always got where they're going on time, and car people constantly blogged about it, this would be a great analogy.
- 3eb7988a1663 11mo agoI don't have a choice to use SQL. If I want to speak to a database, there is precisely one language available. Like Javascript on the web for so long.
- throwaway894345 11mo agoThis comment doesn’t make sense. There are 0 popular relational databases that support SQL and a dialect that addresses SQL’s shortcomings.
- lawrencejgd 11mo agoI think here applies very well this quote: All right, but apart from sanitation, medicine, education, wine, public order, irrigation, roads, the fresh-water system and public health, what have the Roman (SQL) ever done for us?
- layer8 11mo agoThis is mostly all true, but there is little incentive for RDBMS vendors to implement and maintain a second query language, in particular a shared cross-vendor one. Databases are the most long-lived and costly-to-migrate dependencies in IT systems, so keeping the SQL-based interface in parallel for a long time would be mandatory. This is compounded by the standardized SQL-centric database driver APIs like ODBC and JDBC. Despite the shortcomings of SQL, there is no real killer feature that would trigger the required concerted change across the industry.
- andai 11mo agoThe way I've heard this phrased is, for potential customers to justify switching to your solution, it can't be 10% better, it needs to be 10x better. (And on top of that they need to clearly perceive the value of Strange New Thing, and clearly perceive the relative lack of value of the thing they have been emotionally invested in for decades...)
- gavinray 11mo ago> This is compounded by the standardized SQL-centric database driver APIs like ODBC and JDBC. The criticality of JDBC/ODBC as a platform can't be understated. The JDBC API is the dominant platform for data access libraries. Compare number of drivers for JDBC, ODBC, go/sql, etc. Newer platforms like Arrow ADBC/FlightSQL are better-suited to high-volume, OLAP style data queries we're seeing become commonplace today but the ecosystem and adoption haven't caught up. https://arrow.apache.org/adbc/current/index.html https://arrow.apache.org/adbc/current/index.html https://arrow.apache.org/docs/format/FlightSql.html https://arrow.apache.org/docs/format/FlightSql.html
- HackerThemAll 11mo agoThis is mostly all b.s.
- blef 11mo agoFeels old when you see how it played out to become SQL for everything in the data ecosystem lately. Even though SQL as flaws, maybe a lot, it has one upside which is: it's so easy to onboard people on it, in the data ecosystem (warehousing etc.) it means that we can do way much stuff faster than before and hire less technical people, which is great
- deleted 11mo ago[deleted]
- pphysch 11mo agoI think "SQL" is fine, whatever, I'm used to working with multiple different query and programming languages and dialects. That includes the freedom to define abstractions over SQL that meet my personal needs. Standard SQL is not helpful, though. If that (failed) experiment was ended, database implementations would have even more freedom to explore superior syntax. Prescriptive language standards are a mistake.
- throwaway894345 11mo agoI like that SQL is a standard, and it's mostly "fine". Sure, I have to constantly read the man pages because there are half a dozen different ways to do fundamentally similar things, and there are subtle differences between each vendor, and I keep running into silly errors like trailing commas. But it mostly works. The stuff that is more painful is building any kind of interesting application on top of a database. For example, as far as I know, it's very hard to "type check" a query (to get the "type" returned by a given query). It's also hard to efficiently compose SQL. And as far as I know, there's no standard, bulletproof way to escape SQL ("named parameters" is fine when you need to escape parameters, but most of SQL isn't parameters). There's also no good way to express sum types (a "place" can be a "park" or a "restaurant" or a "library", and each of those have different associated data--I don't need a "has_cycling_trails" boolean column for a restaurant, but I do for a park). There are various workarounds, all deeply unsatisfying.
- grebc 11mo agoIn MSSQL you can select top 0 * into a temp table and retrieve all the usual column meta data. I’ve written basic custom report writer functionality using this technique that lets users(usually me the developer or a super user) do custom sanitised SQL selects. I assume similar functionality exists in all the different vendors databases.
- throwaway894345 11mo agoYes, you can obviously run queries to get that information, but you can’t do it statically very easily. > I’ve written basic custom report writer functionality using this technique that lets users(usually me the developer or a super user) do custom sanitised SQL selects. I’m not sure how having the column metadata helps you sanitize SQL.
- andai 11mo agoTake a drink every time you see a comment that didn't even open the article ;)
- qaq 11mo agoThing is it's good enough and extremely widely used. Given that there is close to 0 chance an alternative will take off.
- lelanthran 11mo ago> Thing is it's good enough and extremely widely used. The real problem is not that "it is good enough"; it's that SQL is still better than many of the newer proposals. I mean, sure, if newcomer tech $BAR was slightly better than existing tech $FOO, then maybe $FOO might be eventually replaced. What we are seeing is that the newcomers are simply not better than the existing $FOO.
- dalmo3 11mo ago404. ...Or is that the joke?
- gavinray 11mo agoI work at (what was previously known as) Hasura. Specifically: the connector bits that deal w/ translating Relational Algebra IR expressed as GraphQL nodes -> SQL engine-specific code. The author's comments about lack of standardization and portability might not get across just how nightmarishly different SQL dialects are. I might put together a list of some of the batshit-insane bugs we've run into, even between version upgrades of the same engine. I really think folks would raise an eyebrow if they understood just how much variance exists between implementations in what might be considered "common" functionality, and the sorts of contortions you have to do to get proper shims/polyfills/emulations.
- grebc 11mo agoIt’s not a small decision to switch database vendors. Worrying that your data query language works across multiple vendors DB’s is not a concern ever considered imho.
- nevertoolate 11mo agoWhat is the approach? Do you target a subset of sql which you compile onto or you have some runtime dynamic dispatch thing and fight for code reuse with the magic haskell tools?
- sema4hacker 11mo agoFor any language as large and complicated as SQL, it's easy to come up with a long list of design problems. The difficulty is designing something better, and then even more difficult than that is getting people to use it.
- jampekka 11mo agoMuch of the critique is that it's large and complicated because of bad design. "Because SQL is so inexpressive, incompressible and non-porous it was never able to develop a library ecosystem. Instead, any new functionality that is regularly needed is added to the spec, often with it's own custom syntax. So if you develop a new SQL implementation you must also implement the entire ecosystem from scratch too because users can't implement it themselves. This results in an enormous language."
- jaredklewis 11mo agoI would say that’s just another trade off though, in that extensibility and portability are invariably in tension. The article simultaneously complains that the SQL standard is not universally implemented (fair) and that SQL is not easily extensible (also fair). But taken together it seems odd to me in that if you make SQL very extensible, then not only will it vary between databases, it will vary between every single application. Also, the line between SQL and database feels a little fuzzy to me, but don’t a lot of postgresql extensions effectively add new functionality to SQL?
- jampekka 11mo agoThe point is that with a more expressive language new features could be added as libraries instead of changing the language itself. This is right before the paragraph I quoted: "In modern programming languages, the language itself consists of a small number of carefully chosen primitives. Programmers combine these to build up the rest of the functionality, which can be shared in the form of libraries. This lowers the burden on the language designers to foresee every possible need and allows new implementations to reuse existing functionality. Eg if you implement a new javascript interpreter, you get the whole javascript ecosystem for free."
- JaggerFoo 11mo agoSQL is great. I've used it to implement knapsack optimization for Daily Fantasy Sports at scale. I use it in Big Data tools and RDBMS. It's pervasive in data tech. Feel free to innovate and bring forth other RDBMS/Data query languages and tools, perhaps something may succeed and stick as long as SQL has. Cheers