Updated on 2022-02-22 GMT+08:00

Introduction

DDM is compatible with the MySQL license and syntax, but the use of SQL statements is limited due to differences between distributed databases and single-node databases.

Before evaluating a DDM solution, evaluate the compatibility between SQL syntax in your application and syntax supported by DDM.

MySQL EXPLAIN

When you add EXPLAIN before a SQL statement is executed, you will see a specific execution plan. Analyze the time required based on the plan and modify the SQL statement for optimization.

Table 1 Description of the EXPLAIN column

Column Name

Description

table

Table that the data record belongs to

type

Type of the connection. The connections from the best to the worst are const, eq_reg, ref, range, index, and ALL.

possible_keys

Index that may be applied to the table

key

Index that is actually used. If the value is NULL, no index is used. In some cases, MySQL may select indexes that are not fully optimized. Add USE INDEX(indexname) to the SELECT statement to forcibly use an index, or IGNORE INDEX(indexname) to force MySQL to ignore the index.

key_len

Length of the used index. The shorter the length is, the better the index is if accuracy is not affected.

ref

Column where the index is used. The value is generally a constant.

rows

Rows of the data returned by MySQL

Extra

Additional information about how MySQL parses queries

SQL Restrictions

  • Temporary tables are not supported.
  • Foreign keys, views, cursors, triggers, and stored procedures are not supported.
  • Customized data types and functions are not supported.
  • Process control statements such as IF and WHILE are not supported.
  • Compound statements such as BEGIN...END, LOOP...END LOOP, REPEAT...UNTIL...END REPEAT, and WHILE...DO...END WHILE are not supported.

DDL Syntax

  • Sharded and broadcast tables do not support foreign keys.
  • Modifying sharding keys is not supported.
  • ALTER DATABASE Syntax is not supported.
  • Creating sharded or broadcast tables from another table is not supported.
  • The CREATE TABLE statement does not support GENERATED COLUMN.
  • Modifying sharding keys or global sequence fields using the ALTER command is not supported.
  • Creating TEMPORARY sharded or broadcast tables is not supported.
  • The logical table name contains only letters, digits, and underscores (_).
  • CREATE TABLE tbl_name LIKE old_tbl_name is not supported.
  • The CREATE TABLE tbl_name SELECT statement is not supported.
  • Updating the sharding key by executing INSERT INTO ON DUPLICATE KEY UPDATE is not supported.
  • Cross-schema DDL is not supported, for example, CREATE TABLE db_name.tbl_name (... )
  • Reverse quotation marks are required to quote identifiers such as table names, column names, and index names that are MySQL key words or reserved words.

DML Syntax

  • PARTITION clauses are not supported.
  • Nesting a subquery in an UPDATE statement is not supported.
  • INSERT DELAYED Syntax is not supported.
  • STRAIGHT_JOIN and NATURAL JOIN are not supported.
  • Multiple-table UPDATE is supported if all tables joined across shards have primary keys.
  • Multiple-table DELETE is supported if all tables joined across shards have primary keys.
  • Manipulating variables in SQL statements is not supported, for example, SET @c=1, @d=@c+1; SELECT @c, @d.

Unsupported Functions

  • XML functions
  • GTID functions
  • Full-text search functions
  • Enterprise encryption functions
  • Function row_count()

Subqueries

Using subqueries in the HAVING clause and the JOIN ON condition is not supported.

Data Types

Spatial data