Updated on 2024-05-14 GMT+08:00

MySQL Compatibility Overview

This chapter compares the M-compatible mode in GaussDB with MySQL 5.7. Only compatibility features added later than GaussDB Kernel 505.1 are described. You are advised to view the specifications and restrictions of the features in Developer Guide.

To adapt to MySQL statements and multiple connection modes such as pymysql and JDBC, the M-compatible protocol is added to GaussDB.

GaussDB is compatible with MySQL in terms of data types, SQL functions, and database objects.

The execution plan, optimization, and EXPLAIN result in GaussDB are different from those in MySQL.

The underlying framework implementation of the GaussDB is different from that of MySQL. Therefore, there are still some differences between GaussDB and MySQL.

The underlying architecture of M-Compatibility is different from that of MySQL. Therefore, the query performance of schemas with the same name as MySQL under information_schema and m_schema may be different. For details, see chapter 6 in M-Compatible Developer Guide. For example, the execution of the count function cannot be optimized. The time consumed by the SELECT * and SELECT COUNT(*) statements is similar.

Database and Schema Design

MySQL data objects include database, table, index, view, trigger, and proc. The mapping relationship between MySQL object layers and GaussDB is from top to bottom and one-to-many, as shown in the following figure.

Figure 1 Differences between databases and schemas in MySQL and GaussDB
  • In MySQL, database and schema are synonyms. In GaussDB, a database can have multiple schemas. In this feature, each database in MySQL is mapped to a schema in GaussDB.
  • In MySQL, an index belongs to a table. In GaussDB, an index belongs to a schema. As a result, an index name must be unique in a schema in GaussDB and must be unique in a table in MySQL. This difference will be retained as a current constraint.