Live data from Hacker News

Ask HN: Is PostgreSQL better than MySQL?

news.ycombinator.com

41–50 of 83 posts

Re: Ask HN: Is PostgreSQL better than MySQL?

#41
Echoing VLM:

No, not really. All else being equal:

I'd say that today, it's much muddier than it was maybe ten years ago, before the data science explosion and cloud explosion.

That is, turn-key cloud Postgres is not Y2K Postgres, and MySQL post-Maria is not Y2K MySQL. In the former, administration of Postgres has gotten much easier since Heroku got involved and Andy Pavlo started talking about self-driving databases. In the latter, MySQL can do text search well enough that I sat pair programming this with a young engineer around 2016-2017 when I'd have argued prior that you were wasting your time.

In the end, it probably comes down to how you rank your requirements:

usability, performance, suitability for a particular purpose.

Things like postgis and pgrouting may have little equal, so like others, those can be huge differentiators if you need them and see the advantage in db backend computation without invoking the N+1 query problem in aggregate.

I'm biased since I used MySQL before the inefficient backend was deprecated and I used PostgreSQL to do all manner of experimental EAV implementations using bjson including various forms of tuples from Rich Hickey.

All hail Stonebraker.

Re: Ask HN: Is PostgreSQL better than MySQL?

#42
I think the case of "it depends" mattered more in the days of shared webhosts and basic PHP sites when the relatively lightweight MySQL made more sense. These days, not only is PostgreSQL designed better and has more features (our key usecase was RLS) but its governance is better. You're not tied to the monster called Oracle and Postgres has a very healthy development community that isn't overwhelmingly dominated by any one entity.

I recommend https://pgloader.io if you're currently on MySQL and want to switch your existing app.

Re: Ask HN: Is PostgreSQL better than MySQL?

#43

It depends: the projects make different trade offs and support different points of extension. I find it useful to remember that MySQL has various storage engines (that make different trade offs, and may themselves have different options such as various row formats), when using for instance the default of InnoDB knowing that it uses index organized (meaning stores the data in a btree as opposed to heap) tables can inf…

As far as making/performing modifications to the schema/data, as others have stated, transactional ddl is a huge feature for Postgres and makes migrations much more straightforward in my experience.

Any DDL worthy of the name (table rewrite needed) in MySQL needs to be done with pt-online-schema-change or gh-ost. With DDL, you want to e.g. have it tune the I/O load of the migration so it doesn't interfere too much with production load. In practice, pt-osc / gh-ost means you have a kind of transaction, because the rewritten table doesn't take the place of the old one until the rename at the end. That's essentially an atomic commit.

Re: Ask HN: Is PostgreSQL better than MySQL?

#44

I've used both for similar amounts of time at this point. I know a _lot_ about the implementations details of MySQL, and a helluva lot less about PostgreSQL, and that's because I hit _way_ more landmines with MySQL. It's just so easy to use it the wrong way and get saddled with ugly problems for months or years. To be fair, my PostgreSQL experience is more recent, and both products have matured a bunch, but I've also…

/me cries in range locks and mutexes

Re: Ask HN: Is PostgreSQL better than MySQL?

#45

Don't miss out on SQLite - https://news.ycombinator.com/item?id=31159281

It is only good if you do few writes, with at least seconds in between.

Incorrect. Here are some actual numbers: https://blog.wesleyac.com/posts/consider-sqlite

> Writing 512 byte blobs as separate transactions, in WAL mode with synchronous=normal3, temp_store=memory, and mmap enabled, I got 13.78μs per write, or ~72,568 writes per second.

Re: Ask HN: Is PostgreSQL better than MySQL?

#46

Don't miss out on SQLite - https://news.ycombinator.com/item?id=31159281

It's a little off-topic, but agreed! I use SQLite on production. Here are more resources talking about the trade-offs:

- https://blog.wesleyac.com/posts/consider-sqlite

- https://fly.io/blog/all-in-on-sqlite-litestream/

Re: Ask HN: Is PostgreSQL better than MySQL?

#47
post #27

I first used MySQL when it didn't even check column constraints, so that left a bad impression. It has improved, but I'd much rather use Postgresql, and a few features which I really like are: - Streaming Replication (keep a secondary instance for contingency or moving heavy queries away from the main database); - Procedures in various languages; - Foreign Data Wrappers for integration with other databases (much stur…

> "- Streaming Replication (keep a secondary instance for contingency or moving heavy queries away from the main database);"

MariaDB/MySQL's replication is also streamed. It's a continuous stream of replication data over an unbroken connection, for both statement-based and row-based methodologies. The only difference is that Postgres has since long been able to break transactions up into smaller pieces and apply them piecemeal, which is something that didn't show up in MariaDB/MySQL camp until a few years ago when introduced in Galera.

Re: Ask HN: Is PostgreSQL better than MySQL?

#48

Earlier quoted context omitted.

A little history, I used: - MySQL from about 1999-2007 - Postgres from 2006-present - Oracle at a job 4 years ago One of the things that absolutely made my brain explode is that Oracle, too, does not support DDL transactions. I discovered this during a pretty funny code review. “Why are you wrapping this DDL in a transaction? That’s pointless.” “Wait… Oracle doesn’t support DDL transactions?” “What do you mean ‘DDL t…

Your reviewer immediately made a suggestion that you're just unqualified? Well, I shouldn't be so surprised, it's a company that chose to use Oracle after all...

Ahhhh, it was much more polite than that and it was a junior-ish developer. I was new to the team and had already made it clear that while I had some database experience I had zero Oracle experience. I don't fault them too much; when someone suggests something that is completely outside of my mental model of how things work, it takes me a bit of reminding that I need to dig a little deeper to figure out what's going on and not just start jumping to conclusions about competence.

It just happened to be a great opportunity for both of us to expand our mental model of how different systems work. If you imagine someone whose mental model is "DML commands can be transactional, DDL modifies the database structure directly" then it's pretty reasonable for them to go "Uh... this guy doesn't seem to know the difference between modifying data and modifying tables..."

Re: Ask HN: Is PostgreSQL better than MySQL?

#49
Here's my experience with PostgreSQL:

Coming from Oracle, I've been able to use PostgreSQL pretty much as though it were Oracle, including Oracle's optimistic locking strategy. Some of the SQL functions are a little different, but it seems the underlying philosophy is the same. In other words, PostgreSQL seems like Oracle, just a little different.

MySQL has always felt completely foreign to me. Depending on your background and familiarity with other RDBMS's though, you may be right at home with it. Wouldn't be a bit surprised if someone had a similar anecdote to mine replacing PostgreSQL with MySQL and Oracle with SQL Server.

If you don't have a personal preference for either system then do some benchmarking on the platform you'll be running them on and the loads you're expecting and see if either particularly excels over the other for what you're intending to do.

Re: Ask HN: Is PostgreSQL better than MySQL?

#50
It takes an account from 2020 with little Karma to dare and ask the MySQL question on HN. So I am taking this opportunity again, anyone knows anything about next major version of MySQL?

If anything Postgres has a much clearer development model. Lots of features in the pipeline.

Post reply on HN