MySQL vs PostgreSQL Performance Benchmark (Latency - Throughput - Saturation)

preview_player
Показать описание
PostgreSQL vs MySQL Performance/Speed Benchmark.

▬▬▬▬▬ Experience & Location 💼 ▬▬▬▬▬
► I’m a Senior Software Engineer at Juniper Networks (12+ years of experience)
► Located in San Francisco Bay Area, CA (US citizen)

▬▬▬▬▬▬ Connect with me 👋 ▬▬▬▬▬▬

▬▬▬▬▬▬▬ Timestamps ⏰ ▬▬▬▬▬▬▬
0:00 Intro
1:21 Tests Overview
2:39 Code Overview
3:31 1st Test
7:49 2nd Test

▬▬▬▬▬▬▬ Source Code 📚 ▬▬▬▬▬▬▬

#postgresql #mysql #postgres
Рекомендации по теме
Комментарии
Автор

That's the most advanced open source database for you. I love postgresql.

Takatou__Yogiri
Автор

This is shocking. I never knew that Postgres was such a clear winner for most of the time.

austinisakson
Автор

MariaDB v PostgreSQL would be a great comparison I think, not many opting to run MySQL over MariaDB these days, and I imagine it should be a bit of a closer race.

briankb
Автор

Testing SQLite against any of those would be very interesting. I know that SQLite is a different "animal", and it does not scale horizontally, but I found in most of my use cases that it provides more than enough performance (actually much more), and it is incredibly easy to operate and maintain (less moving pieces).
In addition, there are already solutions for availability and replication which are simple. So, I am using most of the time SQLite in production.

jesusruiz
Автор

I think one that would interest me a lot is MS-SQL vs PostgreSQL. I personall have worked with both but I vastly prefer PostgreSQL

roccociccone
Автор

Pls also tests MySQL vs MariaDB.

The Results should be pretty simular but it would be interesting to see

spieles
Автор

Already commented about some technical stuff, now about the design: for testing SQL databases I would like to see a slightly more complex set of operations, UPDATE and DELETE are missing, having more JOINs would be more realistic, where clauses that don't use an index or different types, sorting and aggregation would also help to highlight different strength and weaknesses.

Maybe something like a simplified online shop with shopping cards (adding/removing items, changing amounts), orders and reports like the top 100 customers or articles in a given time frame. And also very important: transactions. In other words some kind of CRUD app that does everything in SQL. A lot of work and preparation though.

yannick
Автор

love your benchmarks, queep the good work!

krshock
Автор

2 Years ago i was tested on bare metal mysql vs postgresql using 0.9 TB file with real events. Nodejs was used, both databases used default configs. There was ~90% of selects, rest was IUD. With low level of concurrency mysql was winner, with > 30 workers postgre on a top. I played with database structure and other things, and found, than there is no clear winner or loser. Summary: both mysql and postgre have own advantages/and disadvantages, and database selection is depends on many factors.

arozhik
Автор

Am I the only one who didn't see MySQL config? What is the table engine for MySQL?
Not sure if this is still the case nowadays, but MySQL used to come with really tiny default parameters for INNODB engine. And the first thing you do with MySQL is to set those params like innodb_buffer_pool_size, etc. (there are a bunch of them) I. e. nobody uses MySQL out of the box. You have to set those params to reflect your load.
The easiest way were running tuning-primer or MySQLTuner script after running the workload. You had to do this several times.

PavelTimofeev
Автор

The test seems a bit too one sided, the main architectural difference in MySQL vs Postgres is MySQL write operations (write, update, delete) are amortized so data is always "balanced", while Postgres postpones it until VACUUM and it is prone to degradation, when vacuum starts under load. It would be nice to show how these databases will compare under mixed workload, when records are inserted, updated and deleted at the same time, and data that is being changed should be in the index to test tuple bloating.
Also can you publish schemas for databases?

marknefedov
Автор

These videos are always so clean. Thanks for sharing this, it's really valuable information for scaling projects.

davidriveros
Автор

I liked this comparison between databases! I like the idea of seeing more databases on these videos.

GabrielPozo
Автор

Thank you for the colors. This is very clear to see the graph.

dgtemp
Автор

Did you also consider fine tuning the database configs, since the default configurations are not optimized at all. Think about innodb_buffer_pool_size for Mysql. And shared_buffers in PostgreSQL.

MelroyvandenBerg
Автор

I knew that PostgreSQL was booming, now I understand why. Thanks for this work.

MotinQ
Автор

Nice benchmark! A couple of things:

1 - I believe that Postgres uses a process per connection. Are you making sure to measure the combined CPU and memory usage of the 'main' process along with all of the connection processes? The reason that this is relevant is that MySql is thread based, so the main process should show the overall CPU/Memory whereas with Postgres you might only be looking at the DB process which is kind of cheating since the connection processes also use CPU/Memory.

2 - It would be cool to see a Java benchmark using the latest Java as well as the latest JDBC drivers for each. Be sure to use a connection pool like Hikari if you do.

michaelm
Автор

Thank u for this comparison, even though most of us probably already knew postgres was going to win. I'm not sure if u already did this but I'd love to see how Postgres compares to MongoDB, the two GOATs of the DB world. 😀

BeeBeeEight
Автор

You are awesome!!! Please make a between PostgreSQL and Microsoft SQL Server!! I wasn't expected that.

milendenev
Автор

I love seeing benchmarks between databases. We need more of them. Folks should keep in mind that schema design and use cases make a bigger difference than engine in most cases, just like data structures and algorithm choice makes a bigger difference than the programming language. There are also so many "shortcuts" that each engine implements for different scenarios.

It's still good to see comparisons with apples-to-apples. It's a shame the proprietary db vendors don't allow performance comparisons like the open source DBs allow.

mileselam