4 ms·
For the last decade or so, since I first became acquainted with databases, the HN crowd has said “Use PostgreSQL.” And every few weeks there’s a company blog po
by freyir 6y ago
For the last decade or so, since I first became acquainted with databases, the HN crowd has said “Use PostgreSQL.” And every few weeks there’s a company blog post mentioning that they use MySQL. Why is this?
- jniedrauer 6y agoI think it's inertia. A lot of people have been using MySQL for 10+ years and it's still Good Enough. It takes them an extra 10 minutes to figure out how authentication or permissions work in postgres, and that extra 10 minutes isn't worth it.
- pg_bot 6y agoMySQL is certainly more popular, but that doesn't necessarily mean it is a better database from a technical standpoint. MySQL is a fantastic piece of technology and it will likely serve most of your needs if you are building websites. If you have used it before and are familiar with it there may not be a great reason to change. You also have to consider that databases are "sticky" products. Once the choice is made it is unlikely to change for the lifetime of the project due to high switching costs so there is not really an incentive to go out of your way to learn about multiple databases. MySQL was basically the default database for developing web applications from 1998-2013. (It is the "M" in the LAMP stack) It gained this position by being free to use, reliable and stable. This began a virtuous cycle where more companies catered to MySQL users. Deploying, managing, and MySQL was easier since everyone catered to the audience which drove a virtuous cycle of more developers using MySQL. A lot PostgreSQL's popularity can be traced to Heroku where it was the default choice for a database. Heroku made it even easier for developers to deploy their applications to the internet. Instead of having some janky build process you would just type "git push heroku master" and you changes would be live in a matter of minutes. This ease of deployment drove the virtuous cycle for PostgreSQL. For the web it's unlikely that choosing either database would be a mistake. They both are great options. Going into the technical reasons why I believe PostgreSQL is a superior if you don't know what to choose would be a separate post in and of itself, but I've already gone on long enough.
- skunkworker 6y agoThere are some tools that make horizontal sharding much easier, like Vitess which is MySQL only. But most businesses won't come close to needing these kinds of capabilities. I would say for anyone starting out and worrying about how large a single node can scale, Postgres can run well on aa 64/128core server, 2TB ram and 20TB ZRAID6 with a chain of read replicas. This can be done out of the box on Postgres without much issue and can get many businesses quite far, but once you go to the lots and lots of TB, or you have specific write latency, consistency, or other requirements, you have to evaluate multiple databases against your company's specific usage patterns and data, as no benchmark will give you a good idea.
- rzzzt 6y agoMulti-master replication was also a MySQL-only functionality that came built in, while on Postgres you had to pick a third-party solution (I think...)? Did that change in recent times?
- pezezin 6y agoI have been looking for how to set up multi-master replication, and as far as I know you still need a third-party solution.
- samlambert 6y agoVertical scaling and scaling out via replicas is only excusable in a world where sharding isn't a solved problem. With a bunch of read replicas you have to deal with eventual consistency when you get replication lag as well as the inability to scale writes. If you shard out horizontally you get write scaleability, and read scalability with much less chance of replication delay. You like likely be reading from the master node most of the time. You also gain a bunch of operational flexibility, and smaller failure domains.
- mtVessel 6y agoHow does horizontal sharding help with HA/DR concerns?
- seer 6y agoApart from the other reasons people have mentioned - the headline “we switched from postgres to $database (for example MySQL) is so unusual it warrants a justification. PG is so good that you really need to be a very niche case for there to be objective reasons to do such a switch. And granted the bigger the company the more intricate and unique its requirements. I personally advise people to just start with PG and if they encounter very unique requirements that for some reason PG can’t be tuned to - then do the switch.
- acomjean 6y agoI use MySQL. From what I’ve read Postgres is better. As a developer I’ve used MySQL a lot, installed it myself in local environment and used it with fairly large tables. It’s very reliable and I’m generally comfortable with it. Once it’s running I don’t give it much thought frankly, so I’m not itching to change.
- zozbot234 6y agoLegacy. MySQL used to be very popular in the late-90s and early-2000s as part of a broader MySQL+PHP web stack. But that was before PostgreSQL got good enough (including wrt. performance) for that sort of simple use case. Nowadays, there's really no reason not to go for Postgres.
- dugmartin 6y agoI also think it was because MySQL didn’t require vacuuming so small hosting providers and resellers didn’t have to deal with support issues around that. I know when I was looking around in the late 90s for a database it was a deciding element for me.