I'm kind of curious as to where this hype is. I've almost never heard anybody say anything positive about mongodb. All I ever see is people saying it's terrible / hilarious for various reasons.
Not saying those are impossible goals but so far no database has managed to deliver that. Building a large-scale endlessly-scalable database is still very hard and very detailed and easy to screw up.
>The Standard for Modern Applications
>MongoDB 3.0 features performance and scalability enhancements that place MongoDB at the forefront of the database market as the standard DBMS for modern applications.
>Also included in the release is our new and highly flexible storage architecture, which dramatically expands the set of mission-critical applications that you can run on MongoDB.
>These enhancements and more allow you to use MongoDB 3.0 to build applications never before possible at efficiency levels never before attainable.
Hang out on the freenode room for mongo and you will see that most people, working on production software, make inquiries that reflect a complete lack of knowledge, common sense and leave you facepalming with no hope in humanity at a large.
I wish people would stop using acronyms and realize Express/Angular/Node is just as good with something other than Mongo.
great incentive to dive into React further and ditch Mongo
Take it with a grain of salt...
Just today CNBC announced its list of "the 2016 CNBC Disruptor 50 companies"[1]
MongoDB is #19. It apparently is:
Big data's thought leader
[1] http://www.cnbc.com/2016/06/07/2016-cnbcs-disruptor-50.htmlBecause of its excellent integration with Spark/Hadoop and the schemaless nature it's very useful in the analytics space.
There are some things MongoDB does fairly well:
* MongoDB is really easy to use
* Document databases can be great and flexible solutions for some kinds of projects
* Documentation is fairly good so learning the basics isn't too hard even if you know nothing about it
* scales fairly well at the initial stages
* arguably quicker to get a project off of the ground with than traditions RDBMs, which might be the most important consideration for any startup even if a complete rewrite would eventually need to take place
That being said, I've used MongoDB significantly before and it wouldn't be my first choice for most types of new project: PostgreSQL probably would be
I doubt they meet in the middle, but both have great use cases. scaffolding out a quick isomorphic js app is great for mongodb for example. pg is faster and more robust.
its just tech, depends what you are optimizing for
* Mongo is only easy to learn. Beyond simple demos, it gets harder and harder to use as projects evolve i.e. you have to do a lot of work yourself imo this is a common problem with nosql datastores that isn't exclusive to Mongo
* "Document databases can be great and flexible solutions for some kinds of projects": Postgresql has been able to work directly with JSON for some time now. There are also other document datastores that are more reliable than Mongo
* Scaling with Mongo is difficult, specifically the crazy setup. Even if you set it up properly, the results don't tend to match the marketing https://aphyr.com/posts/322-jepsen-mongodb-stale-reads
* "arguably quicker to get a project off of the ground with than traditions RDBMs" unless you're using Meteor, I'm also going to disagree here. Most frameworks target a relational database by default. Developing by convention tends to get you off the ground much faster than using something more specialized and niche
Not sure what that means, but scalability is the worst thing about mongo (though my experience with mongo is all from ~2.5 ish years ago). As soon as your working set of indices gets bigger than memory, performance falls off a cliff and your entire app grinds to a halt. In my experience, mysql and postgres have a more gradual decline in performance so you have some time with only mildly degraded performance to figure out a solution (plus they have more options for tuning which can buy you more time).
MongoDB is the fastest database I've ever used. The easiest to get running, stable and scaled out. The best documentation by far and has excellent integration e.g. Spark, Hadoop.
If you are doing Big Data it's a great tool in the arsenal.
If you have a lot of relations in your data don't
use mongo
Why would you use Mongo if you have lots of relational data? Why would you not start with a relational database for that?I know Mongo has issues but it's never going to beat an RDBMS on relational queries.
Denormalizing on day 1 (Mongo) has you making guesses about your data access patterns at the worst possible time instead of just thinking about the data itself.
This has nothing to do with database choice. This is just shitty development. It's a strawman at best.
Normalization is just a method of organization to minimize repetition of data. It has nothing to do with efficiency of operation. This is perfectly valid code:
person = {
_id: "person123",
username: "lloyd-christmas"
}
comment = {
_id: "comment123",
person: "person123",
text: "This is how I start",
}
You don't have to do: person = {
_id: "person123",
username: "lloyd-christmas"
}
comment = {
_id: "comment456",
person: {
_id: "person123",
username: "lloyd-christmas"
},
text: "This is also valid"
};
Sure, a join is faster than the first one where you'll have to hit the DB twice. The point is that you don't have to START with denormalizing everything. I start with normalized data and do more DB reads than I need. I figure out how the application uses my data as I go along, and denormalize the pieces I need only once I need them and am confident I won't bump into consistency issues (my username isn't updating every 5 seconds). Through this process I realize what the actual relationships are in my application and how my app functions request to request. This allows me to better structure my data. This is a quick update in mongo and usually a couple of lines of refactoring in application logic.Obviously this is just an MCVE. My original point was that I find this to be a drastically more flexible process than starting off relational.
To nit-pick, I think normalisation improves the efficiency of updates, as you only have to modify the one place where the piece of data lies.
I'm just curious how that's an upside to using a relational database from the beginning when your plan is to migrate to a relational database anyways.
Switch out "Mongo" for "Postgres" in your bulk paragraph and you have the same scenario but with less work on your part and more features to help establish your data model.
One upside I can see if it you're more familiar with Mongo where using a relational database slows you down.
The bottom level of our application layer is a query builder which is almost a drag and drop replacement between mongo and postgres. By the time that layer is built out, we know what our database needs to look like. I find that adding/dropping fields and models in mongo to be drastically faster than moving models around in postgres. The above example would obviously end up in the same structure, whether we started with relational or not. It was nothing more than demonstrating an iterative process where you don't need to START denormalized just because "that's why you use nosql".
We try to be as incremental as possible when building our apps, and have found that using nosql allows for 20 small refactors that often end up being 2 larger refactors with a relational db. We've just found that it ends up being a faster production process, and we end up with a much more application-specific database instead of just "This is a Person, this is an Address, this is a Comment". Sure, we know beforehand that the application will contain all those components. We don't necessarily know how they'll be used in a request-by-request basis, and whether or not they will actually end up being one-to-one, one-to-many, or many-to-many.
Quite the opposite. We feel that going in with the assumption that you know where the application is going to end up is hard-headed. However, acknowledging that the situation will definitely change doesn't absolve you of planning it out properly given the information currently available to you.
> Or is it just the kind of projects you work on?
We build mainly internal facing or b2b apps in the medtech space. Given that we need to integrate with larger players that don't really care much for small businesses, we can receive slow response times for data/api requests from any external sources we deal with.
e.g., Recently we built an application for a home-town pharmacy where we were forced to use two databases; one under our control and one which was controlled by a pharmacy management system. We needed to update certain models in their database while reading from other ones. They promised to build out a few stored procedures that we needed. They flat out lied on a couple, and then quoted us a 8 month turn around on the other ones. We'd be stuck with them regardless, the expectation of a curveball like that allows us to rapidly adapt.
Obviously, the pharmacy's business model doesn't change very rapidly. Iterating over the app through a few of their business cycles tends to give you enough knowledge of what you can build them, as well as what they really want. Regardless of how much time we spend planning with them, they'll always leave us with some form of an XY problem that we'll only understand after they use the application for an extended period.
We don't deal with web-scale, so the problems generally encountered in the mongo complaint arena tend to be irrelevant to us. Given our use case, I think the decision is pretty reasonable.
> Do you find there's less rewriting over time as you become more experienced?
We've factored that into our development strategy, which is why I mentioned the query wrapper. That query wrapper paired with a DAO level that's reasonably database agnostic makes our transition fairly simple and quick.
https://wiki.postgresql.org/wiki/What%27s_new_in_PostgreSQL_...
JSONB values are indexable and queryable, so there aren't very many downsides.
So... you are not against MongoDB but against NoSQL in general? I've used MongoDB and I've never ended up with lots of joins in my code. But I guess it all depends on the use case and how you've structured your data. Document databases are not a silver bullet.
Perhaps you should have been using a relational database from the get go.
Sounds more like your issue, not mongo's.