MySQL vs PostgreSQL

Santo Lococo
3 min readApr 23, 2022

One of the first steps to building a new project is deciding what kind of database will be needed for what you are trying to achieve. The first question is whether to use a relational database or a non-relational database. now if you know that parts of the data will be dependent on other parts of data, say you know you will be needing foreign keys, then you will probably want to use a relational database. after you have sorted that much out, you aren't done. there are several prominent relational databases to consider. Two of the most prominent and most widespread databases are PostgreSQL and MySQL. But which one of these is the best for the app you are making? let's go through the similarities and the differences between the two to find which one is right for you.

We can start with how they are similar. They are both relational databases that were released in the 90s just one year apart with MySQL being released in 1995 and Postgres in 1996. Both are very well documented and open source so they are both free to the public, one of the many reasons they are both so popular. They both have a GUI to help the user create add and use their data. Lastly, they both have a high level of security so you can guarantee that your data will be safe both during and after development. Because of all of these things, either choice would be suitable for most applications. However, the differences between the two might just make your product shine in the way you wanted that the other just couldn't do.

The primary difference between the two is in the architecture. While MySQL is a pure relational database management system, PostgreSQL is an object-relational database. This key difference allows for Postgres to use more complex data types like arrays and also allows objects to inherit properties. Very useful features, but these extras mean a higher degree of difficulty when using Postgres, and therefore might require a higher understanding of the technology which might make getting to the end product take longer. but if these extra data types make it so you can accomplish things you otherwise could not, the extra effort might be worth it. You will need to keep in mind however that depending on how complex and app specific a solution gets, the less likely you will be able to get support from online documentation and other sources when using Postgres due to the documentation being limited to only being able to solve more generic problems. Another architectural difference is that Postgres is a multi-thread system and MySQL is a single thread system. This makes Postgres less efficient the larger the scope of the application gets and by contrast makes MySQL superior in terms of speed and efficiency.

If you had to condense the differences between the two you could say that MySQL has less of a learning curve and high efficiency while Postgres has higher functionality with the ability to achieve higher complexity with solutions at the expense of ease of use. If you are going to be making an application that has many write operations and needs a more complex solution than MySQL can provide then consider Postgres. But if your app is simpler and just needs to run fast be secure and be put together more simply, go with MySQL. But don't forget that you can use Sequalize with both to make your life a little easier than just working with raw queries.

--

--