News for hackers. Stuff that matters.
Re:Why you should never use MongoDB (2013) by chatmasta on Monday August 15, 2016 @11:09AM (#12290931)
My first introduction to databases was with PHP/MySQL, where normalization was the name of the game. The whole point of normalization is that there is no duplication of data anywhere. If it's possible for duplicate data to exist, that's a symptom of a design flaw in the schema.

I've been using Mongo recently, and every time I raise criticism of it, the counterargument I hear is "forget about normalization! Duplication is okay."

Like the author, I really cannot wrap my head around this. While I understand that duplicating documents across collections may make querying faster, what about when you want to change the document? You need to propagate the change across every duplicate of the document in every collection where it exists. This means that any "de-duplication" logic needs to happen at the application level, rather than the database level.

Parse.com provided an interesting abstraction around that with "cloud code" and beforeSave and afterSave triggers. To maintain consistency, they encourage propagating updates to a document within its collection's beforeSave function. So if a document changes in one collection, you write code to change all instances of the document in other collections. That's nice in that it almost feels like you're writing the dedeuplication logic in the database layer, because you can view the "beforeSave" and "afterSave" functions as extensions of the schema. As long as those functions are up to date, the schema and any pseudo-linked documents will stay up to date.

But I really don't buy it. The strengths of mongo encourage a design that necessitates complexity for any significant write operation.

I think the real issue is that "if you have a hammer, everything looks like a nail." Mongo and other NoSQL stores have some real use cases, but people who are more familiar with Mongo than RDBMS are too trigger happy to employ it as a solution to problems where a RDBMS is the clear solution.

Re:Why you should never use MongoDB (2013) by manyxcxi on Monday August 15, 2016 @11:39AM (#12291153)
This is a problem I've had to explain to too many developers recently. It's not faster just because you throw away data modeling practices and jam bits of info all over the place.

If you have semi normalized data relationships, Mongo really doesn't fit the bill that well as your primary data store.

Where it shines is when you've got computed pieces of data to display (parts of a user data feed for example, data for a live graph, etc), you want to quickly store some data to be processed later (analytics, event processing), or you just use it as an object cache for expensive queries.

I have found that with a decently tuned DB, and I mean barely tuned, a decent data model, and sane fetching strategies (don't eager load everything always), a database can be good enough for quite a while, if not forever.

The answer I pretty much always get from people when I ask, "Why did you start with (whatever NoSQL they chose)?" Is, "Because (whoever) said it's faster and scales better."

I think younger devs that have options besides relational DBs find the barriers to entry on NoSQL lower (it looks mostly like how it went in and it's just JSON) so they pass over the learning SQL and basic data normalization fundamentals.

Re:Why you should never use MongoDB (2013) by catnaroek on Monday August 15, 2016 @01:13PM (#12291773)
> find the barriers to entry on NoSQL lower

Not having to think rigorously about the logical structure of your data is a huge selling point for many. For programmers, because it means they don't have to think. And for employers, because it means they can make do with programmers who don't want to think.

Re:Why you should never use MongoDB (2013) by sangnoir on Monday August 15, 2016 @05:09PM (#12293478)
> Not having to think rigorously about the logical structure of your data is a huge selling point for many

I'll play the devils advocate: what ever logical structure of the data you come up with will not line-up with relational DB tables - I have had the pleasure of designing relational schemas for cyclic graphs. Hell, we have been trying and failing to do Object-Relational Mapping for years now, and it's still a shit-show. I could name a long list of ORM libraries and an even longer list of their various deficiencies.

Say you've thought rigorously about the logical structure of your data and v1 is out, and now a change comes along and you need an extra field or 5. Renormalize your structure, write some migration scripts (in both directions, just in case you want to downgrade). With NoSQL I'll just dump the new document structure and call it a day (or rather, deal wiht the differences in the application layer).

Re:Why you should never use MongoDB (2013) by catnaroek on Monday August 15, 2016 @05:29PM (#12293610)
I suspect you read too much into my comment. I wasn't making a value judgment. If anything, I'm actually in favor of thinking no more than necessary to get high-quality results - but also no less than that.

> I'll play the devils advocate: what ever logical structure of the data you come up with will not line-up with relational DB tables

That contradicts my experience. The relational model isn't a panacea, but it lets me model most scenarios adequately. Whenever the relational model is deficient, what I want is more powerful schemas (sum and product tables, constraints spanning several tables, etc.), not less.

> Hell, we have been trying and failing to do Object-Relational Mapping for years now, and it's still a shit-show.

I'm inclined to think the problem is actually at the object-oriented end of the bridge: https://news.ycombinator.com/item?id=11861520

> With NoSQL I'll just dump the new document structure and call it a day (or rather, deal with the differences in the application layer).

Correctly managing these differences without help from schema-aware tools is rather painful.

Re:Why you should never use MongoDB (2013) by 20years on Monday August 15, 2016 @01:22PM (#12291838)
That is a scary thought.
Re:Why you should never use MongoDB (2013) by catnaroek on Monday August 15, 2016 @05:44PM (#12293716)
It isn't that scary once you take into account the fact that our brains are just as finite as any other resource available to us. It's a virtue not to make more mental effort than what is strictly necessary to complete the task at hand.
Re:Why you should never use MongoDB (2013) by 20years on Monday August 15, 2016 @05:49PM (#12293755)
I agree with "It's a virtue not to make more mental effort than what is strictly necessary." but to have an environment with only "programmers who don't want to think" is not appealing at all to me. I personally want to be surrounding by thinkers.
Re:Why you should never use MongoDB (2013) by pbreit on Monday August 15, 2016 @04:39PM (#12293235)
Only scary if you are locked into the past and/or closed-minded. (disclaimer: I'm not a mongo fan).
Re:Why you should never use MongoDB (2013) by 20years on Monday August 15, 2016 @05:42PM (#12293703)
I was mainly referring to "And for employers, because it means they can make do with programmers who don't want to think."

Sorry, but I don't want to work in an environment where programmers don't want to think or don't have to think. That is a scary thought. Has nothing to do with being locked into the past or being closed-minded. Just the opposite actually.

Re:Why you should never use MongoDB (2013) by emp_zealoth on Monday August 15, 2016 @06:40PM (#12294044)
How else do you think we arrived at webpages that need hundreds of MB of RAM?
Re:Why you should never use MongoDB (2013) by jt2190 on Monday August 15, 2016 @12:41PM (#12291557)
I agree with you, but would like to add that by using SQL to query a relational database it is very, very easy to denormalize the data that is copied into an application, so while a relational schema is essentially "static", query results are very dynamic, and can easily strip away all of the "goodness" that results from a normalized data structure.

In other words, the application probably needs to deal with normalization and schema if it's taking copies of data, and using a relational database doesn't remove this requirement. (Of course, small applications often get away without enforcing schema, with the understanding that frequent database write failures due to malformed data are ok.)

Re:Why you should never use MongoDB (2013) by DashRattlesnake on Monday August 15, 2016 @05:36PM (#12293665)
> The answer I pretty much always get from people when I ask, "Why did you start with (whatever NoSQL they chose)?" Is, "Because (whoever) said it's faster and scales better."

Pretty much the classic http://www.mongodb-is-web-scale.com/?

Re:Why you should never use MongoDB (2013) by phamilton on Monday August 15, 2016 @11:28AM (#12291086)
While not a fan of mongoDB for many reasons, any sufficiently large scale application will have denormalization. Caching layers cause all sorts of cache invalidation bugs because of this exact problem. Indexes, while often managed by the DB, are essentially denormalization. One could even argue that syncing data between a client and server is a class of the same problem.

My point is that we deal with these problems out of necessity. If you don't get a ton of traffic, then sticking with a normalized RDBMS is probably best. However, large scale systems will have redundant logic. Generic solutions (letting the normalized DB do the work) will often be slower than specific ones (denormalizing your schema and moving logic into the application layer). These are pretty simple principles that I've seen on almost every large-scale application I've worked on.

Re:Why you should never use MongoDB (2013) by tremon on Monday August 15, 2016 @01:05PM (#12291721)
Indexes are not an example of denormalization. Normalization means that there is one canonical element that describes an object, not that there's only one copy or representation of that element.
Re:Why you should never use MongoDB (2013) by kolme on Monday August 15, 2016 @01:13PM (#12291778)
Indexes are basically a copy of the original data, only sorted in the right order.

They are denormalized data, sort of.

Re:Why you should never use MongoDB (2013) by hobs on Monday August 15, 2016 @01:24PM (#12291861)
Indexes are often only a pointer to that data, and they are not denormalized, they are better described as projections of your data (this way saving the work of ordering/filtering on that same projection in the future.)
Re:Why you should never use MongoDB (2013) by kolme on Monday August 15, 2016 @01:40PM (#12292001)
Yes, they are pointers. But the indexed fields have to be duplicated for efficient reading. From Wikipedia:

"An index is a copy of select columns of data from a table that can be searched very efficiently that also includes a low-level disk block address or direct link to the complete row of data it was copied from." [1]

When you reference a field in an index, you're effectively duplicating this column on disk.

We can discuss semantics, but at the end of the day, indexes are glorified copies of your columns in a specific order.

[1] https://en.wikipedia.org/wiki/Database_index

Re:Why you should never use MongoDB (2013) by throwanem on Monday August 15, 2016 @01:27PM (#12291882)
Not only that, they're projections which you don't have to spend effort on keeping up to date, and which the engine automatically uses to optimize your queries. While there's an argument to be made that the same can be accomplished in a non-relational database with suitable application code or a translation layer, all else equal it's better not to need those things in the first place.
Re:Why you should never use MongoDB (2013) by phamilton on Monday August 15, 2016 @02:46PM (#12292525)
And as we saw from a recent Uber post about Postgresql, that automatic updating is not actually free.
Re:Why you should never use MongoDB (2013) by throwanem on Monday August 15, 2016 @04:04PM (#12292995)
Of course it's not, but if you're not Uber, that almost certainly isn't a problem for you. When you use MongoDB, you get to roll your own indexes no matter who you are.
Re:Why you should never use MongoDB (2013) by hobs on Monday August 15, 2016 @03:55PM (#12292938)
Was going to say the same, but I realized the OP was talking about in your code, not so much as overhead.
Re:Why you should never use MongoDB (2013) by tremon on Monday August 15, 2016 @01:37PM (#12291966)
Are you suggesting that RAID-1 and RAID-5 are also examples of denormalized data, sort of?
Re:Why you should never use MongoDB (2013) by kolme on Monday August 15, 2016 @01:49PM (#12292070)
Not really, for two reasons:

- It's done at the hard disk level, so no database or data schema is involved.

- It's not done for performance reasons, but for security reasons (not to lose any data).

"In computing, denormalization is the process of trying to improve the read performance of a database, at the expense of losing some write performance, by adding redundant copies of data or by grouping data."

It's a technique that involves copying data for some very particular reason, an abstraction to hide the nasty duplication because the desirable thing is to have only one source of truth.

So while there's some remote similarity (the copying of data), the goals are completely different.

Re:Why you should never use MongoDB (2013) by jdmichal on Monday August 15, 2016 @02:24PM (#12292351)
A good RAID controller exactly fits your included quote. It will speed up reads by distributing to all disks, but writes will be slower because they have to be written to all disks before the controller will signal the write as completed.
Re:Why you should never use MongoDB (2013) by spikej on Monday August 15, 2016 @02:17PM (#12292296)
What you're really after is materialized/indexed views, or having the NoSQL DB be a layer after your primary DB...
Re:Why you should never use MongoDB (2013) by nurettin on Monday August 15, 2016 @11:49AM (#12291206)
If you excuse the buzzword, data warehouses are built for this very reason. So you are right in the sense that cache invalidation and denormalization are problems in sql based large scale systems, but they are largely solved problems whereas in mongodb you would need to do this work manually.
Re:Why you should never use MongoDB (2013) by dozzie on Monday August 15, 2016 @12:42PM (#12291562)
> [...] data warehouses are built for this very reason. [...] [cache invalidation and denormalization] are largely solved problems [...]

Uhm, no. Data warehouse is not a database with operational (i.e. current) data, it's a database with historical data. If it is out of sync with production for a day or a week, it's totally OK, depending on its design.

So no, cache invalidation is not a solved problem there.

Re:Why you should never use MongoDB (2013) by nurettin on Tuesday August 16, 2016 @04:58AM (#12296274)
I've worked with data warehouses which were replicated like a multimaster, YMMV.
Re:Why you should never use MongoDB (2013) by herdrick on Monday August 15, 2016 @02:39PM (#12292474)
dozzie, could you remove the "Uhm, no." from that? It only adds snark to an otherwise good comment.
Re:Why you should never use MongoDB (2013) by lmm on Monday August 15, 2016 @12:24PM (#12291459)
> Like the author, I really cannot wrap my head around this. While I understand that duplicating documents across collections may make querying faster, what about when you want to change the document? You need to propagate the change across every duplicate of the document in every collection where it exists. This means that any "de-duplication" logic needs to happen at the application level, rather than the database level.

You're assuming that you need to change things. Almost all big-data approaches work better when you abandon that and go for a log-structured model where you only ever append.

> I think the real issue is that "if you have a hammer, everything looks like a nail." Mongo and other NoSQL stores have some real use cases, but people who are more familiar with Mongo than RDBMS are too trigger happy to employ it as a solution to problems where a RDBMS is the clear solution.

True enough, but I think the converse is more true. If you're using a traditional RDBMS you're accepting a big series of constraints in exchange for functionality you often don't use. Indices are updated synchronously on every insert, slowing your writes, for the sake of transactional guarantees that most applications aren't written to take advantage of. Queries have to be passed over the wire as strings, so your application will spend a significant chunk of its time building them (hopefully using a library without vulnerabilities to send them over the wire so the database can spend a significant chunk of its time parsing them), or else you get to deal with the db-specific and per-connection quirks of prepared statements, for the sake of supporting ad-hoc querying in a language that frankly isn't great for humans. Tables, materialized views and the like occupy this awkward in-between condition where it's not clear whether you're supposed to create and modify them ad-hoc (and manipulate them programatically) or not; if you really do need to do ad-hoc reporting then they're what you want, but often the performance implications of that make it unacceptable to do in production.

I don't think a lot of cases are good fits for RDBMS. If you don't need ad-hoc reporting then you're better off building a data processing pipeline where you produce your results directly rather than the sort of semi-aggregating you end up with with an RDBMS. If you don't need full ACID then it's not worth paying the performance cost of it. And I don't know why there aren't RDBMSes without better query languages and schema definition languages, but there aren't.

Re:Why you should never use MongoDB (2013) by breischl on Monday August 15, 2016 @03:02PM (#12292633)
>>Queries have to be passed over the wire as strings, so your application will spend a significant chunk of its time building them... or else you get to deal with the db-specific and per-connection quirks of prepared statements...

Or you could use stored procedures. Think of it as making your RDBMS into a microservice, if you like.

>>I don't know why there aren't RDBMSes without better query languages and schema definition languages Huh... I always thought SQL was pretty straightforward for most cases. It only gets really arcane when you get into advanced cases (eg, recursive queries) and/or vendor extensions. It does take a bit of a mental shift, but no more so than imperative-style to functional-style, IMO.

There are certainly tradeoffs to using an RDBMS. But I think a lot of people jump to the conclusion that they have a big-data situation when they really don't. I also think a lot of people underestimate the value of very easy ad-hoc querying and already-solved backup/restore.

Re:Why you should never use MongoDB (2013) by lmm on Monday August 15, 2016 @03:36PM (#12292834)
> Or you could use stored procedures. Think of it as making your RDBMS into a microservice, if you like.

The trouble is testability, versioning, deployment, and SQL just not being a pleasant language for expressing business logic. And the lack of a library ecosystem. And poor IDE support. And...

Re:Why you should never use MongoDB (2013) by breischl on Monday August 15, 2016 @03:58PM (#12292956)
>>SQL just not being a pleasant language for expressing business logic

No kidding - don't do that. Sprocs are great to present a query interface and avoid sending queries over the wire every time. They can be handy to decouple the actual storage architecture from the query interface, so you can do tricky stuff in SQL without screwing up the clients. That doesn't mean you should stick your business logic in there.

>>testability, versioning, deployment... library ecosystem...

And how would any of those problems be solved by using raw SQL strings or a document DB? That just moves the problems back into the schema or the data, where it's even harder to deal with.

>>poor IDE support

So your code editor has a better IDE for SQL? Or are we talking about a document DB? I haven't seen any of them that were anywhere close to SSMS.

Re:Why you should never use MongoDB (2013) by lmm on Monday August 15, 2016 @04:29PM (#12293163)
> And how would any of those problems be solved by using raw SQL strings or a document DB? That just moves the problems back into the schema or the data, where it's even harder to deal with.

I'm arguing for using a non-SQL interface. Either a structured binary query protocol (which leaves you shipping a lot of data around sure, but at least removes the constructing-and-parsing SQL overhead), or a map-reduce style setup where you can run your queries where the data is but in a first-class programming language.

Re:Why you should never use MongoDB (2013) by breischl on Monday August 15, 2016 @04:41PM (#12293253)
It seems to me that you're advocating changing implementation details (binary query protocol instead of SQL, map-reduce queries instead of sprocs) and claiming that it is somehow fundamentally different. But I don't see how that would be the case.

How is a binary query protocol fundamentally different than calling a sproc?

How is a map-reduce job in Javascript any different on the attributes you mentioned than ad-hoc SQL or a sproc?

Obviously map-reduce is a fundamentally different approach to data processing, but it seems to have similar traits in regards to source control, testability, etc.

Re:Why you should never use MongoDB (2013) by lmm on Monday August 15, 2016 @07:02PM (#12294175)
Binary query protocol is just a tweak, but it's a tweak that most RDBMSes are missing, and it matters for some workloads.

Switching to a model where you supply your own map-reduce or pipeline is a real shift, I think, from the DB as a framework that manages querying for you to more of a library/toolkit you can use to write your own computations. The indexed tables model is an incredibly effective compromise, but it's still a compromise - if you know specifically what you need to do, you can do it better.

Running a first-class programming language with full support for usual programming language tools is a major difference for developability, testability, libraries and so on. Deployment model depends on the datastore - plenty of non-SQL ones have room for improvement here - but I think the traditional RDBMS still has the worst of it.

Re:Why you should never use MongoDB (2013) by breischl on Tuesday August 16, 2016 @04:42PM (#12300489)
Huh, interesting. I wonder if this is down to us having used different RDBMSes?

Most of my experience has been with SQL Server, which I think does use a (mostly) binary wire protocol, at least when calling sprocs. It also has a pretty good query optimizer - I've spent a lot of time trying to beat it with hand-tuned queries and only come up with something better about 50% of the time. And there are a lot of tools for source controlling the DB scripting and testing everything. It's not hard to do unit test style runs that set up and tear down tables and DBs.

Has that not been your experience?

Re:Why you should never use MongoDB (2013) by lmm on Wednesday August 17, 2016 @07:01AM (#12303726)
> which I think does use a (mostly) binary wire protocol, at least when calling sprocs

Hmm. I'm used to invoking storedprocedures via "select mysproc(param1, param2, ...)" which still has to be formed into a string and then parsed on the DB side using the arbitrary-SQL parser (because there's no way for the DB to know a priori that it's not a "regular" query). Does SQL server have some special case binary protocol for invoking them directly?

> It also has a pretty good query optimizer - I've spent a lot of time trying to beat it with hand-tuned queries and only come up with something better about 50% of the time.

The query planner can usually run the best query possible with the indices that exist, sure. But you have to fit your calculation into this model of indices that are built on insert and everything else happening at query time. Or you go down the route of lazy materialized views that make use of other lazy materialized views, specifying indexing strategies... I mean I think you can ultimately express any data processing pipeline in a RDBMS if you try hard enough (though you have to use database-specific features that tend to be less-well supported by the ecosystem), but at some point it's easier to just have a first-class programming language that has access to the data, and write the code that you want to run.

> And there are a lot of tools for source controlling the DB scripting and testing everything. It's not hard to do unit test style runs that set up and tear down tables and DBs.

Up to a point. It's easy to end up with "unit" tests that take a second for each test, which mean it's not really practical to get good coverage of logic there.

In terms of source controlling and so on I guess the big problem is that you now have a distributed system written in two quite different technologies. So you've got to figure out a release and deployment process that handles both, and a lot of shops don't seem to bother. If you're already running a multi-language microservice architecture then this is probably a lot less of an issue.

Re:Why you should never use MongoDB (2013) by breischl on Wednesday August 17, 2016 @10:18AM (#12304866)
TBH I've never really looked at how TDS (the SQLServer wire protocol) works. From a code level, in ADO.NET you would create a query object, set the type to "sproc", set the name of the sproc, and attach parameters as objects. I bet the sproc name is going across as text, and maybe the param names, but that's probably it.

>>So you've got to figure out a release and deployment process that handles both, and a lot of shops don't seem to bother.

Yeah, that's true. Setting up something along the lines of Rails' migrations isn't really that hard, but many don't bother.

Re:Why you should never use MongoDB (2013) by dragonwriter on Monday August 15, 2016 @04:04PM (#12292996)
> > Or you could use stored procedures. Think of it as making your RDBMS into a microservice, if you like.

> The trouble is testability, versioning, deployment, and SQL just not being a pleasant language for expressing business logic.

Most of those, to the extent they are valid, are trouble with using stored procs in SQL for that purpose, but most RDBMSs support stored procs in languages other than SQL.

Re:Why you should never use MongoDB (2013) by lmm on Monday August 15, 2016 @04:25PM (#12293138)
Testability, versioning, deployment, IDE support and library support are still very much issues with non-SQL stored procedures.
Re:Why you should never use MongoDB (2013) by gaius on Monday August 15, 2016 @02:26PM (#12292366)
Indices are updated synchronously on every insert, slowing your writes, for the sake of transactional guarantees that most applications aren't written to take advantage of. Queries have to be passed over the wire as strings

Those are implementation details, not inherent properties of the relational model.

Re:Why you should never use MongoDB (2013) by EpicEng on Monday August 15, 2016 @06:45PM (#12294088)
If they're pervasive then it's irrelevant. Looking at this stuff from a purely academic viewpoint isn't useful to people who care about implementation details.
Re:Why you should never use MongoDB (2013) by dragonwriter on Monday August 15, 2016 @03:06PM (#12292655)
> And I don't know why there aren't RDBMSes without better query languages and schema definition languages, but there aren't

Well, better is subjective, but there are RDBMSs with languages other than SQL (e.g., Dataphor with its D4 language.)

Re:Why you should never use MongoDB (2013) by jdmichal on Monday August 15, 2016 @02:27PM (#12292382)
> You're assuming that you need to change things. Almost all big-data approaches work better when you abandon that and go for a log-structured model where you only ever append.

That depends on your loads. If you're write heavy, then yes. If you're read heavy, then you're adding extra work to find the current row out of all the appends. If you're read and write heavy, then get used to buying really expensive beefy machines and maybe sharding...

Re:Why you should never use MongoDB (2013) by fragola on Monday August 15, 2016 @12:26PM (#12291479)
It's a trade-off. There are a lot of reasons to duplicate (faster reads, etc.), with the big drawback being consistency. The duplications are basically caches, with similar pros and cons.

I think a good solution is to use something like DynamoDB and use hot/cold tables. Like, if you're storing something high read/write (i.e. today's olympic stats), keep it in the hot table with a frequent cache timeout. Later, when they become yesterday's stats, move them to the cold table which will basically be read-only, with a longer valid cache.

The problem with MongoDB is that it discourages this type of data management, at least how I've seen it used.

Re:Why you should never use MongoDB (2013) by rogerdpack on Monday August 15, 2016 @12:38PM (#12291548)
If it's like Cassandra, then you can kind of get around consistency problems by, for instance if you have a "replication" factor of 2, by instructing it to write to "2 instances before returning" (and then you turn around and read it after that, if you want to double check). Though of course while it's writing to the first, then second replica, it'll be inconsistent, but not for too long :)
Re:Why you should never use MongoDB (2013) by mateo411 on Monday August 15, 2016 @04:05PM (#12292997)
Yes, that is the difference between strongly consistent and eventually consistent.
Re:Why you should never use MongoDB (2013) by fiatjaf on Monday August 15, 2016 @11:14AM (#12290977)
It has always seemed to me that the solution to the duplication/normalization dilemma is an approach that gets "normalized" data (not necessarily normalized in the sense that it is scattered among many tables, but in the sense that there is a single source of truth for each data point) and uses it to write materialized views, automatically and efficiently recomputed and stored for fast querying.

CouchDB does this to a certain extent, but its JSON-document approach is not appropriate enough.

Re:Why you should never use MongoDB (2013) by andybak on Monday August 15, 2016 @11:25AM (#12291065)
I've always looked on 'duplication' (or denormalization) as an optimization to be used sparingly when performance dictates.

Regarding it as essentially a form of caching has been helpful. In fact there is a spectrum that goes from simple caching to denormalized schema with many points inbetween.

Re:Why you should never use MongoDB (2013) by mamcx on Monday August 15, 2016 @03:17PM (#12292710)
Also this weird adversion against using the power of a RDBMS.

NO VIEWS! NO STORED PROCEDURES! NO TRIGGERS! YOU SQL MUST BE AGNOSTIC!

and stuff like that. However, they pick Mongo or anything like that and yep, they must use anything it provide just by necessity.

---

People:

Using views is easy. Is probably the most simple thing you can get to leverage what a DB can give (plus indexes) and let model the data in different ways and even help in transition from a data model and another.

Re:Why you should never use MongoDB (2013) by pmelendez on Monday August 15, 2016 @12:05PM (#12291320)
>"Like the author, I really cannot wrap my head around this. While I understand that duplicating documents across collections may make querying faster, what about when you want to change the document? "

That's a trade-off you have to analyze to see if it is worth it. If that data is not maintained often then is OK to have duplicated data. One thing you have to realize is that there is no a silver bullet in the CAP theorem and you always would give up something.

The other thing to realize is that not everybody needs a distributed database and most problems will live happily with an old-fashioned relational database.

Re:Why you should never use MongoDB (2013) by chaostheory on Monday August 15, 2016 @01:40PM (#12291993)
> "if you have a hammer, everything looks like a nail."

I don't like MongoDB either, but normalization is not the answer for every project. For some projects, reading efficiency is so important that people are willing to pay for of it in disk space, an increase in writing costs, and even app complexity.

Re:Why you should never use MongoDB (2013) by icc97 on Monday August 15, 2016 @02:07PM (#12292227)
Normalisation is a good starting point though. If you hit the limits of normalisation then you can always denormalise.
Re:Why you should never use MongoDB (2013) by chaostheory on Monday August 15, 2016 @06:54PM (#12294136)
It depends on the problem and current circumstances. Just because MongoDB doesn't work, it doesn't mean alternatives to relational DBs should be ignored.
Re:Why you should never use MongoDB (2013) by tracker1 on Monday August 15, 2016 @04:14PM (#12293063)
On the flip side... joins are expensive... I worked on an application, where presenting a single page, representing a single item in the application (classifieds site) required upwards of around 40 joins (iirc 36 or 46, I don't remember)... under load (including search result pages), the app was crushed by its' own weight.

I think the bigger issue is that people are afraid of separating data at clear boundaries, so long as the orchestration is in place. Having definitive data in SQL, and having denormalized documents in elasticsearch/mongo/rethinkdb works very well... other instances (huge read and/or write throughput) may work better in a Cassandra (or other bigtable solution) with application-generated lookup tables may be better. It just depends on your need.

With better support for JSON/XML nested structures and indexes in sql rdbms, it's becoming less of an issue for a lot of types of data/documents.

Re:Why you should never use MongoDB (2013) by pbreit on Monday August 15, 2016 @04:49PM (#12293309)
40 joins for a classified ad?
Re:Why you should never use MongoDB (2013) by tracker1 on Monday August 15, 2016 @06:11PM (#12293886)
"Normalized" It comes down to there being a lot of "options" for cars/trucks, and each type was a separate set of mappings (2-joins), etc... it could have been simpler and more flat, but it was excessively normalized to be "flexible".

Like I said, it was pretty crushing on the database... there were a lot of other expensive calculations that ran per request... pre-calculating, caching, and a few other things got some longevity, bit it was a tangled mess of a beast for what would have been 3-4 collections for a document database (mongodb, rethinkdb, etc).

Re:Why you should never use MongoDB (2013) by overcast on Monday August 15, 2016 @11:15AM (#12290991)
Have a look at RethinkDB, it's the best of MongoDB and MySQL with real time feeds. A relational document store.
Re:Why you should never use MongoDB (2013) by GoldenMonkey on Monday August 15, 2016 @12:17PM (#12291411)
There are two paradigms with databases. Normalization for high volume insert/update transaction requirements (faster writes). Denormalization for (faster reads), typically used for data warehouses and reporting.

NoSQL is designed to support both of these scenarios well. And with lower overhead requirements by not having to update a central store... It is used in particular for Big Data solutions. Rather than having to be optimized for one or the other as an RDBMS would require.

Re:Why you should never use MongoDB (2013) by dragonwriter on Monday August 15, 2016 @12:24PM (#12291466)
> Normalization for high volume insert/update transaction requirements (faster writes). Denormalization for (faster reads), typically used for data warehouses and reporting.

Normalization also better supports ad hoc inquiries and reporting compared to denormalization; denormalization is an optimization for regularized reporting patterns (responding to a question that a denormalized reporting design didn't anticipate often requires effectively renormalizing the data, which recovers the logical benefits of normalization, at a potentially very high performance cost.)

> NoSQL is designed to support both of these scenarios well.

Without the integrity benefits of normalization on updates, and without the benefits of normalization for ad hoc queries.

OTOH, there are very few uses of normalized RDBMSs where only the write performance benefits are sought -- usually at least integrity is a concern, and sometimes ad hoc querying as well.

Re:Why you should never use MongoDB (2013) by SeanDav on Monday August 15, 2016 @12:21PM (#12291445)
Not being optimized for a particular use case, makes it a poor choice for anything outside toy, or best case, medium sized applications.
Re:Why you should never use MongoDB (2013) by lmm on Monday August 15, 2016 @12:48PM (#12291604)
The point is you have the level of control that lets you optimize for your use case. RDBMSes are a jack-of-all-trades solution and have the advantage of needing very little customization, but they can't be as well-optimized for specific use cases.
Re:Why you should never use MongoDB (2013) by clifanatic on Monday August 15, 2016 @02:36PM (#12292453)
> "forget about normalization! Duplication is okay."

Not just duplication. I did some work on a platform that used ElasticSearch as a relatively relational "document" store (that is, a purpose to which a true RDBMS would have been better suited). Besides data duplication, we ran into the problem of data consistency: using the author's TV show example, we would end up with some actor's whose birthdates would be recorded, but some whose age was recorded instead. Some TV shows would list the actors by role, some would just list the actors and the roles in two different lists. Sometimes the TV show start and end dates would be milliseconds since the epoch, some would be dates in YYYY/MM/DD formatted strings. Some would be dates in DD-MM-YY formatted strings. All scattered randomly throughout the data store. Elastic schema means random schema.

Re:Why you should never use MongoDB (2013) by drivingmenuts on Monday August 15, 2016 @02:43PM (#12292506)
On the surface, that sounds more like a problem of data cleanup before insertion. Were you doing any validation/normaliztion of the data beforehand?
Re:Why you should never use MongoDB (2013) by clifanatic on Monday August 15, 2016 @03:34PM (#12292825)
> Were you doing any validation/normaliztion of the data

Of course we (they) were - lots of it! Just inconsistently...

Re:Why you should never use MongoDB (2013) by DankCorrector on Monday August 15, 2016 @12:04PM (#12291308)
Why does this comment feel like an ad?
Re:Why you should never use MongoDB (2013) by chatmasta on Monday August 15, 2016 @12:05PM (#12291317)
An ad for what, Parse.com? It doesn't even exist anymore, lol.