Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB and PostgreSQL thoughts

I've got an app fully working with PostgreSQL. After reading about MongoDB, I was interested to see how the app would work with it. After a few weeks, I migrated the whole system to MongoDB.

I like a few things with MongoDB. However, I found certain queries I was doing in PostgreSQL, I couldn't do efficiently in MongoDB. Especially, when I had to join several tables to calculate some logic. For example, this.

Moreover, I am using Ruby on Rails 3, and an ODM called Mongoid. Mongoid is still in beta release. Documentation was good, but again, at times I found the ODM to be very limiting compared to what Active Record offered with traditional (SQL) database systems.

Even to this date, I feel more comfortable working with PostgreSQL than MongoDB. Only because I can join tables and do anything with the data.

I've made two types of backups. One with PostgreSQL and the other with MongoDB. Some say, some apps are more suitable with one or the other type of db. Should I continue with MongoDB and eventually hope for its RoR ODM (Mongoid) to fully mature, or should I consider using PostgreSQL?

A few more questions: 1) Which one would be more suitable for developing a social networking site similar to Facebook. 2) Which one would be more suitable for 4-page standard layout type of website (Home, Products, About, Contact)

like image 675
Christian Fazzini Avatar asked Dec 13 '10 07:12

Christian Fazzini


People also ask

Is MongoDB better than PostgreSQL?

Both databases are awesome. If you are looking for a distributed database for modern transactional and analytical applications that are working with rapidly changing, multi-structured data, then MongoDB is the way to go. If a SQL database fits your needs, then Postgres is a great choice.

How was working with MongoDB different from working with PostgreSQL?

PostgreSQL have to do with their systems, architecture, and syntax. MongoDB is a document database while Postgres is a relational database management system; MongoDB has a distributed architecture while PostgreSQL has a monolithic architecture; and Postgres uses SQL, while MongoDB uses BSON.

Can MongoDB and PostgreSQL together?

As revealed in a new Studio 3T survey of more than 18,000 developers and others, NoSQL databases are moving to the cloud faster than SQL databases, but when developers pair MongoDB with a relational database, it's usually PostgreSQL. Yes, that PostgreSQL.

Which is faster MongoDB or PostgreSQL?

The Postgres database management system (DBMS) measured between 4 and 15 times faster than MongoDB in transaction performance testing conducted by OnGres, a company specializing in providing database software and services and sponsored by EnterpriseDB.


2 Answers

You dumped a decades-tested, fully featured RDBMS for a young, beta-quality, feature-thin document store with little community support. Unless you're already running tens of thousands of dollars a month in servers and think MongoDB was a better fit for the nature of your data, you probably wasted a lot of time for negative benefit. MongoDB is fun to toy with, and I've built a few apps using it myself for that reason, but it's almost never a better choice than Postgres/MySQL/SQL Server/etc. for production applications.

like image 84
Dan Grossman Avatar answered Sep 22 '22 20:09

Dan Grossman


Let's quote what you wrote and see what it tells us:

"I like a few things with Mongodb. However, I found certain queries I was  doing in PostgreSql, I couldn't do efficiently in Mongodb. Especially,  when I had to join several tables to calculate some logic."  "I found the ODM to be very limiting compared to what Active Record offered  with traditional (SQL) database systems."  "I feel more comfortable working with PostgreSql than Mongodb. Only because  I can join tables and do anything with the data." 

Based on what you've said it looks to me like you should stick with PostgreSQL. Keep an eye on MongoDB and use it if and when it's appropriate. But given what you've said it sounds like PG is a better fit for you at present.

Share and enjoy.

like image 26