Live data from Hacker News

NoSQL: The Baby and the Bathwater

brooker.co.za

51–59 of 59 posts

Re: NoSQL: The Baby and the Bathwater

#51
post #5

I don't like NoSQL databases. "NoSQL" should be manna from heaven. It may be impossible to create a less pleasant language than SQL. It isn't composable, it isn't internally consistent, it isn't easy to parse, it claims to be declarative but the ordering of the clauses is completely rigid, it fights every attempt at writing testable or maintainable code. It is hard to read. It is hard to programatically generate. Eve…

The note about composability annoys me. Does it have composability akin to functional programming languages? No. But SQL isn't a functional programming language. Never has been. It's the world's most popular 4th generation language. (Most popular high level languages are 3rd gen in case a reader was wondering.)

With the lens that SQL is a DSL for set theory and set transformation (which it is), composability takes the form of views, temp tables, and CTEs. Not what you're looking for? That's fine. But they 100% make SQL composable.

I take issue with saying it's inconsistent as well. Are there warts? Sure! Like any language. But fundamentally inconsistent from the lens of DSL for set theory and transformation? No.

Folks keep trying to make relational system access like their favorite programming language, and it's not going to happen. Are folks' favorite general purpose programming languages 4th gen languages with an emphasis on set theory and transformation? No? Then stop trying to shoe horn it on! It only leads to frustration. Embrace the set theory and 90% of SQL's issues don't register as issues anymore.

As for NoSQL like MongoDB as a Postgres extension, that's what jsonb and its related operators and functions are for. Seriously. to_jsonb(…) and jsonb_populate_recordset(…) are seriously under-appreciated. They're like rocket fuel for JSON processing. Of course you're also welcome to keep a jsonb column lying around to keep things "schemaless", but experience has shown that defining your data (with types) rather than allowing free-form blobs in your database is better in the long term. You obviously see this already by your trust statement with regard to coworkers. "Better" meaning more performant and easier to maintain.

Just like thinking "functionally" takes training and practice to grok when you've been object-oriented all your life, that "set theory" takes training and practice as well. And it's so worth it. Feels like a goddamn superpower sometimes.

Re: NoSQL: The Baby and the Bathwater

#52
post #5

I don't like NoSQL databases. "NoSQL" should be manna from heaven. It may be impossible to create a less pleasant language than SQL. It isn't composable, it isn't internally consistent, it isn't easy to parse, it claims to be declarative but the ordering of the clauses is completely rigid, it fights every attempt at writing testable or maintainable code. It is hard to read. It is hard to programatically generate. Eve…

PRQL: a simple, powerful, pipelined SQL replacement https://news.ycombinator.com/item?id=34181319 Also: https://github.com/ajnsit/languages-that-compile-to-sql

On the one hand, FROM first makes conceptual sense. On the other, it doesn't offer anything significantly better than SQL. Is it marginally more terse? Yes. Is terseness paramount in a database manipulation and transformation language? I'm not convinced.

Re: NoSQL: The Baby and the Bathwater

#53
post #12

Earlier quoted context omitted.

Very little CPU depending on sorting, indexes, etc... Have a lot of indexes on a collection? Mongo will eat 5-10ms of CPU time per query even with cached query plan stats just to start executing the query. So no different than PG here. What you're getting at is Joins, but I haven't seen a company that didn't end up doing joins with Mongo at some point. Or, they do it in the app layer, in Java/Node/PHP which requires…

But you are describing incorrect ways of using NoSQL. NoSQL requires getting the schema right from the get go. Many people don't like it because they are used to relying on SQL (or a language like you mentioned) to smooth things out. NoSQL requires you to ask yourself hard questions - what specific queries are going to consume this data and then model the data as opposed to in SQL where you just store the data and wo…

Differing structures don't necessarily require more compute to query.

Anyway this is a weird argument. Ideally you get your schema right from the get go no matter the DB, of course things will be easier. But we don't. That's why we have migrations. Also, what's right today, might not be after acquiring Jonny Big Corp.

The whole point of NoSQL is to dump documents into it, of varying structure, and query/index them as-needed.

Re: NoSQL: The Baby and the Bathwater

#54

Earlier quoted context omitted.

That's interesting. A lot of your suggestions are actually exactly the same for SQL based databases. If your schema is not fit for the task at hand, it can slow it down by an order of magnitude, and the process of changing schema is also similar. Though, i would think, a properly designed SQL database would need such full schema refactoring less often, since adding a few tables within the same structure is easier. It…

Efficient joins in NoSQL are done by persisting the relation in a brand new entity. Thus they only make sense when the query is really and constantly needed, not when one is writing up SQL, researching, creating a custom report, etc. NoSQL DBs take large volumes of data, little CPU, and almost no RAM SQL DBs take lower volumes of data, loads of CPU and RAM Storage is cheap, CPU is expensive, hence NoSQL is cheap. Eve…

> Efficient joins in NoSQL are done by persisting the relation in a brand new entity. Thus they only make sense when the query is really and constantly needed, not when one is writing up SQL, researching, creating a custom report, etc.

This is also a common approach for SQL based databases when low latency is needed for common queries.

> SQL DBs take lower volumes of data, loads of CPU and RAM

That depends on the schema and the queries being run on them. Large amounts of CPU is really only needed if there are either 1000s of queries per second or large joins. RAM is very useful for hash joins with medium sized tables (up to a few millions of records). It has some utility for caching indexes or tables that need lower latency than the IO can provide, but that's similar to most NoSQL that I'm familiar with.

Most RDBMS's also come with ACID support, which has a significant cost (especially when writing). That has little to do with the SQL language, though. Spark tends to run on SQL without paying those costs. (More about this in the OA)

> Even when your project is not in the 100 of milions records this can be significant because you then are able to offer a cheaper product than the competition's

For small databases (For large tables (100 million to 10 billion records), good schema design and well written queries may be needed for SQL to perform, but that's not that different from what you're saying about NoSQL. Still, as you approach the upper end of this range, the compromises in needed with regards to denormalization, slack transaction management, etc may come at the cost of eliminating many of the advantages of traditional RDBMS's (such as consistency enforced by the schema definition through normalization and integrity constraints).

More than 10 billion, and traditional RDBMs start to break down, of course (you may need a cluster, and you may need to use sharding or similar methodologies from NoSQL / Big Data or similar paradigms, even if technically still on a RDBMS).

For small-medium sized databases (Btw, I'm not saying that other kinds of databases don't have their place, especially for various types of unstructured data, document oriented data or situations with extreme volumes or throughput requirements. 20 years ago RDBMS's were certainly overused. But 5-10 years ago, the pendulum had swung a bit in the other direction, imo.

A lot of devs that left college around 2010 seems to have jumped on NoSQL databases less because of their strengths than because of how they enabled the devs to trivially persist object oriented data structures with a line or two of code, and because they'd never learned how to use traditional RDBMS's properly.

This is fine as long as they don't need the kind of data consistency features provided by relational data models, but when consistency is needed, it tends to cause unnecessary problems. (Especially as a system ages, dev teams and application logic evolve.)

The reason I started my previous message with "That's interesting", is that your approach to NoSQL clearly shows you have a mature approach to NoSQL, as opposed to those who consider it a silver bullet that makes all complexity go away.

Anyway, it seems that a good design, suitable both to the problems at hand and the technology chosen/available is a universal in the field. Usually more important than specific tech choices.

Re: NoSQL: The Baby and the Bathwater

#55
post #28

Earlier quoted context omitted.

Yup. I've got a (legacy) postgresql database with time series: one timestamp plus measurement per row. And there's a useless third column too. It's awful, and sluggish. For a newer project, where we basically use one object, I've chosen a NoSQL database. Get the object, edit it in the browser, put it back. Done. No need to update relations, ORMs or any of that. But: that won't fly for more complex projects. So I agre…

Hi tgv, curious to hear why you picked NoSQL for your time-series use case?

It's not a choice that's guaranteed to suit your use case, but storing a time series as a large set of rows is not performant. Perhaps I should have mentioned that our time series data is "write once": we record and store it, but it doesn't get altered. And the time series are all sent to the browser, which does the displaying, filtering and analyzing, so there's no point in processing (our particular) time series in SQL, if that were even feasible. So, basically, because it is good enough, and better than the available alternatives.

Re: NoSQL: The Baby and the Bathwater

#56

Earlier quoted context omitted.

That's interesting. A lot of your suggestions are actually exactly the same for SQL based databases. If your schema is not fit for the task at hand, it can slow it down by an order of magnitude, and the process of changing schema is also similar. Though, i would think, a properly designed SQL database would need such full schema refactoring less often, since adding a few tables within the same structure is easier. It…

Efficient joins in NoSQL are done by persisting the relation in a brand new entity. Thus they only make sense when the query is really and constantly needed, not when one is writing up SQL, researching, creating a custom report, etc. NoSQL DBs take large volumes of data, little CPU, and almost no RAM SQL DBs take lower volumes of data, loads of CPU and RAM Storage is cheap, CPU is expensive, hence NoSQL is cheap. Eve…

RAM depends on your working set, right?

I maintain clusters with 50+ machines with 128gb+ of RAM...

Re: NoSQL: The Baby and the Bathwater

#57

Earlier quoted context omitted.

Efficient joins in NoSQL are done by persisting the relation in a brand new entity. Thus they only make sense when the query is really and constantly needed, not when one is writing up SQL, researching, creating a custom report, etc. NoSQL DBs take large volumes of data, little CPU, and almost no RAM SQL DBs take lower volumes of data, loads of CPU and RAM Storage is cheap, CPU is expensive, hence NoSQL is cheap. Eve…

> Efficient joins in NoSQL are done by persisting the relation in a brand new entity. Thus they only make sense when the query is really and constantly needed, not when one is writing up SQL, researching, creating a custom report, etc. This is also a common approach for SQL based databases when low latency is needed for common queries. > SQL DBs take lower volumes of data, loads of CPU and RAM That depends on the sch…

Hard to disagree

I get that many devs are using NoSQL in a careless way that produces horrors. I just don't think that is NoSQL's fault, hence I dislike comments critizicing NoSQL DBs. I am an efficiency (mostly in $ terms) freak, so I really love how NoSQL avoids the pitfalls of SQL (CPU and RAM usage - plus licenses if paid). That makes my take subjective

Re: NoSQL: The Baby and the Bathwater

#58
post #20

Earlier quoted context omitted.

I'm so glad this sentiment is being spread more. So tired of explaining that when I complain about SQL I *emphatically do not mean relational databases in general*, only to have everyone counter with "but relational stuff is good!"

Your argument seems a bit childish to me. Like you never really cared to learn the tool. SQL is relational algebra. Sure you can write it some other way. Lots of projects tried, none succeeded. Wonder why is that? End of the day - if you just learn the syntax, the hard part will be in the logic. As it should be.

I can't tell if you are being sarcastic or not.

In case you aren't: I didn't state my argument at all. Unless you dug through my comment history to find my complaints. This is precisely the kind of nonsense you get in response to even stating that you dislike the language.

> SQL is relational algebra. Sure you can write it some other way.

The same applies to general purpose programming languages, yet they have improved immensely since COBOL.

> Lots of projects tried, none succeeded. Wonder why is that?

Because of inertia, the mixed userbase of SQL, and ORMs and things like LINQ. The fact that most projects avoid direct use of SQL when possible is telling enough on its own.

Re: NoSQL: The Baby and the Bathwater

#59
post #5

I don't like NoSQL databases. "NoSQL" should be manna from heaven. It may be impossible to create a less pleasant language than SQL. It isn't composable, it isn't internally consistent, it isn't easy to parse, it claims to be declarative but the ordering of the clauses is completely rigid, it fights every attempt at writing testable or maintainable code. It is hard to read. It is hard to programatically generate. Eve…

How about EdgeDB? Never used it, but I found it when looking for a similar thing to you after reading this article. It's built on top of PostreSQL, uses it as a storage engine and provides a NoSQL interface to it. It calls itself a "graph-relational database."
Post reply on HN