6 ms·
SQL should go away, though. It is an astonishingly poor method of communicating your query to the database server. Generating and parsing it is problematic and
by jeffbee 6y ago
SQL should go away, though. It is an astonishingly poor method of communicating your query to the database server. Generating and parsing it is problematic and expensive. It really has nothing going for it, except that a lot of people already know it.
- not_knuth 6y agoInteresting. I've never seen SQL as a limiting factor, since 99% of the cases I use I just need to get something by it's id or a simple query (select, join, where, order). And it's really easy to learn too. I've seen many people without coding background pick it up and this is definitely a bonus where I work. Otherwise that 1 CS/Data Science guy is pre-occupied with hammering out queries for everyone. What kind of limitations do you run into? And what alternative do you propose (besides GraphQL)?
- jakear 6y agoNot the parent, but I quite like the Kusto query language. It’s Microsoft specific, but the overall concept is nice and could be implemented more broadly. The operations are described as a pipeline, which to me is much more readable (and writable!) than SQL, where it feels like I’m always bouncing my mental cursor around to figure out what a query is doing. I’m sure that’d reduce with more SQL exposure, but understanding Kusto came pretty much instantly for me. Also, each operation being its own line in the pipeline makes modification an absolute breeze, simply comment out, reorder, etc lines and the result will usually also be a valid query. https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/tutorial?pivots=azuredataexplorer https://docs.microsoft.com/en-us/azure/data-explorer/kusto/q...
- iudqnolq 6y agoKusto looks very similar to the Ecto DSL for SQL queries (elixir library). I really like the pipeline operation, I wish more languages added it. https://hexdocs.pm/ecto/Ecto.Query.html#module-macro-api https://hexdocs.pm/ecto/Ecto.Query.html#module-macro-api
- elygre 6y agoI was reading the same parent post, also thinking about kusto! It really is very nice. It would be super interesting to see how it would fit on top of Postgres or Oracle.
- edmundsauto 6y agoSQL is pseudo-readable by people like PMs, non-technical analysts, marketing, customer success, etc. As a test: I just showed my non-technical wife the following snippet of SQL, and she was able to tell me what it retrieved, as well as modify it to find a different player or statistic. SELECT player_name, COUNT(*) as num_hits FROM baseball_players WHERE result='base_hit' GROUP BY 1;
- chihuahua 6y agoI think your COUNT(*) is just going to be 1 unless you add a GROUP BY to your query.
- edmundsauto 6y agoUpdated, thank you!
- jakear 6y agoPretty telling for the “look SQL is so easy!” example to have a bug.. :) As mentioned in a sibling comment, Kusto Query Language^1 is potentially more readable here: > SELECT player_name, COUNT(*) as num_hits FROM baseball_players WHERE result='base_hit' GROUP BY 1; baseball_players | where result=‘base_hit’ | summarize num_hits = count() by player_name | project player_name, num_hits 1: yes this is msft specific, yes I work at msft, no not on that team. Just a happy user. The point is the overall pipeline concept more than msft’s specific implementation. https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/tutorial?pivots=azuredataexplorer https://docs.microsoft.com/en-us/azure/data-explorer/kusto/q...
- deleted 6y ago[deleted]
- ethbr0 6y agoThe biggest benefit to anything approaching pipelining is making data-interactive developers think about intermediate and transient state. In my enterprise coding experience, most app developers don't thing of db's as anything other than "one, current state." Which makes debugging a nightmare.
- sharadov 6y agoWhat in your opinion is a better way of communicating with the database other than SQL?
- snuxoll 6y agoI mean, having a sane protocol designed for use by applications rather than humans would be nice. It’s not that SQL is bad, it’s that mechanically generating it is wrought with peril, gotchas, and a huge mismatch between the code we write to work with the data we retrieve from these sources. Hell, s-expr’s would be a much better format and would require little implementation work.
- ethbr0 6y agoHow would s-expr's be a better format? (My lisp exposure is minimal)
- snuxoll 6y agoFor an application level interface they make sense - they’re trivial to generate and parse in any language, don’t require expensive bespoke parsers and lexers to be written, and the basic constructs are more appropriate for a query interface than something like JSON or other common serialization formats while still being human readable if needed. Again, SQL isn’t a terrible language - it’s just not designed to be mechanically generated in a sane manner. Libraries like jOOQ are useful because they handle a lot of pitfalls with runtime-generated queries, when we could avoid them altogether by having a better way of applications (rather than users) to query and manipulate data.
- jeffbee 6y agoI’ve seen a -lot- of engineering time spent trying to adapt to transient quirks of sql query planners, where the programmer expected a filtered range scan and the database elected for a materialized temp table, or similar disasters. Each and every one of those people would have been better served if they could have just specified the op tree that they wanted to be executed.
- jeff-davis 6y agoOver the course of SQL's existence, how many entire programming languages have built up entire ecosystems? It doesn't make sense that people would upend their language stack every ten years, but then be afraid to learn a new query language. Most developers need to know their programming language deeply; but not necessarily the query language, which might be hidden behind an ORM anyway. In theory, at least, changing the query language would disrupt fewer people than, say, moving from C++ to .NET or Perl to Ruby or Python to Go.
- nicoburns 6y agoI would be very willing to change query langauges. Problem is there's nothing that conpetes with SQL that offers even close to equivalent functionality.
- z3t4 6y agoSQL is very expressive compared to rolling your own map reduce. And SQL databases has a lot of optimizations. That said, accessing the data array directly is often easier and faster.