News for hackers. Stuff that matters.
Re:The growing irrelevance of MongoDB by collyw on Wednesday January 14, 2015 @03:49AM (#8885045)
I have seen many people try and shoehorn various problems into MongoDB, when in most cases a relational database would have been better suited.

I have yet to see a real use case for Mongo unless you are building a Facebook clone. Can someone suggest when it is actually useful over a properly tuned relational database?

I guess I kind of reached the irrelevance stage just thinking about the sort of problems it would be suited to rather than actually building anything.

Re:The growing irrelevance of MongoDB by phpnode on Wednesday January 14, 2015 @04:21AM (#8885160)
> I have yet to see a real use case for Mongo unless you are building a Facebook clone

People seem to keep making the mistake of building a social network in mongo. It's entirely unsuitable for that.

Source: I've helped 3 companies move their social networks from MongoDB to OrientDB when they figured out that MongoDB prevents them from shipping features that users expect, e.g. friend-of-a-friend style queries

Re:The growing irrelevance of MongoDB by filearts on Wednesday January 14, 2015 @08:57AM (#8886204)
What has your experience been like in deploying and working with OrientDB? This is a bit of really cool tech that I've been keeping an eye on for some time but haven't gotten around to really playing with it.

What server language were you using and where were you deploying?

Re:The growing irrelevance of MongoDB by phpnode on Wednesday January 14, 2015 @09:46AM (#8886505)
OrientDB is very cool software, I find it pretty hard to go back to traditional databases now that I've seen how powerful graphs are, but the cool thing about it is that it's still a document store at heart, so you get all the same advantages of mongo, but with the graph awesomeness on top. It's a fantastic tool, but there are a few quirks that can catch beginners out and the documentation is not stellar. It also requires some configuration tweaking to get the best performance for your workload.

I've been using node.js (I develop the official driver - https://github.com/codemix/oriento), but there's pretty good libraries emerging for other languages too. Most people I've worked with are deploying to AWS, one company was running on the bare metal.

Re:The growing irrelevance of MongoDB by filearts on Wednesday January 14, 2015 @10:41AM (#8886880)
I actually JUST discovered oriento and was absolutely delighted to see a bluebird promise-based api. API looks fantastic. Thanks a ton for creating the lib.

Do you have any advise for someone thinking of deploying on GCE?

My use-case would be for an online code editor (Plunker, if you've heard of it) with users, projects, packages, collections (of projects), comments and project versions (stored as content-addressable git-compatible objects).

I'm also interested in understanding if there is any built-in compression mechanism because I will be storing a large volume of very similar text files. Any hints?

Have you used the lucene indexes much? If so, can you do any of the crazy faceting delivered by ElasticSearch?

Re:The growing irrelevance of MongoDB by phpnode on Wednesday January 14, 2015 @11:33AM (#8887263)
> Do you have any advise for someone thinking of deploying on GCE?

No, sorry, I've never used that. However, generally - like all dbs, Orient is happiest when it has access to a lot of RAM. Also the Write Ahead Log can take up a significant amount of disk space, those are two things to be immediately aware of.

> I'm also interested in understanding if there is any built-in compression mechanism because I will be storing a large volume of very similar text files. Any hints?

Sadly it doesn't yet do leveldb style document compression, and I've seen no hints that it's on the horizon, but the OrientDB guys are pretty responsive and would probably be open to the suggestion.

> Have you used the lucene indexes much? If so, can you do any of the crazy faceting delivered by ElasticSearch?

I'm just starting to use the lucene indexes now so I can't give much feedback on those yet. It should be possible to do faceting using SQL to a limited degree, but I don't think there's native support for it yet. I think that will get improved in the next few versions because people are crying out for it.

Re:The growing irrelevance of MongoDB by filearts on Wednesday January 14, 2015 @12:18PM (#8887589)
Thanks a lot for your contributions to the node module and your answers.
Re:The growing irrelevance of MongoDB by proveanegative on Wednesday January 14, 2015 @12:55PM (#8887850)
Did they choose OrientDB instead of Neo4j for the license or for technical reasons?
Re:The growing irrelevance of MongoDB by phpnode on Wednesday January 14, 2015 @02:51PM (#8888573)
actually both in many cases, Neo4j does have quite a hostile license, but its biggest downside is that it is graph only, whereas OrientDB (and ArangoDB which is also worth looking at) are "multi-model" - you can use them as pure document (or even key / value) stores, and the graph is just another way of viewing / representing that data. This is really powerful and means that you don't have the problem of duplicating data between different database systems or needing to do cross-data-store joins in your application.
Re:The growing irrelevance of MongoDB by Harrisburg on Wednesday January 14, 2015 @03:59AM (#8885086)
Think of an Amazon like product catalogue.

I don't want to create a schema in a relational database for that kind of use case. A MongoDB fits as well.

Edit: Sorry for my short and unprecise comment. I regret posting it, loosing all my Karma. Yes, of course I would use a schema, but I may use hundreds to get my products presented with all attributes and variants available. There is a set of attributes that will remain for all products, others will vary, some will change and will be dropped. Some may be conditional, depending on size or color. I could model that in RDBMS as well, adding those properties in an additional JSON or something else.

Yes, I'm also mainly using relational databases and just wanted to give an example of a use-case for MongoDB. I regret, sorry.

Re:The growing irrelevance of MongoDB by ris on Wednesday January 14, 2015 @04:51AM (#8885272)
"I don't want to create a schema..."

You are always going to end up creating a schema, whether it's explicit in your tables or implicit within your code. Otherwise you end up with completely heterogeneous data which is impossible to query in any useful way.

This is a red herring.

Re:The growing irrelevance of MongoDB by woah on Wednesday January 14, 2015 @05:10AM (#8885356)
Not really. Maybe some products have an attribute that others don't. Maybe you want to query by that attribute. The query won't turn up products without that attribute. Maybe that's ok. Like if you wanted to find all shoes with black laces you can just query for that. Tractors don't even have laces and so they don't come up in the results.

In a sql db, every single thing needs to fit into a flat schema with nesting done by relations. Additionally, it's very rigid. Maybe you just don't want to set up a laces table, and 4000 other tables for every little attribute of every product. Of course this is not how you would do it in real life, there are better ways. Mongo is one of those ways.

Saying that Mongo is good for nothing is just as dumb as saying that Mongo is good for everything. In 2015, the Mongo backlash is just as tired as the Mongo hype.

Re:The growing irrelevance of MongoDB by xerophyte12932 on Wednesday January 14, 2015 @07:56AM (#8885900)
I would probably solve this problem using Relational DB by having an ItemHeader table with all the common attributes. Then will make an ItemAttributes table where I'd use the foreign key of the first table and just have Key/value pairs for all the unique attributes you want to give to the item. Any sort of query on any of the attributes can be one via a simple join.

Though i suppose it gets trickier if attributes may have sub attributes etc....

Re:The growing irrelevance of MongoDB by icebraining on Wednesday January 14, 2015 @07:19AM (#8885754)
In a sql db, every single thing needs to fit into a flat schema with nesting done by relations.

Nope, see Postgres (hstore and json).

Re:The growing irrelevance of MongoDB by mgkimsal on Wednesday January 14, 2015 @08:34AM (#8886078)
why not "see sql server from 10 years ago with xml column type"?
Re:The growing irrelevance of MongoDB by icebraining on Wednesday January 14, 2015 @08:38AM (#8886099)
Because one example is enough to dispel that myth, and I'm familiar with Postgres, and not with "sql server from 10 years ago with xml column type".
Re:The growing irrelevance of MongoDB by gasping on Wednesday January 14, 2015 @06:33AM (#8885607)
Are you saying you're using a single MongoDB collection as a dumping ground for all your entities? I hope you're not building a real product that someone has to maintain.
Re:The growing irrelevance of MongoDB by woah on Wednesday January 14, 2015 @07:02AM (#8885691)
I don't actually use Mongo at all, I prefer Postgres. But for loosely structured data, it has a use case. Just like dynamic vs typed languages, there are pros and cons.
Re:The growing irrelevance of MongoDB by annnnd on Wednesday January 14, 2015 @05:28AM (#8885421)
Agreed. That said, optional schema enforcement would be really nice (in my experience, most of the data has a predefined format; so why not define schema and enforce it?).
Re:The growing irrelevance of MongoDB by ris on Wednesday January 14, 2015 @08:47AM (#8886153)
"In 2015, the Mongo backlash is just as tired as the Mongo hype."

If you say so.

Re:The growing irrelevance of MongoDB by CmonDev on Wednesday January 14, 2015 @04:15AM (#8885133)
You can always just stick JSON into a separate table for those cases. So that alone is not an argument.
Re:The growing irrelevance of MongoDB by rjaco31 on Wednesday January 14, 2015 @04:11AM (#8885116)
Care to elaborate? Beside maybe for the suggestion system, I really don't see what's the gain compared to a relational database.
Re:The growing irrelevance of MongoDB by BonoboBoner on Wednesday January 14, 2015 @04:17AM (#8885143)
Probably the EAV nightmare
Re:The growing irrelevance of MongoDB by arethuza on Wednesday January 14, 2015 @04:53AM (#8885279)
Stick JSON in a field within your relational model - best of both worlds.
Re:The growing irrelevance of MongoDB by BonoboBoner on Wednesday January 14, 2015 @09:21AM (#8886354)
I wish I could have a foreignkey within that json.
Re:The growing irrelevance of MongoDB by crdoconnor on Wednesday January 14, 2015 @04:16AM (#8885141)
So what happens when you want to list all of the products in a category?
Re:The growing irrelevance of MongoDB by Harrisburg on Wednesday January 14, 2015 @04:35AM (#8885220)
query = db.products.find({'type': 'Film', 'details.actor': 'Keanu Reeves'})

@see: http://docs.mongodb.org/ecosystem/use-cases/product-catalog/

I personally miss Joins in MongoDB - but other vendors support Joins.

Re:The growing irrelevance of MongoDB by ris on Wednesday January 14, 2015 @04:54AM (#8885281)
There - you're consistently using a field named "type" across your objects - you're using a schema.
Re:The growing irrelevance of MongoDB by onion2k on Wednesday January 14, 2015 @08:10AM (#8885968)
Not quite. The 'type' in the example is a label for what it contains - it's wholly semantic - as opposed to a field that would exert some sort of constraint such as describing the data type, collation, restraints, etc. Schemaless databases don't completely abandon all forms of organisation because that'd be unusable. They just make the organisation looser. For example, if the user wanted to they could add a record to the products in that example that doesn't have a 'type' (although in the case of that example that probably wouldn't be useful).
Re:The growing irrelevance of MongoDB by takeda on Wednesday January 14, 2015 @12:47PM (#8887787)
The thing is that in order to use that /label/ you need to write logic to handle it in your code, ultimately you end up implementing schema, the only difference is that you enforce it in your application. This label becomes not much different than a column in database that is nullable.

Now things become more hairy when you realize that perhaps you want to keep more information about the actor so for example you want to change details.actor to details.actor.name. You will have two choices, either run through your database and modify all documents (which is something similar to RDBMS is doing) or write code to handle both cases. The second one seems easier, but as you'll have more changes it'll come back and bite you hard.

Later in the future you might realize that by repeating details about actor for every single movie you simply not only wasting a lot of resources (your database is bigger and slower) but also this affects integrity (in one movie perhaps you include actor's middle name, or maybe you have a typo).

At that point you'll start creating a collection that holds actors and then only store key of it in "details.actors". You will soon realize that you're basically reimplementing a relational database on top of Mongo, except not only it is way slower, your application is becoming more complex.

There are uses for NoSQL, but whenever you have to ask yourself which model you should go with pretty much always the answer will be: relational.

Re:The growing irrelevance of MongoDB by woah on Wednesday January 14, 2015 @05:13AM (#8885370)
HA! You got him. A gold star for you sir.
Re:The growing irrelevance of MongoDB by collyw on Wednesday January 14, 2015 @04:22AM (#8885168)
Have a category field or link in the table. Join to it. Joins are not evil, they are damn useful. And well done if your product has become large enough to have scaling problems that can't be solved by a bit of indexing on the joins.
Re:The growing irrelevance of MongoDB by crdoconnor on Wednesday January 14, 2015 @04:32AM (#8885208)
Joins are not supported by Mongo. Or at least, not in any way that isn't tortuous.
Re:The growing irrelevance of MongoDB by rimantas on Wednesday January 14, 2015 @04:51AM (#8885276)
I'd say elasticsearch is often used for this kind of tasks.
Re:The growing irrelevance of MongoDB by collyw on Wednesday January 14, 2015 @04:15AM (#8885134)
I wouldn't personally say it fits better. And you are throwing away a ton of useful features that come with a relational database.
Re:The growing irrelevance of MongoDB by TheDong on Wednesday January 14, 2015 @04:54AM (#8885283)
> Facebook clone

Diaspora is a social network that made the mistake of choosing mongodb for their first iteration. Here's a blog post where one of the involved developers explains why it's not good for that, even: http://www.sarahmei.com/blog/2013/11/11/why-you-should-never...

Re:The growing irrelevance of MongoDB by andrea_s on Wednesday January 14, 2015 @06:07AM (#8885542)
To be fair, this is a poor technical choice that no reputable DBA should ever make... Not really the technology's fault.
Re:The growing irrelevance of MongoDB by lmm on Wednesday January 14, 2015 @05:07AM (#8885345)
> I have yet to see a real use case for Mongo unless you are building a Facebook clone. Can someone suggest when it is actually useful over a properly tuned relational database?

Seamless auto-sharding, supported as a first-class use case. Particularly in a cloud environment where you can have your system automatically spin up more hosts as load increases (and take them down as load drops) with zero human intervention, which is really nice.

There are plenty of alternatives in that space nowadays (more than when mongo first came out), and reasonable people can disagree over whether to use mongo rather than e.g. cassandra, riak, or shonky third-party clustering addons for mysql/postgresql, but I've yet to see an affordable relational database with out-of-the-box auto-sharding support that comes anywhere close to what mongo offers.

(Also, first-class support for async-io clients. This is about client libraries rather than the server itself, and purely an artefact of when mongo was released, but if you're calling e.g. PostgreSQL from the JVM, most of the libraries are oriented towards blocking JDBC which is "good enough" (there are valiant efforts like https://github.com/mauricio/postgresql-async but you can't use them with established higher-level libraries). Whereas every mongo library offers a callback- or future-based API, and the higher-level libraries are built around this)

Re:The growing irrelevance of MongoDB by girvo on Wednesday January 14, 2015 @06:44AM (#8885632)
> but I've yet to see an affordable relational database with out-of-the-box auto-sharding support that comes anywhere close to what mongo offers.

FoundationDB is a bit weird, but it handles automatic scaling-out, and has an ANSI SQL interface (backed onto a K-V store): https://foundationdb.com/key-value-store/white-papers/scalab...

Caveat: I've not used it for more than hobby stuff yet, but it's a fascinating bit of technology!

Re:The growing irrelevance of MongoDB by lmm on Wednesday January 14, 2015 @08:50AM (#8886165)
Sounds interesting, but frankly I wouldn't trust anything so young in production yet. For all mongo's faults, at this point the pitfalls are reasonably well-known and there are enough serious organizations using it at scale to give a certain level of confidence.
Re:The growing irrelevance of MongoDB by enobrev on Wednesday January 14, 2015 @06:52AM (#8885657)
I generally agree in regards to shoehorning data into MongoDB. I don't agree that a facebook clone fits appropriately. When thinking through a project, my mental model generally self-configures into third-normal form, which is to say I literally think in the manner of a relational database.

That said, I have found one specific use-case where it has incredibly worked well, which is as a JSON-based file system in which I can query into the document structure to find the records and data I need en-masse with very simple queries. A project I've been working on for a few years has its own custom schema that fits far better into a JSON hierarchy than a relational one. In this specific system there are very few records (compared to our primary RDBMS which has millions), and when not being explicitly maintained, the files are generally static. The single-collection database in question with a few hundred JSON objects would likely have to be split into at least 10 tables with thousands of records each.

When it comes to using said "files" in production, I index the objects into memory for quick retrieval. In order to populate said cache, MongoDB allows me to query into the JSON file structure and retrieve the necessary "files" very simply into however many indices I need. And that's where it has shined in my experience; Not as a live read-write datastore for production use, but as read-heavy storage for a relatively small amount of JSON data with a deep hierarchy that would require an annoying amount of joins and subqueries for otherwise simple queries.

I've also tried it out with our multi-system logging system using capped collections (JSON formatted messages transported and collected with rsyslog). But we grew beyond its limits almost immediately and ended up in far more manageable territory with kibana / elasticsearch.

Re:The growing irrelevance of MongoDB by khalidmbajwa on Wednesday January 14, 2015 @08:30AM (#8886063)
We are building a music streaming website. Think of it as a Spotify for Pakistan and Mongo has been wonderful for the kind of Data Structure we have. Its perfect for a catalogue like structure where objects can very easily nest inside each other. Each Artist has multiple albums, and multiple artists have multiple songs. All of this nestles very neatly inside eachother, and when i want a song, i almost always need its album and artist data, so i can very easily get that. Mongo is blazing fast on such kind of nested data structures. The only slight problems is where you have playlists and need to reference songs for a certain Artist. That could be countered by Data Duplication, since the song artist data etc once entered will very rarely change. So for us it makes perfect sense. You really need to understand what your data model is, and what you want from it, and then Mongo will be your friend, other than that it will cause you a world of pain.
Re:The growing irrelevance of MongoDB by fragmede on Wednesday January 14, 2015 @08:33AM (#8886074)
How does that hierarchical model work when songs or albums have more than one artist?

Why does a traditional relational db fail for such a well-defined data model? I mean, there's nothing about 'given an song (id), retrieve artist and album' that would make mongo inherently better.

Re:The growing irrelevance of MongoDB by annnnd on Wednesday January 14, 2015 @04:09AM (#8885111)
Lately (and not so lately ;) there has been a lot of bad press about MongoDB. We use it extensively as part of our product (on single servers) and it fills this role nicely. It has a few drawbacks, most notably huge disk space requirements (MongoDB has no compression) which we are hoping to solve with TokuMX (haven't tried it yet). It has some other quirks too, but in general it just... works. And I love using a document DB because it lets you use relations just when they are needed. With relational DBs you often have to use complex joins even for things which should be incredibly simple. On the other hand, I do miss JOINs when I need them (though we solved that on app level). And I would appreciate a way to define schema... :) But would I exchange document DB for relational DB for that? No (for the current project).

Maybe I'm getting old, but I really want DB to just work (unlike HBase, at least a few years ago). Other than that, I'm flexible.

Re:The growing irrelevance of MongoDB by andrea_s on Wednesday January 14, 2015 @04:21AM (#8885162)
The good news is, you can just wait a few weeks and get the possibility to use WiredTiger inside the upcoming 2.8.0. That will solve a few pain points that we've been dragging along for years (namely, document-level locking, disk requirements, multi-document transactions).
Re:The growing irrelevance of MongoDB by annnnd on Wednesday January 14, 2015 @04:25AM (#8885177)
Whoa, I totally missed that news, thank you!!! :)
Re:The growing irrelevance of MongoDB by thawkins on Wednesday January 14, 2015 @04:25AM (#8885176)
And compression
Re:The growing irrelevance of MongoDB by andrea_s on Wednesday January 14, 2015 @04:26AM (#8885180)
Yes, I missed a word, it was supposed to read "disk (space) requirements" :)
Re:The growing irrelevance of MongoDB by ttty on Wednesday January 14, 2015 @04:29AM (#8885192)
>And I would appreciate a way to define schema

Use mongoose!

>On the other hand, I do miss JOINs when I need them (though we solved that on app level).

How you do that? (maybe is different than me)

What about transactions?

Re:The growing irrelevance of MongoDB by annnnd on Wednesday January 14, 2015 @05:24AM (#8885406)
>Use mongoose!

We don't use node.js. Also, we have app-level schema, but enforcing should (IMHO) be done on DB level so as to avoid any chance of invalid data.

Joins: easy, we specify which fields are connected (on app level), then fetching goes to connected collections and fetches data from there too. Not ideal, but it works. We made a similar solution for foreign keys.

Transactions: no need for any further guarantees. Our system mostly works on a single record at a time in all critical components. If this is not possible, we have app-level locking to avoid conflicts. No issues or wishes here.

Re:The growing irrelevance of MongoDB by avasdvasdv on Wednesday January 14, 2015 @07:56PM (#8890267)
> If this is not possible, we have app-level locking to avoid conflicts.

app-level locking is a recipe for disaster if data matters and more than 1 process/user/client/etc can access your data. if the data doesn't matter then I guess you can do whatever you want.

web "developers" have a bad reputation for a reason. so many amateurs amongst web developers...

Re:The growing irrelevance of MongoDB by annnnd on Thursday January 15, 2015 @08:16AM (#8892309)
I will assume the last part is just a generic statement and is not directed towards me. You are a Java dev I presume?

As for app-level locking, I am talking about sacrificing performance, not safety. We just make sure that some piece of code runs exactly once. Since the need for this is very rare and the places are not performance critical, we can live with that. So no, we have no need for additional transactional guarantees on DB level.

Re:The growing irrelevance of MongoDB by avasdvasdv on Friday January 16, 2015 @12:17AM (#8897360)
> I will assume the last part is just a generic statement and is not directed towards me.

It's most definitely directed at you.

> You are a Java dev I presume?

C#/C++. Though I've worked with java before amongst others.

> As for app-level locking, I am talking about sacrificing performance, not safety.

You are sacrificing both. Only idiots truly depend on app-level locking.

> We just make sure that some piece of code runs exactly once.

Amateur hour...

> Since the need for this is very rare and the places are not performance critical, we can live with that. So no, we have no need for additional transactional guarantees on DB level.

So it's a useless pointless trivial application...

Re:The growing irrelevance of MongoDB by annnnd on Monday January 26, 2015 @08:17AM (#8946821)
Incredible, I am being judged by someone on Internet... How will I survive this? </sarcasm>

Another day, another idiot, I guess. (and yes, the term is definitely directed at you - if you still follow this throwaway account anyway)

Re:The growing irrelevance of MongoDB by collyw on Wednesday January 14, 2015 @04:15AM (#8885138)
Postgres and MySQL just work as far as I am concerned.
Re:The growing irrelevance of MongoDB by annnnd on Wednesday January 14, 2015 @04:23AM (#8885172)
I never said or implied that they don't. What is your point?
Re:The growing irrelevance of MongoDB by collyw on Wednesday January 14, 2015 @11:00AM (#8887047)
OK, I took your last line to imply that somehow Mongo just works in a way that others don't.
Re:The growing irrelevance of MongoDB by deepGem on Wednesday January 14, 2015 @06:50AM (#8885647)
MongoDB is not at all good for Social networks or anything resembling a graph. You are better off with Titan (horizontal scaling) or Neo4j (vertical scaling). Neo4j offers this great ability to query by a path, which no other database offers.
Re:The growing irrelevance of MongoDB by nevi-me on Wednesday January 14, 2015 @05:04AM (#8885332)
Hopefully a useful example, would love some comment.

I've been building https://rwt.to and https://movingjoburg.co.za with storage backed by MongoDB. Both are transit apps/websites in South Africa, could be more useful, except that we spend most of our time collecting and capturing data.

At the time I was very inexperienced (I guess I'm a bit better now?), but these are the reasons why I chose MongoDB.

1. Geospatial query support out of the box (this is during 2.0-2.2). It's now great with GeoJSON, I store routes and stations as GeoJSON, and querying them is very easy. Compare with PostgreSQL + PostGIS.

2. Some bus services have weird schedule structures, and I needed to be able to generate those schedules, I store schedules as a giant JSON file, and I can query that file to find when the next bus/train is. It's now possible with JSONB in PostgreSQL, but trying to fit that into a relational model wasn't worth the pain at the time, especially when there's always edge cases that I have to cater for at times.

3. To create a pricing engine on rwt.to, I needed a very flexible schema, because I have to cater for many cases (are there bus/train transfers, discounts, and quite different rules for those transfers and discounts). MongoDB gave me the ability to vary my schema in the instances where I needed to store different types of data. I'd rather contend with that than have a table with 100 columns to do the same. To head off on a tangent, in GTFS this data (fares) is computed and stored in the table, but I calculate fares at query-time because there's sometimes a lot of rules to consider, making calculating them and caching them like GTFS unpleasant.

4. Other reasons was because it was pleasant to work with MongoDB + Mongoose.js. This is very important as I'm the sole developer, and due to my line of work, I don't get all the time I need to work on both projects. For my core transit data, I won't reach >20GB even when I manage to collect all the data for South Africa, so I won't have to contend with the 'big data' issues that other users would face.

PS: Out of interest, if anyone would like to try rwt.to to see how it works, here are some example links: - https://rwt.to/*mrwF8w0u - https://rwt.to/*mrCLEZaE - https://rwt.to/*mrOkEDKH

Re:The growing irrelevance of MongoDB by nextw33k on Wednesday January 14, 2015 @04:18AM (#8885148)
> Can someone suggest when it is actually useful over a properly tuned relational database?

In your own question you kind of hint at it. You need a tuned database. NoSQL lowers the barrier to entry for fast persistent data storage with replication. NoSQL doesn't replace SQL databases, it's looking to optimise a use case where transactions are not required.

Personally I use Mongo a bit like a cache, sitting in front of a SQL DB. Things that need to be ACID are handed back and forth. Those that don't are kept in Mongo and I get the best of both worlds.

Re:The growing irrelevance of MongoDB by ddebernardy on Wednesday January 14, 2015 @06:25AM (#8885592)
> NoSQL doesn't replace SQL databases, it's looking to optimise a use case where transactions are not required.

I'd be curious to know in what contexts anyone would not want transactions.

I readily see the case for memcached or equivalent when it comes to caching -- it is very valid, and indeed useful, when slightly outdated data is perfectly acceptable. I can even picture how you might be using MongoDB to do the same, even if you admittedly have me wondering how you're invalidating the mess.

For a persistent data store, however, I'm honestly at a loss. In my own experience, transactions are needed as soon as there's a remote possibility that a concurrent write may occur. Even embedded systems need them, when you're threading statements concurrently for performance reasons, or when you're subsequently merging local data with another node. (See CoreData/iCloud bugs for what occurs when you ignore ACID in the latter case.)

Re:The growing irrelevance of MongoDB by jbergens on Wednesday January 14, 2015 @11:17AM (#8887171)
Document databases normally has atomic updates of a document. This may contain many parts and would require transactions in a relational db. Meaning you kind of get some transactions automatically. Other things are not possible to make transactions around and then you must try to create the app to handle the problems. And some document databases can actually use transactions, like FoundationDb.
Re:The growing irrelevance of MongoDB by pjmlp on Wednesday January 14, 2015 @07:24AM (#8885771)
> Can someone suggest when it is actually useful over a properly tuned relational database?

Maybe when developers don't want to bother to learn SQL?

On my CS degree we got proper introduction to SQL and the relational algebra behind it, so for me it is just a tool, not a scary monster.

I really love the data integrity options I have at my disposal with relational databases.

So for me this all NoSQL fad never made much sense. Then again, I never had to deal with a Facebook like scale problem, only daily reports from mobile network operators across their whole network elements.

Re:The growing irrelevance of MongoDB by octix on Wednesday January 14, 2015 @08:56AM (#8886203)
It's not about Facebook clone, they still use MySQL for some functionality (i believe), but not as RDBMS but more like NoSQL...

NoSQL means model your data in a different way, the way you'll be using it. For some it makes more sense, for some may not.

For example, compare implementation of a tagging system in mongo and any other RDBMS, which one is easier?

Re:The growing irrelevance of MongoDB by pjmlp on Wednesday January 14, 2015 @09:11AM (#8886287)
> For example, compare implementation of a tagging system in mongo and any other RDBMS, which one is easier?

As I said, I never bothered with NoSQL so I cannot properly answer it.

Re:The growing irrelevance of MongoDB by andrea_s on Wednesday January 14, 2015 @04:19AM (#8885152)
I'd say a graph database would work much better for building a Facebook clone compared to a document store like MongoDB... And a relational database would still be better than the document store.

I've been using Mongo happily to provide online analytics solutions, but the advantage is mostly from the development side, not really from the performance side.

On the other hand, this kind of approach is great for attribute matching, which is usually a nightmare to do properly with a RDBMS.

Re:The growing irrelevance of MongoDB by avasdvasdv on Wednesday January 14, 2015 @07:45PM (#8890218)
> I have seen many people try and shoehorn various problems into MongoDB

MongoDB is easy and was used by web "developers" too lazy to learn SQL and RDBMs.

MongoDB is fine if you don't really care about the data. If you don't need ACID compliance and can afford to lose transactions.

Re:The growing irrelevance of MongoDB by collyw on Monday January 26, 2015 @11:40AM (#8947900)
/dev/null would be faster in those cases
Re:The growing irrelevance of MongoDB by jbergens on Wednesday January 14, 2015 @08:46AM (#8886144)
For some systems the development time is much shorter with a document db (or a graph db) than with a relational db. That can be more important than pure performance. Basic scalability is also usually better since it often easy to shard data across servers.
Re:The growing irrelevance of MongoDB by JulianMorrison on Wednesday January 14, 2015 @04:15AM (#8885135)
I could see its "capped collections" being useful for log analysis.
Re:The growing irrelevance of MongoDB by Kiro on Wednesday January 14, 2015 @04:22AM (#8885165)
I just like being able to insert a random JSON into a collection and query it by any of its properties. Not sure how I would do that with a relational database.
Re:The growing irrelevance of MongoDB by adamors on Wednesday January 14, 2015 @04:37AM (#8885227)
PostgreSQL has full support for JSON [1]. So, quite easily in fact.

[1]: http://www.postgresql.org/docs/9.4/static/datatype-json.html

Re:The growing irrelevance of MongoDB by Kiro on Wednesday January 14, 2015 @05:13AM (#8885371)
Thanks, I didn't know that. What's the benefit of using PostgreSQL though if the functionality is the same?
Re:The growing irrelevance of MongoDB by jerven on Wednesday January 14, 2015 @06:18AM (#8885569)
The reliability and speed advantages of PostgreSQL over MongoDB. Plus the fact that sometimes KV/document is better and sometimes normalized relational. Is nice if one tool solves both.
Re:The growing irrelevance of MongoDB by mateuszf on Wednesday January 14, 2015 @06:21AM (#8885580)
Full ACID transactions, reliability, access to trained DBA-s.
Re:The growing irrelevance of MongoDB by thorin on Wednesday January 14, 2015 @04:38AM (#8885234)
You can do this in Oracle 12 and I think in Postgres. You might want to think about why you need to store unstructured data as part of your application though and query it. If it's expected to live a long time and be queried it should probably be structured. If not you could store it (a serialized object) as a blob if you are just caching some state.

https://docs.oracle.com/database/121/ADXDB/json.htm#ADXDB624...

Re:The growing irrelevance of MongoDB by Arnt on Wednesday January 14, 2015 @04:59AM (#8885311)
I've used it and been happy. If you want something that's simple to use, know your schema partly but not entirely, and you don't mind losing a few writes, then mongo fits.

Relational databases place such emphasis on reliability. Mongo is generally reliable but only two or three nines, and it's simple.

For example, if you're collecting sub-cent line items for invoices, you might prefer to collect 99.x% of the line items simply over 100% at greater complication and expense, particularly if you can measure x.

Re:The growing irrelevance of MongoDB by gasping on Wednesday January 14, 2015 @06:02AM (#8885533)
What? When would it ever be OK to lose parts of an invoice. Mongo apologists baffle me sometimes. To anyone considering MongoDB, don't be fooled, you probably want to stick with an RDBMS.
Re:The growing irrelevance of MongoDB by Arnt on Wednesday January 14, 2015 @08:13AM (#8885981)
When the parts are cheap compared to the cost of storing them in a real database.

I even know someone who stores invoice items in memcached. Whenever memchached evicts something that hasn't made it onwards to real storage, they lose the ability to invoice the right customer for an ad impression.

Re:The growing irrelevance of MongoDB by mwj on Wednesday January 14, 2015 @07:19AM (#8885753)
What are you talking about? We run a 800+ GB mongo cluster and have never lost data.
Re:The growing irrelevance of MongoDB by mietek on Wednesday January 14, 2015 @06:22AM (#8885582)
This is satire, right? Right?…
Re:The growing irrelevance of MongoDB by Arnt on Wednesday January 14, 2015 @08:03AM (#8885935)
Not at all. Let me run an example with simple and made-up numbers.

Consider two storage solutions used to gather line items to invoices. The line items are ten cents on average.

One system is properly ACID, and running it costs one cent per line item on the invoice. The other loses 1% of writes randomly, but its hardware/backup/ops requirements are lower, so it costs just 0.1c/item.

The ACID way gives you complete invoices, but you spend 10% of the invoiced amount on the invoices. The lossy way makes your invoices 1% smaller, randomly, but the loss+cost adds up to about 2% instead of 10%.

It's like returns on physical goods, really. A random percentage of customers will return goods, you can't control that but you can estimate and monitor it, and optimize if the numbers aren't good enough.

Re:The growing irrelevance of MongoDB by dyadic on Wednesday January 14, 2015 @08:24AM (#8886033)
So, if I want to incorrectly invoice my customers then I should use MongoDB?

I don't understand how you can say any of this seriously.

Re:The growing irrelevance of MongoDB by Arnt on Wednesday January 14, 2015 @08:40AM (#8886107)
What's the problem with serving customers and occasionally forgetting some small part of the invoice?

Overinvoicing would be bad. But underinvoicing is just another cost of business. If the cost is smaller than the alternative, fine.