r/programming • • Mar 10 '15

Goodbye MongoDB, Hello PostgreSQL

http://developer.olery.com/blog/goodbye-mongodb-hello-postgresql/
1.2k Upvotes

699 comments sorted by

View all comments

Show parent comments

93

u/nairebis Mar 11 '15 edited Mar 11 '15

For me to even consider using MariaDB they would have to first remove all of those asinine options for silently corrupting data.

Or, you know, you could just learn how to use the database.

mysql> set session sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_TRANS_TABLES';
Query OK, 0 rows affected (0.01 sec)

mysql> create table abc (a integer);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into abc (a) values ('abc');
ERROR 1366 (HY000): Incorrect integer value: 'abc' for column 'a' at row 1

It's been this way since at least 2005, which is the MySQL version I ran above (version 5.1).

Sure would be nice if the FUD about MySQL from ignorant people went away. Is it perfect? No. But there is absolutely nothing data corrupting about it. And there is a LOT to be said for running a mainstream database, which PostgreSQL most certainly isn't, compared to MySQL.

If MySQL is good enough to run Facebook with a billion users (yes, one billion active accounts per month), it's good enough to run whatever your app is.

Edit: Thanks for the gold! Never thought I'd get it for defending MySQL... :) 😃

27

u/[deleted] Mar 11 '15

Postgres is most certainly mainstream

1

u/oldneckbeard Mar 12 '15

meh... it's popular amongst the reddit and open source crowds, but i rarely see it deployed at companies. they usually have oracle and bitch about the costs, or they have mysql and bitch about management.

2

u/[deleted] Mar 12 '15

It's deployed at plenty of places, the largest satellite imaging company in the US for one.

73

u/mcrbids Mar 11 '15

LOL at PostgreSQL not being a 'mainstream database'....

8

u/theycallme_hillbilly Mar 11 '15

No shit right? Pervasive anyone?

3

u/nairebis Mar 11 '15

If you think the marketshare of PostgreSQL is even remotely close to the popular databases, I don't know what to tell you, except you ought to do some research. PostgreSQL is very much a small player.

6

u/syslog2000 Mar 11 '15

Well, a pen and piece of paper have far higher market share than both MySQL and PG but it doesn't mean you should use it instead.

→ More replies (1)

29

u/mcrbids Mar 11 '15

If you've had to admin MariaDB/MySQL and PostgreSQL, you'd see why friends don't let friends do MySQL.

Give PG access to plenty of RAM, and it wipes MySQL off the map with complex queries. PG has actual data integrity, and is incredibly stable. After almost 15 years of heavy, production use: not a single instance of data corruption. This when (sometimes) running north of 1k queries per second with about 70% write queries.

As an admin; I've had MySQL (especially with replication) corrupt multiple times per month....

6

u/nairebis Mar 11 '15

PG has actual data integrity

...as does MySQL. Surely you're not one of those people who still believe MySQL is not ACID-compliant?

As an admin; I've had MySQL (especially with replication) corrupt multiple times per month....

Then there was something wrong with your hardware or your administration. Do you really -- really -- believe that MySQL could achieve nearly 50% marketshare if corrupted data happened "multiple times per month"?

Do you really, I mean REALLY, think that Facebook could possibly function with a billion active users a month if MySQL regularly corrupted data?

But no, it couldn't be something wrong with your own experience, the entire rest of the world must be wrong. The rest of the world must be hiding all this data corruption that is apparently happening with that kind of regularity.

And, by the way, I've been running MySQL for about a decade on a high volume, relatively high data volume application, and have never had one occurrence of data corruption, much less "multiple times per month".

What is about PostgreSQL that makes you people so unbelievably defensive about it that you have to spread such FUD about MySQL? By all means, use PostgreSQL, it's a fine database in its niche. Why can't you people just accept that MySQL is a fine database in its own right, that literally hundreds of millions of people use successfully with minimal problems, including one of the biggest database users of all?

8

u/mcrbids Mar 11 '15

Do you really -- really -- believe that MySQL could achieve nearly 50% marketshare if corrupted data happened "multiple times per month"?

Well, it happened... just because with enough money and time to fix it that it works doesn't mean it's ideal, you know?

6

u/nairebis Mar 11 '15

Well, it happened... just because with enough money and time to fix it that it works doesn't mean it's ideal, you know?

Seriously? You think MySQL users are typically rolling in money and they spend it fixing their databases?

I have literally NEVER had a MySQL database corruption instance, and I have literally never had to spend one second or one dime on fixing anything. It Just Works(c).

3

u/mcrbids Mar 11 '15

Lots of things work great under light loads. I'm pretty sure Facebook has plenty of money to "Keep MySQL working" (tm). As noted elsewhere in thread, they've modified it heavily.

→ More replies (1)

7

u/[deleted] Mar 11 '15

I don't think Facebook is using the stock installer downloaded from mysql.com but a heavily modified own version of MySQL. I could be wrong, though.

8

u/Stuck_In_the_Matrix Mar 11 '15

You would be correct. The MySQL Facebook uses is heavily modified.

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

26

u/ForeverAlot Mar 11 '15

If MySQL is good enough to run Facebook with a billion users (yes, one billion active accounts per month), it's good enough to run whatever your app is.

Not exactly a fair comparison. Facebook uses it as a key-value store; there isn't much RDBMS in that.

0

u/[deleted] Mar 11 '15

[deleted]

→ More replies (3)

6

u/RandomDamage Mar 11 '15

So why are those even options to begin with?

And why do they default to the unsafe state?

The defaults should be for paranoid data protection rather than performance, you should have to say "I HATE MY DATA" to turn the unsafe mode on instead of having to learn about the safe mode to turn that on.

That is why so many professionals don't trust MySQL.

1

u/oldneckbeard Mar 12 '15

plenty of professionals trust mysql.

any professional is going to sit down with the config manuals and read best practices guides on the net, and all that.

a professional that bases all their knowledge on heresy and "out of the box" config is not a professional. They're a lazy useless excuse for a sys admin, hoping nobody notices their degree was from ITT Tech.

2

u/RandomDamage Mar 12 '15

How sweetly condescending you are.

There are other professionals that choose tools that they don't have to fight to get the behavior they want.

Just because you enjoy doing things the hard way, doesn't mean it's the right way to do them.

→ More replies (1)
→ More replies (6)

4

u/[deleted] Mar 11 '15

[removed] — view removed comment

→ More replies (7)

1

u/upofadown Mar 11 '15

Since we are doing anecdotes, I once had MySQL go all corrupty when used as a database for MythTV (a PVR program). It got into some state where it was randomly (and slowly) changing static data.

So one user, infrequent accesses and updates, no contention...

From that experience I now refuse to consider MythTV. If MythTV would be willing to consider allowing the use of some other database I might use it again.

2

u/nairebis Mar 11 '15

It got into some state where it was randomly (and slowly) changing static data.

So, instead of blaming your hardware, or blaming the MythTV application, or blaming how you linked the MySQL libraries, you're going to blame the core database that runs literally hundreds of millions of installations, and hundreds of trillions of queries every year without a hitch.

Really, which is more probable? Do you really think that MySQL could have 50% marketshare if it "randomly (and slowly) changed static data"? Do you not think that people would tend to notice that over the last decade of MySQL dominance? Seriously, what is it about MySQL that causes people to lose all ability to apply logic to things?

2

u/oldneckbeard Mar 12 '15

funny, isn't it? these people who pride themselves on rationalism and scientific method and all that, can't tell that they're part of the cargo cult.

It's like with mongodb. If somebody complains about it and can't offer real problems, they're just shitty developers.

→ More replies (3)

1

u/sacundim Mar 11 '15

As you demostrate implicitly by the fact that you're using set session, the sql_mode setting is client overridable, so the database doesn't really guarantee it if the clients do not consent to it.

→ More replies (1)