Dear readers of our blog, we'd like to recommend you to visit the main page of our website, where you can learn about our product SQLS*Plus and its advantages.
 
SQLS*Plus - best SQL Server command line reporting and automation tool! SQLS*Plus is several orders of magnitude better than SQL Server sqlcmd and osql command line tools.
 

REQUEST COMPLIMENTARY SQLS*PLUS LICENCE

Enteros UpBeat offers a patented database performance management SaaS platform. It proactively identifies root causes of complex revenue-impacting database performance issues across a growing number of RDBMS, NoSQL, and deep/machine learning database platforms. We support Oracle, SQL Server, IBM DB2, MongoDB, Casandra, MySQL, Amazon Aurora, and other database systems.

Postgresql vs MySQL – which one of these DBMS is better

19 June 2020

Postgresql vs MySQL - which one of these DBMS is better

Postgresql vs MySQL: MySQL is the most popular relational DBMS, while PostgreSQL is the most advanced and functional.

Functions of DBMS MySQL and PostgreSQL

Almost any developer will say that MySQL is better suited for websites and online transactions, while PostgreSQL is better suited for large and complex analytical processes. He will also add that PostgreSQL comes with “a lot of great features”, such as extensibility and native NoSQL functionality, which helps in managing a complex database. Finally, he will remind you that MySQL is not overloaded with functions because it prioritizes “speed and reliability”.

For the most part, these theses are true. Although MySQL and PostgreSQL databases are functionally similar to each version (see table), they are still different, so in certain situations one system may be better than another.

Comparison of functionsPostgreSQL 10MySQL 8
Generalized tabular expressions (CTE)

+

+ (recently added)

Declarative sectioning

+ (recently added)

+

Full text search

+

+

Geographic Information Systems (GIS) and Reference System Identifiers (SRS)

+

+ (updated)

JSON

+

+ (updated)

Logical replication

+ (recently added)

+

Semi-synchronous replication

+ (recently added)

+

Оконные функции

+

+ (recently added)

This tutorial will explain the differences between MySQL and PostgreSQL so you can understand which one is best for your case.

Overview of MySQL and PostgreSQL

MySQL: general characteristics

What is MySQL? It is a fast, reliable and universal relational database management system (RDBMS), the most popular in the world: 39% of developers used it last year. Although it lacks the extensive features of PostgreSQL, it is perfect for a wide range of applications, especially the web.

MySQL is an ideal choice for scalable web applications. This DBMS is part of the standard LAMP stack – a set of open source web applications: Linux, Apache HTTP Server, MySQL and PHP. In addition, popular content management systems such as Drupal, Joomla and WordPress work on MySQL.

MySQL is an ideal choice for scalable web applications

Here are some MySQL features:

  • Open source code: MySQL is a free and open relational DBMS (DBMS).
  • Long history: MySQL is available since 1995.
  • Responsive Community: A dedicated community of enthusiasts will always help with problem solving and troubleshooting.
  • Stability and reliability: everyone agrees that MySQL is a very stable RDBMS as long as the databases remain “compact” and you don’t forget about regular maintenance.
  • MVCC Functions: MySQL now offers Parallel Access Management through Multiversion Coverage (MVCC). This is a well-known PostgreSQL function (discussed below).
  • Frequent updates: MySQL is updated frequently, releasing new functions and security improvements.
  • High user ratings: MySQL has a 4.4 star rating (out of five) with 1420 reviews on G2 Crowd.

MySQL is an open, free, stable database management system suitable for production. This lightweight DBMS can be installed on production servers with large loaded applications, and on developer work computers. All platforms are supported, including Windows, Linux and Mac. The system is secure and all vulnerabilities are closed.

Among MySQL users: Facebook, Google, Flickr, GitHub, NASA, Netflix, Spotify, Tesla, Twitter, Uber, US Navy, WeChat, Wikipedia, YouTube, Zappos, Zendesk.

PostgreSQL: description and general features

PostgreSQL is considered a suitable solution for complex operations with large data volumes. The reason is that it handles emergencies better (we will discuss this below).

It is believed that PostgreSQL has more functions than other DBMS (users confirm this). In addition, PostgreSQL is an extensible system, its work is based on directories (catalog-driven approach). In other words, it stores information not only about tables and columns, but also about data types, index types, functional languages and so on. Users can change all this information in system directories, which look like regular tables.

Other distinctive features of a PostgreSQL database are the object-relational system, which is compatible with the principles of ACID:

  • atomicity – atomicity;
  • consistency – coherence;
  • isolation – isolation;
  • durability – persistence.

It also supports High Parallel Computing and NoSQL (MySQL also supports NoSQL since version 8.0).

PostgreSQL: description and general features

Here are some PostgreSQL features:

  • Open source code: PostgreSQL is a free and open object-relational database management system (DBMS). It is unlike conventional DBMS. It allows you to use both object-oriented and relational databases.
  • Advanced settings: you can develop your own plug-ins and customize PostgreSQL to your needs. PostgreSQL also allows you to activate non-standard functions written in other programming languages, such as C/C++, Java and others.
  • Long history: PostgreSQL has been developing since 1988.
  • Frequent updates: Thus, the last update for March 2020 in PostgreSQL is version 12.2 of February 13, 2020.
  • Liberal Open License: PostgreSQL has a generous, open source license that allows you to use, modify and distribute the DBMS as you wish.
  • MVCC Functions: PostgreSQL was the first DBMS to implement Multiple Version Access Control (MVCC) functions.
  • Responsive community: A dedicated community of developers and activists is always there to help. In addition, paid support from third parties is available. The community supports PostgreSQL and updates the platform through the PostgreSQL Global Development Group.
  • High user feedback: PostgreSQL has a 4.4 star rating (out of five) with 452 reviews on G2 Crowd.

PostgreSQL is one of the most interesting open-source DBMS. It is free, and also offers many advanced options. Today PostgreSQL is considered the most advanced database management system. When making a transaction there is no need to put reading locks, which gives better scalability. Also, this tool is not managed by a person or company, but by the community of developers.

Among PostgreSQL users: Apple, BioPharm, Cisco, Debian, Etsy, Facebook, Fujitsu, IMDB, Instagram, Macworld, Red Hat, Skype, Spotify, Sun Microsystem, Yahoo.

When developers choose MySQL, and when PostgreSQL

PostgreSQL is often chosen as a more functional option. As you will see in the following description, it does come with a lot of additional options. However, when it comes to database architecture, in some cases simplicity, lightness and other features of MySQL are more important. In this regard, each DBMS optimally manifests itself in different areas.

Let’s look at the key features of MySQL and PostgreSQL in terms of why DBMS developers choose one of them.

Main advantages of MySQL for developers

High flexibility and scalability: MySQL allows you to choose from a wide range of storage engines. This allows you to flexibly integrate data from different table types. MySQL 8.0 supports the following table storage systems:

  • InnoDB
  • MyISAM
  • Memory
  • CSV
  • Archive
  • Blackhole
  • NDB/NDBCLUSTER
  • Merge
  • Federated
  • Example

Speed and reliability: By abandoning some SQL functions, MySQL has maintained its ease, giving priority to speed and reliability. Its speed is especially evident when it comes to highly parallel operations without writing to the database (read only). It is an excellent choice for certain business analytics applications. But if you need to execute many complex queries under heavy load, PostgreSQL can do better.

Server optimization options: MySQL offers many options to configure and optimize your MySQL server by setting variables such as sort_buffer_size, read_buffer_size, max_allowed_packet and so on.

Easy to use and popular: the popularity of a MySQL database means that it will be easy to find database administrators with extensive experience with this database. Users say that this system is easier to configure, i.e. it does not require such fine-tuning as other DBMS. In this guide you can see how easy it is for a novice user to configure his or her first MySQL database. Installing and configuring PostgreSQL will be more complicated.

In addition, a number of frontend services such as Adminer, MySQL Workbench, HeidiSQL and dbForge Studio add a graphical interface to MySQL that is more convenient and simple than working from the command line.

Cloud DBMS: MySQL Database is well suited for use in the cloud, many cloud platforms offer appropriate paid services: they are ready to install and maintain your database.

Parallel access management through multi-version (MVCC) and ACID compliance with InnoDB: In current versions of MySQL, the default engine is InnoDB. It provides MVCC functionality and ACID compliance. However, due to the MyISAM table format in InnoDB, problems with damaged tables can still occur in MySQL.

According to MySQL documentation, “although the MyISAM table format is very robust (all changes made to a table by an SQL instruction are written before the instruction is returned), you may still encounter corrupted tables”. Switching to another engine will not save the situation: worse, it can lead to loss of MVCC and ACID compliance.

Main advantages of PostgreSQL for developers

What is PostgreSQL? It is an object-relational system, and its programming is a kind of bridge between object-oriented and relational/procedural programming (like C++). It allows to define objects and inheritance of tables, which generates more complex data structures. DBMS is perfect for data that do not fit into a strictly relational model.

Perfect for complex queries where complex read-write operations need to be performed with simultaneous data validation. However, DBMS does not handle read-only operations so well (this is where MySQL is superior).

NoSQL support and wide variety of data types: PostgreSQL is a popular choice for NoSQL functions. It initially supports a wide variety of data types, including JSON, hstore and XML. You can also customize the original data types and use non-standard functions.

Designed to manage very large databases: PostgreSQL functions do not limit the size of your databases. For example, according to the database administrator on Adjust.com, they have PostgreSQL manages a database “by about four petabytes”. He goes on to say that “the environment processes, and then logs, 100 to 250 thousand external queries per second. This is a really heavy load!

Multiple Version Multiple Access Control (MVCC): This is one of the main reasons why companies choose PostgreSQL. MVCC allows multiple read and write agents to access the database simultaneously. This eliminates the need to block read-write every time someone interacts with the data. Thus, DBMS management efficiency and performance is significantly improved.

MVCC provides this functionality through “snapshot isolation” (as Oracle calls it). Momentary snapshots (snapshots) represent the state of the data at a certain point in time.

ACID compliance: PostgreSQL prevents data corruption and preserves its integrity at the transaction level. Read more about the importance of ACID compliance here (as mentioned above, MySQL also offers ACID compliance, but complications may occur).

Support for users in MySQL and PostgreSQL

Extensive communities have been formed around both DBMS, which are always ready to help, in addition to paid support from the DBMS owner or third-party providers.

MySQL User Support

As an open source project, MySQL has a large community of activists ready to provide free advice and guidance. The best way to get such support is to visit MySQL and Percona websites.

Here is what one IT specialist at G2 Crowd says about user support for MySQL:

I liked it best that for MySQL, as an open source project, you can find a lot of tips on the Internet and get help for free. This is especially useful for problems that are difficult to solve by themselves. One of the main advantages of MySQL is the great popularity of this DBMS, so you will find a huge community of people willing to help in any way.

In addition, you can solve any problems yourself by browsing the free MySQL books, manuals and tutorials.

PostgreSQL User Support

The PostgreSQL database also has a large community of activists who provide free advice to users, including on IRC and through mailing lists. In addition, you can study numerous instructions and books on PostgreSQL yourself.

This is what one database administrator says about PostgreSQL support in G2 Crowd:

…the best support is provided by the community in forums where questions are answered.

Another reviewer at G2 Crowd said this:

Personally, I thought it was a little harder to get community support or to google the problem. But as PostgreSQL becomes more popular, community support becomes better.

Getting PostgreSQL support can be a bit harder because:

  • more technical knowledge is required to configure and use the DBMS;
  • there are fewer PostgreSQL experts than there are MySQL experts.

Which is Faster: MySQL or PostgreSQL

Both MySQL and PostgreSQL are considered one of the fastest DBMS. It is not quite clear which of them is the fastest.

Depending on the hardware and configuration, it is easy to find benchmarks, in which this or that DBMS will win. One may work better on a single-core machine with a small amount of memory, while the other is better scalable to multiple processors. One wins by the speed of reading operations and the other by the speed of writing.

Performance tests give conflicting results. For example, Windows Skills favors MySQL, while Benchw says PostgreSQL is faster. As a result, the speed depends on how exactly you use the database. We know that PostgreSQL is faster when processing massive data sets, complex queries and read-write operations. Meanwhile, MySQL Database is considered more efficient in read-only operations.

Which programming languages MySQL and PostgreSQL support

Supported MySQL languages: C/C++, Delphi, Erlang, Go, Java, Lisp, Node.js, Perl, PHP, R.

Supported PostgreSQL languages. It supports several broader languages: C/C++, Delphi, Erlang, Go, Java, JavaScript, Lisp, .Net, Python, R, Tcl and other programming languages.

Which operating systems MySQL and PostgreSQL work with

Let’s see how the requirements to the MySQL and PostgreSQL operating systems differ.

MySQL compatibility with operating systems

DBMS MySQL offers cloud support and local installation in the following operating systems and formats:

  • Windows
  • MacOS
  • Linux (Ubuntu, Debian, Generic, SUSE Linux Enterprise Server, Red Hat Enterprises, Oracle, Fedora)
  • Oracle Solaris
  • FreeBSD
  • Source code

PostgreSQL compatibility with operating systems

PostgreSQL DBMS offers cloud support and local installation, usually installed on Linux servers. In addition, the PostgREST web server is available to work with the database through REST API program interfaces.

PostgREST is a standalone web server that turns your PostgreSQL database directly into a RESTful API. API endpoints and operations are defined by structural constraints and database permissions.

PostgreSQL is available for the following operating systems:

  • MacOS
  • Solaris
  • Windows
  • BSD (FreeBSD, OpenBSD)
  • Linux (Red Hat Linux family, including versions of CentOS/Fedora/Scientific/Oracle, Debian GNU/Linux and derivatives, Ubuntu Linux and derivatives, SuSE and OpenSuSE, other Linux distributions)

How MySQL and PostgreSQL index data

Indexes improve database performance by accelerating SQL queries when working with large tables. Without database indexing the queries are processed slowly and overload the system. Both MySQL and PostgreSQL offer different indexing options.

Types of MySQL indexing

  • Indices in B-trees such as INDEX, FULLTEXT, PRIMARY KEY and UNIQUE.
  • Indices in R-trees, such as indices for spatial data types.
  • Hash indexes and inverted lists when using FULLTEXT indexes.

Types of PostgreSQL indexing

  • Hash indexes and B-trees.
  • Partial indexes that organize information only from part of the table.
  • Indexes of expressions that are calculated from functions, not from values in columns of the table.

How does programming for each DBMS differ?

You need to know about the three differences in MySQL and PostgreSQL database programming:

  • Case sensitive
  • Character sets and strings by default
  • Functions IF and IFNULL instead of CASE

Case sensitive

MySQL does not differentiate between case characters in queries, so queries do not necessarily have to be case sensitive with strings in the database. PostgreSQL is case sensitive. Strings in queries must exactly match the fields in the database, otherwise the query will not be executed.

Character sets and default strings

In some versions of MySQL you need to convert character sets and strings to UTF-8. This is not necessary in PostgreSQL. Moreover, UTF-8 syntax is not allowed in PostgreSQL at all.

Functions IF and IFNULL instead of CASE

In MySQL you can easily use IF and IFNULL operators. In PostgreSQL they do not work, but instead you should use the CASE operator.

What to choose: Postgresql vs MySQL

Choosing between MySQL and PostgreSQL often comes down to the following questions:

Do you need a multifunctional DBMS capable of processing complex queries and supporting massive databases? Then choose PostgreSQL.

Do you need a lighter database, relatively easy to set up and manage, fast, reliable and clear? Choose MySQL.
However, even from this guide it is clear that the solution is not always so obvious.

You have to look for a compromise considering the advantages and disadvantages of both DBMS.

 
Tags: , , , ,

MORE NEWS

 

Preamble​​NoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...

Preamble​​MongoDB Conditional operators specify a condition to which the value of the document field shall correspond.Comparison Query Operators $eq...

5 Database management trends impacting database administrationIn the realm of database management systems, moreover half (52%) of your competitors feel...

The data type is defined as the type of data that any column or variable can store in MS SQL Server. What is the data type? When you create any table or...

Preamble​​MS SQL Server is a client-server architecture. MS SQL Server process starts with the client application sending a query.SQL Server accepts,...

First the basics: what is the master/slave?One database server (“master”) responds and can do anything. A lot of other database servers store copies of all...

Preamble​​Atom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to...

Preamble​​MongoDB recently introduced its new aggregation structure. This structure provides a simpler solution for calculating aggregated values rather...

FlexibilityOne of the most advertised features of MongoDB is its flexibility.  Flexibility, however, is a double-edged sword. More flexibility means more...

Preamble​​SQLShell is a cross-platform command-line tool for SQL, similar to psql for PostgreSQL or MySQL command-line tool for MySQL.Why use it?If you...

Preamble​​Writing an application on top of the framework on top of the driver on top of the database is a bit like a game on the phone: you say “insert...

Preamble​​Oracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...

Preamble​​IBM pureXML, a proprietary XML database built on a relational mechanism (designed for puns) that offers both relational ( SQL / XML ) and...

  What is PostgreSQL array? In PostgreSQL we can define a column as an array of valid data types. The data type can be built-in, custom or enumerated....

Preamble​​If you are a Linux sysadmin or developer, there comes a time when you need to manage an Oracle database that can work in your environment.In this...

Preamble​​Starting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...