Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb vs Postgres in Nodejs [closed]

I'm building a NodeJS application and am utterly torn between NoSQL MongoDB vs RMDS PostregresSql. My project is to create a open source example project for logging visitors and displaying visitor statistics in real time on a webpage using NodeJS. I was planning on using MongoDB at first, because lot of NodeJS examples and tutorials, albeit mostly older ones, used it and paas hosters with a free tier are abounding. However, I was seeing a lot of bashing on MongoDB recently and found that people who tried to use MongoDB ended up switching to Postgres:

  • http://blog.engineering.kiip.me/post/20988881092/a-year-with-mongodb
  • http://dieswaytoofast.blogspot.com/2012/09/mysql-vs-postgres-vs-mongodb.html
  • http://www.plotprojects.com/why-we-use-postgresql-and-slick/

I also a fan of Heroku and have heard a lot about Postgres because of that and find that SQL queries can be nice sometimes.

I'm not a database expert, so I can't tell for the life of me which way to go. I would really appreciate it if you could give some advice on which one to consider and why.

I have a few criteria:

  1. Since I want this to be a example, it would be nice to have a way to host a decently sized amount of data. I know that MongoDB definitely offers this, but Postgres paas like Heroku seem to have pretty small databases (since I am logging every visitor to the website)

  2. A database that is simplistic and easy to explain to others.

  3. Performance doesn't really matter, but speed can't hurt

Thanks for all of the help!

Note: Please no flame wars, everyone has their own opinion :)

like image 249
joshua-anderson Avatar asked Sep 12 '13 23:09

joshua-anderson


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.

Is MongoDB faster than 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.

Is MongoDB better than Nodejs?

MongoDB is a widely used NoSQL database. The ability to store data in several formats makes MongoDB a beneficial tool for managing large amounts of data. On the other hand, Nodejs is a well-known runtime environment that assists in executing JavaScript code outside the browser.

What is the difference between PostgreSQL and MongoDB?

MongoDB is a non-relational database, while PostgreSQL is a relational database. While NoSQL databases work on storing data in key-value pairs as one record, relational databases store data on different tables.


1 Answers

Choosing between an SQL database and a NoSQL database is certainly being debated heavily right now and there are plenty of good articles on the subject. I'll list a couple at the end. I have no problem recommending SQL over NOSQL for your particular needs.

NoSQL has a niche group of use cases where data is stored in large tightly coupled packages called documents rather than in a relational model. In a nutshell, data that is tightly coupled to a single entity (like all the text documents used by a single user) is better stored in a NoSQL document model. Data that behaves like excel spreadsheets and fits nicely in rows and is subject to aggregate calculations is better stored in a SQL database of which postgresql is only one of several good choices.

A third option that you might consider is redis (http://redis.io/) which is a simple key value data store that is extremely fast when querying like SQL but not as rigidly typed.

The example you cite seems to be a straightforward row/column type problem. You will find the SQL syntax is much less arcane than the query syntax for MongoDB. Node has many things to recommend it and the toolset has matured significantly in the past year. I would recommend using the monogoose npm package as it reduces the amount of boilerplate code that is required with native mongodb and I have not noticed any performance degradation.

http://slashdot.org/topic/bi/sql-vs-nosql-which-is-better/

http://www.infoivy.com/2013/07/nosql-database-comparison-chart-only.html

like image 117
Nathaniel Johnson Avatar answered Sep 29 '22 02:09

Nathaniel Johnson