The difference between PG and mysql, why is PG not popular?

1. mysql supports a variety of storage engines, and the selection of storage engines is more flexible. In fact, innodb is generally used. DDL is placed on the server side, and the transactional support of DDL statements is poor, and server-level database loss may occur. pg server has better stability

2 The mysql data storage structure is a clustered index, which is more efficient to query through the primary key, but it has many limitations, such as inserts can only be inserted sequentially. Not suitable for very large data non-primary key query, access to the secondary index requires back to the table. PG uses heap tables to store data, which can support a larger amount of data

3 pg does not support partition tables. The purpose of partition tables is achieved through inheritance tables. When there are more than tens of thousands of partitions, pg inheritance tables are less efficient

4 mysql has a gap lock. After the postgresql database executes the delete operation, the records in the table are only marked as deleted, and the space is not released. In the future update or insert operation, the space in this part cannot be reused. The function of VACUUM is Delete the data that has been marked as deleted and free up space. The vacuum needs to be run regularly, which consumes IO

5 PG supports more data types (such as gis), analysis functions, and object-oriented databases. There are more third-party open source tools to assist system design and implementation

6pg supports stored procedures and execution plan caching, table connection and complex query capabilities are stronger. mysql optimizer, operators are relatively simple, suitable for simple query operations

7 pg master-slave uses wal log physical synchronization, mysql uses binlog logical synchronization. Physical synchronization has higher reliability and higher replication performance.

8 mysql only supports nested loop table join (8.0 supports hash join), pg supports nl, hash, merge join

9 mysql is suitable for scenarios with simple application logic, light data storage and calculation, pg is suitable for complex data analysis and special application scenarios

 

Recently I studied pg and found that pg is no worse than mysql. Everyone is an open source relational database, but it is obvious that MySQL is more popular than pg.

There are many historical reasons. MySQL has been in the market since 4.x. The use rate of the first few versions of PG is not high. Recently, the reputation of PG is relatively good, but MySQL has occupied a large part of the open source relational database market. The functions of the recent pg version are very complete and complex. Most lightweight applications only want a free, data-storable, simple relational database. Most of the data calculation and analysis functions will not be placed on the OLTP database level. .

The pg data type, the optimizer does better than mysql, and it is more suitable for OLAP scenarios. For example, Ali's ADB is made by pg and used for alanyze. Huawei's guass-A is developed based on PG and is also used for analysis scenarios. It is wrong that all PGs are not popular. PGs are still very popular. At least domestic databases or cloud databases pay much attention to PG.

Regardless of the previous development, all from the current market situation, mysql and pg do not even compete with each other. One of them serves OLTP and the other applies to OLAP.

 

 

 

reference:

https://www.jianshu.com/p/c3911e3e830a

https://www.cnblogs.com/sbj-dawn/p/8053549.html

Guess you like

Origin blog.csdn.net/qq_40687433/article/details/110467141