DEV Community

MySQL vs Postgres: Which Database is Right for Your Application?

Mark Holtzhausen on December 14, 2022

MySQL and Postgres are two of the most popular open-source relational database management systems. They have many similarities, but there are also ...
Collapse
 
alejandro_du profile image
Alejandro Duarte

Thanks for writing this. I enjoyed reading the article. I love both PostgreSQL and MySQL/MariaDB. Just one thing to notice is that although PostgreSQL has more data types than MySQL, I wouldn't say the "rage" is necessarily wider. I mean, PostgreSQL has 43 data types (postgresql.org/docs/current/dataty...) while MariaDB has 36 (mariadbtutorial.com/mariadb-basics...). That's 7 less than PostgreSQL. Both cover pretty much all use cases. Now, it'd be interesting to also see an "ecosystem" comparison since both have amazing open-source and close-source technologies and communities around them. Thanks again for publishing this!

Collapse
 
nemesarial profile image
Mark Holtzhausen • Edited

Thank you for your reply. Seven may not seem like a huge difference, but I would argue that amongst them, there are game-changers when it comes to optimising your code and making architectural decisions.

Although pg ARRAY can be used in many ways, its ability to let you avoid link tables by implicitly storing one-to-many relationships in the same table as the main content, is an organisational feature that can decrease database complexity.

There is also HSTORE that is great for storing and querying semi-structured data in a key-value format and have indexes for all keys and all values. JSONB was built on top of the same architecture, and shares the key and value indexing with HSTORE. Not even considering the performance benefit, the fact that you can index json in this way and then also retrieve rows from json, opens up a bunch of optimizations that just isn't possible otherwise.

Another powerful feature is the custom data types and domains you can create in postgres. This makes it easy to store and query against complex data and add reusable validation across your tables.

In summary, although there are not a plethora of different data types in postgres that don't exist in mysql, I feel it is safe to say that they open up a range of possibilities, strategies and architectural optimizations that you won't find in MySql. Ultimately, the choice of which database management system to use will depend on the specific needs and requirements of your application, and these distingquishing features may be of little consequence to most developers.