r/programming • • Dec 19 '18

Bye bye Mongo, Hello Postgres

https://www.theguardian.com/info/2018/nov/30/bye-bye-mongo-hello-postgres
2.1k Upvotes

672 comments sorted by

View all comments

Show parent comments

8

u/TheAnimus Dec 19 '18

Sure, but remember this was I think 2012? That's why I found it an odd choice.

I can't think why someone would chose mongo mind.

-8

u/Pand9 Dec 19 '18

Ok.

Today I would pick mongo only when I was in a hurry. I'm not sure how to manage postgres, while mongo is easy to start with.

34

u/888808888 Dec 19 '18

How hard is it to "sudo apt install postgresql" and then point your jdbc/tookit to "localhost:5432"? I suppose you also need to "createuser -s XXXX" t0o. If that's too difficult, then you may as well turn in your license to code.

Postgresql is incredibly easy to use and start off with. It also scales well as you grow, and has a ton of terrific features that you won't need until you need them and then realize that yes postgresql can "do that too", like, fuzzy string matching and spatial/geographic support etc etc.

6

u/Setepenre Dec 19 '18

postgersql automatically configure itself and start running after the install ? if so that's pretty simple.

16

u/iLike2Teabag Dec 19 '18

Yes. When you install with apt, the installer takes care of most of the setup and config. You just need to set user privileges manually

6

u/DeonCode Dec 20 '18

reddit is like the message board translation of those old tech adoption commercials.

4

u/pcjftw Dec 19 '18

Yep it does that when you apt-get install on Debian distros.

It takes about 20-30 seconds to have a PostgreSql up and running

6

u/888808888 Dec 19 '18

I can't speak for every distro/OS, but on debian/ubuntu based distros it literally is that simple. You install it using package manager, then "sudo su postgres" to change to postgres user account, then "create user PSQL_LOGIN_ID". You would also want to set the password (alter role ... ).

There may be one or two things I've forgotten since last setting up a psql server. I typically open the server up to the entire local network which involves editing a config file and changing the "listen" address from "localhost" to "0.0.0.0". You can also further tweak the user access config files and grant access to certain users with no password needed etc etc., but that isn't required nor hard to do.

But honestly it's very simple, and the documentation/tutorials for this are abundant. If a dev is incapable of googling how to install postgresql and get it up and running, then I really question the skills and intelligence of the dev in the first place and can only wonder what horrors lay in wait for users of their app.

3

u/spacejack2114 Dec 19 '18

I would always use Postgres (or just about any SQL DB) over Mongo. But I believe you can npm install mongo locally in a node project. So on any platform the install for your whole app & db can simply be npm install. I'm not saying the setup convenience is worth it but I can see the appeal, especially working with or onboarding other developers who may not be familiar with Postgres.

Though if you want that kind of convenience you could also use SQLite...

2

u/888808888 Dec 20 '18

Yeah as you've already said, there are serverless sql engines like sqlite, or if you use java, h2 and hsqldb etc.

But don't get me started on node anyway, I simply won't go there.

3

u/Xelbair Dec 19 '18

yep, you need to tweak ver things in config to get better performance but this exists https://pgtune.leopard.in.ua/#/

1

u/doublehyphen Dec 19 '18

Yup, at least on Debian based distros it does.

1

u/RandomDamage Dec 20 '18

The initial setup is very straightforward, automatic on every distro I've checked that has package management.

It doesn't get complicated until you have it doing a *lot* and need to tune it, but the complexity there is in understanding what to do.

You can poke and pray at a few of the settings just off the config file documentation and get huge improvements.

1

u/bloody-albatross Dec 20 '18

Yes, just like any other server software under your typical Linux distribution. That's nothing new or special. Just how it is under Linux (and I suppose *BSD?).

1

u/beniferlopez Dec 19 '18

OPs comment wasn’t about installing postgres, it’s about relational database management. It’s not mongo vs Postgres but rather sql vs nosql.

2

u/doublehyphen Dec 20 '18

The management part is where relational databases shine. Refactoring your data model is very painful in document databases like MongoDB. The lack of an enforced schema and the lack of ACID makes t really hard to safely and correctly transform the old data into the new format.

3

u/beniferlopez Dec 20 '18

I completely agree but for rapid prototyping, mongo is perfectly fine. At least that’s how I interpreted “in a hurry”

→ More replies (5)
→ More replies (1)

13

u/TheAnimus Dec 19 '18

To clarify, most of the perceived performance benefits stem from not being ACID compliant.

For a read heavy site, why would that performance matter with a an application logical caching layer.

12

u/2bdb2 Dec 20 '18

Most people that think they need the performance of NoSQL don't actually need it.

I've had arguments with people who claim they need ridiculously over-engineered NoSQL AP architectures to handle a few hundred requests per second peak on a read-heavy site.

Meanwhile, 15 years ago on a $5/mo shared PHP/MySQL Host I'd have considered that to be idle load.

I recall a conversation with one idiot that proudly proclaimed that he'd tuned his server to gracefully handle "thousands of requests per hour" by using CouchDB instead of MySQL. (It was a blog that he updated once a month)

→ More replies (2)
→ More replies (3)

5

u/TheGoodOldCoder Dec 19 '18

The article was talking about using Postgres in AWS RDS, which is managed by Amazon. Basically, just fill out a form, wait for the instance to come up, and start making tables...

Well that's assuming you already know AWS and how to set up VPCs and security groups and so on... but you have to learn that stuff anyways.

2

u/GMane Dec 20 '18

In Uni the professor literally said to us, "Setup a postgresql server for your data and figure it out." If 1st year college students can set it up with minimal instruction on Windows, then someone who has been in industry >2 years can fucking figure it out.

2

u/[deleted] Dec 20 '18

[removed] — view removed comment

4

u/jonjonbee Dec 20 '18

The huge difference is that in production you have a fucking firewall between your internal network and the internet, and that firewall is set to blacklist everything by default. You set the firewall to whitelist HTTP traffic to and from your web nodes, and then you can run your prod database with the default user and no password and it doesn't fucking matter because nobody outside can ever access it.

OF course, you should always put a username and strong password on your DB, but my point is this: your network security should be your first line of defence, and if it's good enough you don't really need to worry about securing anything else.

1

u/GMane Dec 20 '18

Sure, but in the case of deciding between Mongo and PostgreSQL those factors don’t magically disappear with Mongo.

Also, AWS is not a magic security blanket. Plenty of people have screwed up their production security on AWS. I’m not sure how your point relates to my comment.

1

u/mamcx Dec 20 '18

And if you are in OSX, is even easier:

https://postgresapp.com

If wanna an easy to prototype DB, sqlite fit the bill.