What’s the Difference Between MySQL and PostgreSQL?

What's the Difference Between MySQL and PostgreSQL?

MySQL is a relational database management system that lets you store data as tables with rows and columns. It’s a popular system that powers many web applications, dynamic websites, and embedded systems. PostgreSQL is an object-relational database management system that offers more features than MySQL. It gives you more flexibility in data types, scalability, concurrency, and data integrity.

Read about MySQL »

Read about PostgreSQL »

What are the similarities between PostgreSQL and MySQL?

Both PostgreSQL and MySQL are relational database management systems. They store data in tables that are interrelated to each other via common column values. Here’s an example:

  1. A company stores customer data in a table named Customers with column names customer_id, customer_name, and customer_address.
  2. The company also stores product data in a table named Products with column names product_id, product_name and product_price. 
  3. To record the items each customer purchases, the company has a table named Customer_Orders with columns customer_id and product_id.

Here are other similarities between PostgreSQL and MySQL:

  • Both use structured query language (SQL) as an interface to read and edit data
  • Both are open source and have strong developer community support
  • Both have a built-in data backup, replication, and access control features

Read about SQL »

Key differences: PostgreSQL vs MySQL

While PostgreSQL and MySQL are conceptually similar, there are many differences to consider before implementing them.

ACID compliance

Atomicity, consistency, isolation, and durability (ACID) are database properties that ensure a database remains in a valid state even after unexpected errors. For example, if you update a large number of rows but the system fails midway, no row should be modified.

MySQL offers ACID compliance only when you use it with InnoDB and NDB Cluster storage engines or software modules. PostgreSQL is fully ACID compliant in all configurations.

Concurrency control

Multiversion concurrency control (MVCC) is an advanced database feature that creates duplicate copies of records to safely read and update the same data in parallel. When you use MVCC, multiple users can read and modify the same data simultaneously without compromising data integrity.

MySQL databases do not offer MVCC, but PostgreSQL supports this feature.


Databases use indexes to retrieve data faster. You can index frequently accessed data by configuring the database management system to sort and store it differently from the other data.

MySQL supports B-tree and R-tree indexing that stores hierarchically indexed data. PostgreSQL index types include trees, expression indexes, partial indexes, and hash indexes. There are more options to fine-tune your database performance requirements as you scale.

Data types

MySQL is a purely relational database. PostgreSQL, on the other hand, is an object-relational database. This means that in PostgreSQL, you can store data as objects with properties. Objects are a common data type in many programming languages like Java and .NET. Objects support paradigms like parent-child relationships and inheritance.

Working with PostgreSQL is more intuitive for database developers. PostgreSQL also supports other additional data types like arrays and XML.


A view is a data subset that the database system creates by pulling relevant data from multiple tables.

While MySQL supports views, PostgreSQL offers advanced view options. For example, you can precompute some values in advance (like the total value of all orders over a given period) to create materialized views. Materialized views improve database performance for complicated queries.

Stored procedures

Stored procedures are structured query language (SQL) queries or code statements you can write and save in advance. You can reuse the same code repeatedly, which makes database management tasks more efficient.

While both MySQL and PostgreSQL support stored procedures, PostgreSQL allows you to call stored procedures written in languages other than SQL.


A trigger is a stored procedure that runs automatically when a related event occurs in the database management system.

In a MySQL database, you can only use AFTER and BEFORE triggers for SQL INSERT, UPDATE, and DELETE statements. That means the procedure will run automatically before or after the user modifies the data. In contrast, PostgreSQL supports the INSTEAD OF trigger, so you can run complex SQL statements using functions.

How to choose between PostgreSQL vs MySQL

Both relational databases are suitable for most use cases. However, you may consider the following factors before making a final decision.

Application scope

PostgreSQL is better suited for enterprise-level applications with frequent write operations and complex queries.

However, you can start a MySQL project if you want to prototype, create internal applications with fewer users, or create an information storage engine with more reads and infrequent data updates.

Database development experience

MySQL is more suitable for beginners and has a shorter learning curve. It takes less time to build a new database project from scratch. It’s simple to set up MySQL as a standalone product or bundle it with other web development technologies like the LAMP stack.

PostgreSQL, on the other hand, can be much more challenging for newcomers. It typically requires complex infrastructure setup and troubleshooting experience.

Read about LAMP stacks »

Performance requirements

If your application requires frequent data updates, PostgreSQL is a better choice. However, if you require frequent data reads, MySQL is preferred.

Write performance

MySQL uses write locks to achieve real concurrency. For example, if one user is editing the table, another user may have to wait until the operation finishes before changing the table.

However, PostgreSQL has built-in multiversion concurrency control (MVCC) support without read-write locks. This way, PostgreSQL databases perform better in the case of frequent and concurrent write operations.

Read performance

PostgreSQL creates a new system process with significant memory allocation (about 10 MB) for every user connected to the database. It requires memory-intensive resources to scale for multiple users.

On the other hand, MySQL uses a single process for multiple users. As a result, MySQL database outperforms PostgreSQL for applications that mainly read and display data to users.

Summary of differences: PostgreSQL vs MySQL




Database technology

MySQL is a purely relational database management system.

PostgreSQL is an object-relational database management system.


MySQL has limited support of database features like views, triggers, and procedures.

PostgreSQL supports most advanced database features like materialized views, INSTEAD OF triggers, and stored procedures in multiple languages.

Data types

MySQL supports numeric, character, date and time, spatial, and JSON data types.

PostgreSQL supports all MySQL data types along with geometric, enumerated, network address, arrays, ranges, XML, hstore, and composite.

ACID Compliance

MySQL is ACID compliant only with InnoDB and NDB Cluster storage engines.

PostgreSQL is always ACID compliant. 


MySQL has B-tree and R-tree index support.

PostgreSQL supports multiple index types like expression indexes, partial indexes, and hash indexes along with trees.


MySQL has improved performance for high-frequency read operations.

PostgreSQL has improved performance for high-frequency write operations.

Beginner support

MySQL is easier to get started with. It has a wider tool set for non-technical users.

PostgreSQL is more complex to get started with. It has a limited tool set for non-technical users. 

How can AWS support your PostgreSQL and MySQL requirements?

Amazon Webs Services (AWS) offers several services for your PostgreSQL and MySQL requirements.

Amazon RDS

Amazon Relational Database Service (Amazon RDS) is a collection of managed services that makes it simple to set up, operate, and scale relational databases in the cloud. With Amazon Relational Database Service (Amazon RDS) for MySQL, you can deploy scalable MySQL servers in minutes with cost-efficient and resizable hardware capacity.

Similarly, Amazon Relational Database Service (Amazon RDS) for PostgreSQL makes it easy to set up, operate, and scale PostgreSQL deployments in the cloud. It also manages complex and time-consuming administrative tasks such as PostgreSQL software upgrades, storage management, and backups for disaster recovery.

Here are other ways you can benefit from using Amazon RDS:

  • Deploy scalable MySQL and PostgreSQL deployments with cost-efficient and resizable hardware capacity in minutes
  • Reuse code, applications, and tools related to your existing databases
  • View critical operational metrics like compute, memory, and storage capacity utilization

Amazon Aurora

Amazon Aurora is a relational database management system (RDBMS) built for the cloud with complete MySQL and PostgreSQL compatibility. Aurora combines the speed and availability of high-end commercial databases with the simplicity and cost-effectiveness of open-source databases.

Aurora is fully compatible with MySQL and PostgreSQL, so existing applications and tools can run without modification. You can migrate to Amazon Aurora to experience three times the throughput of your current setup.

Amazon EC2

Amazon Elastic Compute Cloud (Amazon EC2) offers the broadest and deepest compute platform. It has over 500 instances and a choice of the latest processor, storage, networking, operating system, and purchase model to help you best match the needs of your workload.

You can use Amazon EC2 to run your MySQL and PostgreSQL databases in the cloud. With this approach, you must manage database administration tasks such as infrastructure provisioning, database setup, tuning, patching, backups, and scaling.

Get started with PostgreSQL and MySQL on AWS by creating a free account today.

Next Steps with AWS