News for hackers. Stuff that matters.
Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @01:44AM (#15172788)
The guy has deliberately changed a default setting (sql_mode) to make MariaDB/MySQL look worse. When someone pointed that out in the comments, he left it unresponded. Which is already telling something about PostgreSQL evangelism.

Speaking of comparing MySQL and PostgreSQL functionality, I've been spending some time recently on this very topic. Both are great databases with interesting and sometimes unique features. Here are some of the features PostgreSQL is missing as compared to MySQL:

- synchronous multi-master cluster (Galera, Group Replication)

- distributed in-memory grid with automatic sharding (NDB)

- semi-synchronous replication (will be available in PostgreSQL 10)

- built-in logical replication (will be available in PostgreSQL 10)

- built-in event scheduler

- clustered indexes

- declarative partitioning (limited functionality will be available in PostgreSQL 10)

- optimizer hints

- optimizer tracing

- efficient MVCC implementation that is unaffected by XID wraparound problems and VACUUM issues (see also Uber's report on moving from PostgreSQL to MySQL)

- page-level compression

- page-level encryption

- page-level incremental backups

- user variables

- NoSQL client APIs (HandlerSocket, memcached protocol, X protocol)

- virtual columns

- ability to choose data page size on database creation

- ability to specify column order when adding a new column with ALTER TABLE

- write-optimized storage engines similar to MyRocks and TokuDB

All of that may seem small from a developer's standpoint. Those things, however, are huge for people who design and operate the busiest websites on the internet. Which is probably why MySQL still shines in that field.

Re:Why favor PostgreSQL over MariaDB/MySQL? by fusiongyro on Tuesday September 05, 2017 @03:07AM (#15173081)
Advanced replication strategies in MySQL and Oracle mostly cause hair loss and divorce. Everywhere I have worked that uses these databases eventually convinces itself that it needs futuristic replication technology and then goes on to suffer from outages and weird corruption. It turns out, distributed consistency is a hard problem. Oracle and MySQL both benefit monetarily from people assuming it will work and then activating it, only to find out a month or two later that it's a complicated problem that requires actual planning and oversight.

I think Postgres will be a better product when it incorporates similar functionality, but the implementations in MySQL and Oracle lie somewhere on the border between false advertising and reckless endangerment. I appreciate that Postgres not having it as two-lines of configuration sends a message that you are making a commitment. Nearly everything else in Postgres is set-it-and-forget-it. You really want to have a DBA if you're going to try to make replication work. When you read the docs on having a hot standby and how much of a commitment that is and sense yourself getting tired, you're starting to appreciate what you might be getting yourself into with single-master replication, let alone multi-master.

Re:Why favor PostgreSQL over MariaDB/MySQL? by barrkel on Tuesday September 05, 2017 @03:23AM (#15173144)
This has not been my experience of multi-master asynchronous replication in MySQL at work. We use only one replica for actual work and the second master is read-only until failover - and is only write enabled after the primary is disabled - and it works quite well.

Getting replication bootstrapped synergises well with having a smooth backup restore procedure, similarly any hiccups in replication can be dealt with using restore.

We have other release QA procedures that use restored backups for testing, so our restore procedure is extremely well exercised. Really fast restores using the Percona tools is a considerable bonus of the MySQL world.

Re:Why favor PostgreSQL over MariaDB/MySQL? by kelnos on Tuesday September 05, 2017 @03:56AM (#15173292)
> This has not been my experience of multi-master asynchronous replication in MySQL at work. We use only one replica for actual work and the second master is read-only until failover

That's not multi-master. That's single master with a hot standby.

> any hiccups in replication can be dealt with using restore.

Restore isn't an option when your database is so large that it takes most of a day to copy the backup onto the replacement master to restore from it. (Not speaking hypothetically here.) Obviously restoring from a backup is still there as a last resort in this case, but you really don't want to have to go there.

Re:Why favor PostgreSQL over MariaDB/MySQL? by pas on Tuesday September 05, 2017 @05:20AM (#15173603)
Galera builds on that, and it works very well. It has weak points, but if you build a working Galera cluster and test it (test the failovers, test [re]bootstrapping a node), you can then be confident that it'll continue to work as intended for a long time.

There are rough edges. Upgrades, recovery from corrupted hot backup, etc. But it's very easy to rebuild the cluster in flight, for example when changing some fundamental cluster property, or after a PEBKAC, (with a not too big read-only window), though it requires plus one node, a regular MySQL/MariaDB server that acts as a donor (where Galera can bootstrap from), but that's not too surprising if you want to at least serve read-only requests.

Re:Why favor PostgreSQL over MariaDB/MySQL? by seanp2k2 on Tuesday September 05, 2017 @06:14AM (#15173833)
You also can't use Galera on RDS, which is a deal breaker for some: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_M...
Re:Why favor PostgreSQL over MariaDB/MySQL? by stephenr on Tuesday September 05, 2017 @07:41AM (#15174204)
Sounds like a reason not to use RDS more than a reason not to use Gallera.
Re:Why favor PostgreSQL over MariaDB/MySQL? by pas on Tuesday September 05, 2017 @11:15AM (#15176022)
Why would you use RDS? AWS is overpriced.

If you really want no-ops deployment, use something that requires minimal amount of ops, like ElasticSearch. Just give it an obscene amount of RAM and it'll work fine for ages.

RDS or not, if you want to run a big site, you'll need (dev)ops expertise. And a lot of it. Famously, Netflix - the big full-cloud business, - employs the most aggressive performance engineering and other "auxiliary" development groups. (Because AWS is fckn!1 expensive, and when you can run on a thousand less nodes, it'll cost you less. And yes, of course Netflix gets a big discount, but you won't, at least not initially.)

Re:Why favor PostgreSQL over MariaDB/MySQL? by manigandham on Tuesday September 05, 2017 @08:30PM (#15180217)
Neither Netflix nor any of the top "startups" are anywhere near aggressive performance. In fact they're usually full of slow fragile tech that only looks great to blog about.

HFT, adtech, scientific engineering and many other industries are magnitudes farther ahead.

Re:Why favor PostgreSQL over MariaDB/MySQL? by stephenr on Tuesday September 05, 2017 @12:28PM (#15176716)
> no-ops deployment

This is the worst joke in tech really. Developers/Managers all jumping on the "cloud" bandwagon because "hey we don't need ops" and then you end up with "Galera is such a POS, you can't use it with RDS".. <facepalm>

Re:Why favor PostgreSQL over MariaDB/MySQL? by otterley on Wednesday September 06, 2017 @01:53AM (#15181521)
> If you really want no-ops deployment, use something that requires minimal amount of ops, like ElasticSearch. Just give it an obscene amount of RAM and it'll work fine for ages.

I can assure you this is not the case if your indexes are very large and their number is constantly growing, and/or clients are doing very complex queries that stress the system.

Re:Why favor PostgreSQL over MariaDB/MySQL? by pas on Thursday September 07, 2017 @04:48PM (#15195570)
The same thing applies to anything really, if you try to "shard" (partition, or simply do multi tenancy) based on files, MySQL tables, MongoDB collections, and of course elasticsearch indexes.

And you have to plan ahead and start with a large number of shards, to be able to scale your ES cluster.

Yet it's much better than trying to get some kind of SQL based cluster going, because those require knowledge of a lot of subtle internal details.

Re:Why favor PostgreSQL over MariaDB/MySQL? by barrkel on Tuesday September 05, 2017 @09:05AM (#15174692)
It's multi-master from MySQL's settings perspective.

Restoring a backup takes minutes for multi-TB restores.

Re:Why favor PostgreSQL over MariaDB/MySQL? by IgorPartola on Tuesday September 05, 2017 @09:21AM (#15174799)
Just because MySQL calls it multi-master doesn't make it so. What you described is single master with a hot spare. Real multi master is when a client can write to both servers and they will be consistent by the magic fairy dust that is replication.
Re:Why favor PostgreSQL over MariaDB/MySQL? by kelnos on Tuesday September 05, 2017 @07:43PM (#15180007)
How exactly do you get that multi-TB backup onto the database server's disk so quickly? Even with a gigabit network interface, that's only 125MB/s, which is over two hours[0] to transfer 1TB. Even if you have a 10 gigabit network, that's ~13 minutes[0].

Also consider if the backups are compressed -- a 1TB compressed file also takes time to uncompress. If the data compresses well, you could even run into the disk being the bottleneck, not the network.

[0] Well, more than that; those numbers assume you're actually getting the link rate with no overhead, which of course isn't reality.

Re:Why favor PostgreSQL over MariaDB/MySQL? by beagle3 on Tuesday September 05, 2017 @02:26PM (#15177854)
Minutes for multi TB restores? Only if both your main and your backup are on SSD, which is still not common for multi TB databases, I think.

1TiB=1,000GiB; if your drives do 300MB/sec, that's still one hour.

Re:Why favor PostgreSQL over MariaDB/MySQL? by CaptainZapp on Tuesday September 05, 2017 @08:56AM (#15174635)
Interesting side note:

A significant number of Oracle shops use Sybase Replication Server to replicate from an Oracle - to an Oracle database.

Go figure...

Re:Why favor PostgreSQL over MariaDB/MySQL? by will_be_no_ai on Tuesday September 05, 2017 @01:26PM (#15177271)
RE: Oracle Replication - Have you looked at DbVisit? Compared to the PhD you need for GoldenGate, you can get by with a high school diploma with this stuff.

http://www.dbvisit.com/

Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @03:12AM (#15173093)
> Nearly everything else in Postgres is set-it-and-forget-it.

There are many people who would disagree with that. Talking to Uber engineers would probably be a good idea to dispel that myth.

Re:Why favor PostgreSQL over MariaDB/MySQL? by glogla on Tuesday September 05, 2017 @05:11AM (#15173574)
Uber switched from MySQL used as relational database, to Postgres used as relational database, to MySQL used as key-value store.

Nobody is saying MySQL is a bad key-value store!

Re:Why favor PostgreSQL over MariaDB/MySQL? by pmarreck on Tuesday September 05, 2017 @09:49AM (#15175087)
Is key-value store the most stable scalable architecture? Reddit, I believe, uses the same idea
Re:Why favor PostgreSQL over MariaDB/MySQL? by fusiongyro on Tuesday September 05, 2017 @11:17AM (#15176037)
To restate your other reply, key-value allows you to sweep consistency problems under the rug. What happens if two transactions try to update the same row? One of the transactions fails. What happens if two clients write different values to the same key in a multi-master key-value store? The last one in wins and the first write is just lost.

Many of the NoSQL databases have provisions for these situations so they can handle both writes but bubble the decision up to the application layer. CouchDB, for instance, will tell you you've got multiple versions and has a way for you to tell it how to resolve the conflict. CRDTs let you bake the logic in for handling a conflict. MySQL does not do any of that. If your database consists of "likes" and other low-value data like that, you may not care if you're losing data at some low rate. Reddit is in that situation, and the decision seems to work for them. But I don't think it generalizes to all situations.

Re:Why favor PostgreSQL over MariaDB/MySQL? by softawre on Tuesday September 05, 2017 @10:38AM (#15175627)
If you give up ACID (the C) you can scale more (the P), sure.

https://en.wikipedia.org/wiki/CAP_theorem

Re:Why favor PostgreSQL over MariaDB/MySQL? by fusiongyro on Tuesday September 05, 2017 @03:18AM (#15173116)
I read their article, and a dozen of the rebuttals. If you want to use MySQL badly enough, you can.
Re:Why favor PostgreSQL over MariaDB/MySQL? by merb on Tuesday September 05, 2017 @05:29AM (#15173644)
> There are many people who would disagree with that. Talking to Uber engineers would probably be a good idea to dispel that myth.

not a good idea, somebody who let their database master run out of storage space is probably not a good source.

Re:Why favor PostgreSQL over MariaDB/MySQL? by user5994461 on Tuesday September 05, 2017 @06:00AM (#15173772)
Uber is a bad reference for good practices.
Re:Why favor PostgreSQL over MariaDB/MySQL? by jeltz on Tuesday September 05, 2017 @09:47AM (#15175048)
The Uber blog post got a lot of things wrong and if that is representative of their knowledge of PostgreSQL I would not suggest using them as an authority on PostgreSQL or databases in general.
Re:Why favor PostgreSQL over MariaDB/MySQL? by fulafel on Tuesday September 05, 2017 @02:08AM (#15172868)
> The guy has deliberately changed a default setting (strict_mode) to make MariaDB/MySQL look worse. When someone pointed that out in the comments, he left it unresponded.

I don't think the comments read like that. Someone pointed out that some MySQL variants have changed the default in a recent version and the author criticised the defaults, so the implication is that he wasn't using a bleeding-edge MySQL installation and got the previous defaults.

Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @02:20AM (#15172913)
Agree, I might have misread the discussion. However, strict mode is on my default since MySQL 5.7 (released in 2015) and MariaDB 10.2 (which is also the version he was using). So he changed that, but didn't explicitly state it. Even when multiple people mentioned sql_mode.
Re:Why favor PostgreSQL over MariaDB/MySQL? by mmarx on Tuesday September 05, 2017 @03:39AM (#15173215)
> However, strict mode is on my default since MySQL 5.7 (released in 2015) and MariaDB 10.2 (which is also the version he was using). So he changed that, but didn't explicitly state it.

From the comments of the original article, the actual version he was using is 10.0: > this is the default version coming with Fedora core 23 (mariadb.x86_64, 1:10.0.28-1.fc23).

Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @04:08AM (#15173331)
OK, I see it now, thanks. I would even edit my original comment if I could. Still, the original article is biased without mentioning strict mode, the fact that it's been recommended to turn it on in any serious deployment for years, and that it is enabled by default in the latest MySQL/MariaDB releases.

There are reasons to choose PostgreSQL over MySQL (and vice versa), but the article is certainly an example of unfair evangelism.

Re:Why favor PostgreSQL over MariaDB/MySQL? by mseebach on Tuesday September 05, 2017 @04:34AM (#15173413)
It's a pretty damning point against MySQL that there's a default setting that you have to know to change, or else the DB will happily throw away your data.

A lot of the evangelism against MySQL is rooted in a deep skepticism against letting a DB that would even have such a feature, much less leave it on by default for years after sort-of admitting that it's probably a bad idea, anywhere near your data. I loved MySQL back in the day when it would work straight out of the box on both Windows and Linux (and god knows not a lot of web software did back then), and Postgres was always, frankly is still, a bit opaque to actually get from zero to one. But I also remember discovering the varchar overflow and the users being pissed at me for losing their data. Luckily it wasn't a really important field and we discovered it reasonably fast, so fallout was contained. But the same app actually dealt with payments, it could have been much worse.

It's basically a country song: MySQL is the kind of guy that's tons of fun, always the centre of the party, but used to disappear for multi-day benders without a word, but have now cleaned up and is disappointed that his high school sweetheart prefers the boring guy who went to college, got a job and was never late for a date.

Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @04:49AM (#15173486)
True, but then you can sing a similar song about PostgreSQL being the kind of guy that is cool all around, and is always there for that high school sweetheart, but still that badass MySQL gets all the fun and is always center of the party, which is oh so wrong.
Re:Why favor PostgreSQL over MariaDB/MySQL? by gmac on Tuesday September 05, 2017 @03:03AM (#15173066)
Which is already telling something about PostgreSQL evangelism.

No. Speaking as an outsider, the Postgres community is about the nicest (and smartest) there is.

Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @03:07AM (#15173080)
I know what I'm talking about. Over the last couple of years I had to speak to many people in the PostgreSQL community. While there are indeed many smart and nice people with balanced views and opinions there, the majority has this ideological bias. With ideology being that PostgreSQL is superior to MySQL in every single way. All counter-examples and arguments are usually ignored. I think it's something unique to PostgreSQL community, I've never met anything like that in other technical communities.
Re:Why favor PostgreSQL over MariaDB/MySQL? by fusiongyro on Tuesday September 05, 2017 @03:13AM (#15173100)
As someone who might fairly get scolded for this, we feel like praising MySQL's features is a bit like enjoying the recessed lighting and granite counters in a house whose roof is actively leaking.

There are certainly features MySQL has that Postgres doesn't, but data integrity is problem 1, and most of us got burned by MySQL on that one at some point before we got here. Or, we deployed MySQL and then found out that the features we were depending on were InnoDB-only, but switching to InnoDB cratered our performance. Or we tripped on one too many of MySQL's numerous special cases or silent limitations.

You can use MySQL productively. You can even benefit from its special features. But the thing taken together is a bit of a mine field.

Postgres has some false advertising issues too ("object-relational"?) but the day-to-day living with it is a lot nicer, because the roof doesn't leak. I can live without the granite counters.

Re:Why favor PostgreSQL over MariaDB/MySQL? by imron on Tuesday September 05, 2017 @03:41AM (#15173225)
> and most of us got burned by MySQL on that one at some point before we got here

Using 3 bytes per codepoint for UTF8 was the one that got me to switch (boy wasn't that fun to discover).

Yes it was fixed a while ago now, but it wasn't fixed when I needed it and so I switched to PostgreSQL and never looked back.

Re:Why favor PostgreSQL over MariaDB/MySQL? by cesarb on Tuesday September 05, 2017 @07:25AM (#15174113)
> Or, we deployed MySQL and then found out that the features we were depending on were InnoDB-only, but switching to InnoDB cratered our performance.

Or worse, we were expecting InnoDB but the default on the mysqld which comes with the RHEL version the client used to deploy our software was MyISAM, so the cascade didn't work when deleting a row, and the dangling reference caused an exception deep in the framework we were using, making parts of our software stop working.

Re:Why favor PostgreSQL over MariaDB/MySQL? by dhd415 on Tuesday September 05, 2017 @08:48AM (#15174581)
Describing the production operation of MySQL as a minefield is an excellent analogy. I maintained a list of the mines I stepped on in the last job I had where MySQL was used and here are the two I encountered with the biggest blast radius:

* If you have pre-5.6.4 date/time columns in your table and perform any kind of ALTER TABLE statement on that table (even one that doesn't involve the date/time columns), it will TAKE A TABLE LOCK AND REWRITE YOUR ENTIRE TABLE to upgrade to the new date/time types. In other words, your carefully-crafted online DDL statement will become fully offline and blocking for the entirety of the operation. To add insult to injury, the full table upgrade was UNAVOIDABLE until 5.6.24 when an option (still defaulted to off!) was added to decline the automatic upgrade of date/time columns. If you couldn't upgrade to 5.6.24, you had two choices with any table with pre-5.6.4 types: make no DDL changes of any kind to it or accept downtime while the full table rewrite was performed. To be as fair as possible, this is documented in the MySQL docs, but it is mind-blowing to me that any database team would release this behavior into production. In other words, in what world is the upgrade of date/time types to add a bit more fractional precision so important that all online DDL operations on that table will be silently, automatically, and unavoidably converted to offline operations in order to perform the upgrade? To me, this is indicative of the same mindset that released MySQL for so many years with the unsafe and silent downgrading of data as the default mode of operation.

* Dropping a table takes a global lock that prevents the execution of ANY QUERY until the underlying files for the table are removed from the filesystem. Under many circumstances, this would go unnoticed, but I experienced a 7-minute production outage when I dropped a 700GB table that was no longer used. Apparently, this delay is due to the time it takes the underlying Linux filesystems to delete the large table file. This was an RDS instance, so I had no visibility into the filesystem used and it was probably exacerbated by the EBS backing for the RDS instance, but still, what database takes out a GLOBAL LOCK TO DROP A TABLE? After the incident, I googled for and found this description of the problem (https://www.percona.com/blog/2009/06/16/slow-drop-table/) which isn't well-documented. It's almost as if you have to anticipate every possible way in which MySQL could screw you and then google for it if you want to avoid production downtime.

There are others, too, but to this day, those two still raise my blood pressure when I think about them. In addition to MySQL, I've pushed SQL Server and PostgreSQL pretty hard in production environments and never encountered gotchas like that. Unlike MySQL, those teams appear to understand the priorities of people who run production databases and they make it very clear when there are big and potentially disrupting changes and they don't make those changes obligatory, automatic, and silent as MySQL did.

Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @03:27AM (#15173156)
Data integrity is of course important, and MySQL indeed has a weak story here, especially in older versions.

Is PostgreSQL flawless when it comes to data integrity? No, that would also be false advertising. Some examples:

- data checksums are disabled by default (silent data corruptions!), and the user manual specifically warns they are not cheap. And the reasons they are expensive is that PostgreSQL does not support O_DIRECT IO;

- removing a file on the filesystem may lead to a silent loss of data in PostgreSQL: https://www.postgresql.org/message-id/c571dfc5-91b0-0df2-4e3...

- some important control structures (which also impact data visibility and thus, integrity) are not even protected by checksums: https://www.postgresql.org/message-id/CAA4eK1L%3DXS3k7X9pfYK...

- there are no tools to verify replication integrity, similar to pt-table-checksum for MySQL; that would require statement-based replication, which is not supported in PostgreSQL, even in the next major release

Re:Why favor PostgreSQL over MariaDB/MySQL? by jeltz on Tuesday September 05, 2017 @04:38AM (#15173433)
Why would O_DIRECT make checksums any cheaper? You always update the checksum at the same time as the data so I cannot see how O_DIRECT could matter.

I am pretty sure the real reasons for checksums being off by default are two:

1) That you need to WAL log hint bit changes if for checksums to work. Hint bits are part of PostgreSQL's MVCC implementation and that you do not need to WAL log them is a clever optimization. This extra WAL traffic can at least in theory hurt some workloads.

2) Probably most importantly: nobody has provided the benchmarks necessary to show that the cost is not too high.

Re:Why favor PostgreSQL over MariaDB/MySQL? by jandrewrogers on Tuesday September 05, 2017 @05:54AM (#15173751)
Checksums on modified pages should only be computed immediately prior to transferring pages to disk. DIRECT_IO makes that transfer point explicit so you can compute the checksum exactly once per transfer regardless of the number of page modifications. If you use the kernel cache like PostgreSQL, you must apply the checksum pessimistically because you don't know when the page will _actually_ be written back to disk by the kernel in-between page modifications.

Computing page checksums burns quite a bit of memory bandwidth, and memory bandwidth is a major resource bottleneck in modern databases. In the DIRECT_IO case, the checksum memory bandwidth should be the same as your storage bandwidth; pessimistic checksumming without DIRECT_IO can burn memory bandwidth that significantly exceeds the storage bandwidth.

Particularly in cases where you have modern, high-performance storage devices, like PCIe connected flash arrays, you can't afford to burn memory bandwidth on checksumming beyond the minimum technically required.

Re:Why favor PostgreSQL over MariaDB/MySQL? by jeltz on Tuesday September 05, 2017 @07:04AM (#15174031)
As I explained in another reply, PostgreSQL does no write directly to the files/file cache. It has its own buffer cache and only calculates the checksum when flushing dirty pages to disk (where PostgreSQL does a normal, cached write syscall and then fsyncs). The lack of O_DIRECT causes other performance issues, but not this one.
Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @04:54AM (#15173501)
Without O_DIRECT, the page may be updated multiple times in the page cache before it hits the disk. The only thing PostgreSQL can do is to update the checksum before expelling the page from its own cache, so it will be doing unnecessary work in write-intensive workloads. But yes, hint bits and WAL is also a good point.
Re:Why favor PostgreSQL over MariaDB/MySQL? by jeltz on Tuesday September 05, 2017 @07:02AM (#15174022)
But PostgreSQL does not update the file directly so this is not an issue. Instead PostgreSQL does all updates in its buffer cache, and then has a background writer which flushes modified shared buffers to the file (but without using O_DIRECT), and then finally it fsyncs the modified file. The window between modifying the file and fsyncing is usually not big so almost always when a page is updated multiple times that will happen before a page is written from the buffers to the OS's file cache.

The above is obviously inefficient which slows down writes, but checksums are not affected by this since those are only calculated on flush. The costs of not using O_DIRECT are 1) extra work on flushing to disk, 2) IO spikes due to the unpredictable nature of when and in what order the OS decides to flush to disk, and 3) wasted RAM. The main benefit is that being able to use the file cache on read loads (by tuning PostgreSQL with small buffers) is that PostgreSQL is nicer to run on shared machines, for example my laptop, since the OS can steal back the read cache when PostgreSQL stops using it.

Re:Why favor PostgreSQL over MariaDB/MySQL? by floatboth on Tuesday September 05, 2017 @11:02AM (#15175876)
> data checksums are disabled by default (silent data corruptions!)

Use ZFS.

> removing a file on the filesystem may lead to a silent loss of data in PostgreSQL

Don't remove database files. LOL. Looking at the link:

> data file is zeroed after some power loss(it is the most known issue on XFS in the past)

Use ZFS.

> not even protected by checksums

Use ZFS.

Re:Why favor PostgreSQL over MariaDB/MySQL? by rleigh on Tuesday September 05, 2017 @11:17AM (#15176036)
The object-relational stuff works (table inheritance). Or at least, it did the last time I tried it out a few years back; I've never used it in production.
Re:Why favor PostgreSQL over MariaDB/MySQL? by shangxiao on Tuesday September 05, 2017 @03:36AM (#15173196)
Your insistence on replying to every single comment on this thread combined with your statements like "I know what I'm talking about" (and you don't) suggests to me that perhaps you're an evangelist yourself?
Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @03:41AM (#15173230)
It's just something I care about. You may call me an evangelist if you like, I consider myself an anti-evangelist.
Re:Why favor PostgreSQL over MariaDB/MySQL? by mateuszf on Tuesday September 05, 2017 @06:44AM (#15173928)
Indeed you're not very effective in prasing MariaDB.
Re:Why favor PostgreSQL over MariaDB/MySQL? by glogla on Tuesday September 05, 2017 @05:04AM (#15173532)
> - synchronous multi-master cluster (Galera, Group Replication)

Which doesn't work, see [1]. What other features of those you listed the authors claim that work, and just don't when you look deeper?

Lot of the big companies are using MySQL as a NoSQL database, and that's not a bad way to use MySQL, but it's a pretty bad relational database, see [2].

[1]: https://aphyr.com/posts/327-call-me-maybe-mariadb-galera-clu...

[2]: https://grimoire.ca/mysql/choose-something-else

Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @05:10AM (#15173569)
Let me just tell you that I've read both links before.
Re:Why favor PostgreSQL over MariaDB/MySQL? by zimpenfish on Tuesday September 05, 2017 @05:32AM (#15173663)
If you've read the aphyr link with this (and the rest of his conclusion):

> Unfortunately, even in totally healthy clusters, with no node failures or network failures, Galera Cluster does not satisfy its claims of Snapshot Isolation

...how on earth can you straight-facedly claim that it's a plus point for MySQL over PostgreSQL?

Re:Why favor PostgreSQL over MariaDB/MySQL? by porker on Tuesday September 05, 2017 @02:34AM (#15172965)
I didn't realise a few of these existed, so thanks.

> - page-level encryption

This got me excited, but for anyone else looking: to keep the key securely (not in a file on the DB server, where an attacker can get it + the DB files) you need to but MySQL Enterprise Edition. Quoting from https://dev.mysql.com/doc/refman/5.7/en/innodb-tablespace-en...:

> The InnoDB tablespace encryption feature in non-enterprise editions of MySQL uses the keyring_file plugin for encryption key management, which is not intended as a regulatory compliance solution. Security standards such as PCI, FIPS, and others require use of key management systems to secure, manage, and protect encryption keys in key vaults or hardware security modules (HSMs).

Re:Why favor PostgreSQL over MariaDB/MySQL? by marcosdumay on Tuesday September 05, 2017 @11:24AM (#15176109)
Well, personally what I see is people comparing a group of developers that are adamant on never corrupting any data, where everything is secondary and will refuse to push any feature that may cause problems with a group that is adamant on increasing market share, if it's by doing a low quality MVP so be it, that I have seen corrupting data on production several times, and whose software still carries the scars from those MVP's errors.

Yes, MySQL is all featureful¹. The only thing missing there is guarantees that your data will stay good.

1 - Some of those are "no, we won't ever implement it" features that will do nothing but eat your data by design. Why would you ever want them in a persistence layer? Cache on memory somewhere better.

Re:Why favor PostgreSQL over MariaDB/MySQL? by bonesss on Thursday September 07, 2017 @05:34AM (#15190236)
> Some of those are "no, we won't ever implement it" features that will do nothing but eat your data by design. Why would you ever want them in a persistence layer? Cache on memory somewhere better.

I feel a significant motivation for MySql development are lightweight webapps on PHP like Wordpress where the developers are beholden to a third-party hosting environment and have a significant front-end focus...

From that perspective I can see why bells and whistles that would be moronic in a normal application would start sticking to the database itself.

MongoDB suffers from some of the same market pressure: being easy to demo and get from 0 to SAP in 10 min is great, but having to choose crazy insecure defaults and be open for data loss in order to get there is a showstopper in Enterprise circles. In both cases the ironic demands for competent administration are much higher because of all the potential for foot-shooting.

"It's always worth it to take the pain up front."

Re:Why favor PostgreSQL over MariaDB/MySQL? by antoaravinth on Tuesday September 05, 2017 @06:18AM (#15173848)
There is one point I need to add it here. Note that I'm not DB expert, but I need to say why I prefer Postgres over Mysql.

Create a table like the following:

create table user (name varchar(4));

MySql:

insert into user (name) values ('antoaravinth');

The above statement works even though I have given the size of my varchar as 4! And retrieving gives me `anto`!!

Postgres:

insert into user (name) values ('antoaravinth');

Stops me there with the relevant exception! That shows how Postgresql is doing small things right.

After seeing this, I never used MySql!

Re:Why favor PostgreSQL over MariaDB/MySQL? by sigi45 on Tuesday September 05, 2017 @07:37AM (#15174175)
As said in many other comments: This is because you used MySQL in non strict mode. You don't run MySQL on Production in non strict mode.
Re:Why favor PostgreSQL over MariaDB/MySQL? by thehardsphere on Tuesday September 05, 2017 @10:59AM (#15175850)
As said in many other comments, the idea that there is even a "strict mode" which was not on by default for many years is itself a problem and a red flag for other problems.
Re:Why favor PostgreSQL over MariaDB/MySQL? by koffiezet on Friday September 08, 2017 @09:45AM (#15200071)
Tell that to developers who develop with the default config and then expect that to work in "Production".
Re:Why favor PostgreSQL over MariaDB/MySQL? by grogers on Tuesday September 05, 2017 @07:49AM (#15174255)
MySQL has similar issues to postgres vacuum. If 'checkpoint age' gets too high throughput drops by ~5x to prevent WAL wrapping. We hit this in production when using 5.5. They've made a lot of improvements to flushing in recent versions, but it isn't a strict advantage. With both DBs as long as you monitor you would be fine.
Re:Why favor PostgreSQL over MariaDB/MySQL? by feld on Tuesday September 05, 2017 @11:28AM (#15176167)
> - optimizer hints

> - optimizer tracing

Hints are bad. They always have been. If you need hints your query planner is broken.

https://wiki.postgresql.org/wiki/OptimizerHintsDiscussion

Even Oracle Tom says DO NOT USE HINTS IN PRODUCTION! Report the bug to Oracle and let them fix it properly.

Re:Why favor PostgreSQL over MariaDB/MySQL? by will_be_no_ai on Tuesday September 05, 2017 @01:16PM (#15177159)
As a general recommendation maybe this is ok. But, unrealistic relative to the world we live in. Sometimes you need to use hints. Oracle / PostgreSQL / what have you, are not perfect nor are developers writing the SQL.

Is your customer going to wait for the next version of Oracle? Is your dev team going to fix some sev 3 performance bug?

Hints allow you to use your brain to help the optimizer. Why would you make a hard rule not to use them? Why else are they there?

Re:Why favor PostgreSQL over MariaDB/MySQL? by feld on Wednesday September 06, 2017 @09:08AM (#15183319)
I won't speak for Oracle because it's always been a "if you have the money you can get a custom patch for the behavior you want" game.

But for Postgres, you contact the developers. If your problems are costing you so much money why wouldn't you just hire a core developer on the Postgres team or hire EnterpriseDB on contract to work on your issues? They'll fix the bug, upstream the fix, and roll you updated packages you can push out to your servers. Not entirely different than working with Oracle, except you are working in the open source world.

Hints are bad. Next time you upgrade your database you may end up with worse performance due to other changes in the query planner. Once your data crosses a certain size threshold it may also start performing worse. They are unpredictable. You will never know when they could break. Using them is the wrong solution.

Re:Why favor PostgreSQL over MariaDB/MySQL? by will_be_no_ai on Wednesday September 13, 2017 @01:54PM (#15240771)
I agree with paragraph three. A hint is a directive. Now we are stuck with it. Bad stuff can ensue...maybe. But, maybe my customer is pissed now. Total cost to fix: a couple hours.

If I had the budget and developers to make PostgreSQL as performant as Oracle, I would be living on an island next to Larry.

Re:Why favor PostgreSQL over MariaDB/MySQL? by teddyh on Tuesday September 05, 2017 @04:54AM (#15173498)
EDIT: Never mind, I read too much into what another commenter wrote.
Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @04:56AM (#15173511)
No, this is all from MySQL Community Edition.
Re:Why favor PostgreSQL over MariaDB/MySQL? by teddyh on Tuesday September 05, 2017 @05:06AM (#15173541)
Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @05:11AM (#15173572)
Does that comment say I'm listing features only available in MySQL Enterprise Edition?
Re:Why favor PostgreSQL over MariaDB/MySQL? by teddyh on Tuesday September 05, 2017 @05:45AM (#15173721)
It does say that one feature you’re listing is not really sensible to use without the Enterprise Edition, but you’re right, it does not say that. Original comment redacted.
Re:Why favor PostgreSQL over MariaDB/MySQL? by kaamos on Tuesday September 05, 2017 @06:35AM (#15173896)
It is, in fact sensible without Enterprise Edition. The only thing it says is that page-level encryption in Community Edition is not intended as a regulatory compliance solution. Nothing more, nothing less.

Even in case you care about regulatory compliance, there are other options besides Enterprise Edition.

Re:Why favor PostgreSQL over MariaDB/MySQL? by porker on Wednesday September 06, 2017 @06:02AM (#15182396)
What are the other options, and when would page-level encryption in Community Edition be useful?

If I'm understanding it correctly, page-level encryption is to protect against someone gaining access to the DB server and copying the files off it. If the key is stored in a file on this DB server, I might as well not bother encrypting the pages.

Re:Why favor PostgreSQL over MariaDB/MySQL? by sigi45 on Tuesday September 05, 2017 @07:34AM (#15174147)
master-master is evil.

Not sure of your other points, i have no need for them.

What i really don't like on MySQL (and i don't care for a lot of other stuff): MySQL 5.6 (yeah don't forget your version numbers) really sucks for queries with or.

It sucks to write 2 selects with an union which is 100x faster than the same query with one select and ONE or.

Re:Why favor PostgreSQL over MariaDB/MySQL? by Nican on Tuesday September 05, 2017 @03:32AM (#15173174)
I have been curious to ask someone who is knowledgeable about databases/MySQL: Spanner has a feature for creating interleaved tables, which helps data locality when performing joins on a distributed database. [1] Is this an important feature for a large database, and does MySQL provide anything similar?

[1] https://cloud.google.com/spanner/docs/schema-and-data-model#...