- What's New
- Product Bulletin
- Service Overview
- Billing
- Getting Started
-
User Guide
- Function Overview
- Kernel Version Notes
- Permissions Management
-
Instance Management
- Instance Statuses
- Buying a DDM instance
- Splitting Read-only and Read-Write Services
- Changing Node Class
- Scaling Out a DDM Instance
- Scaling In a DDM Instance
- Restarting a DDM Instance or an Instance Node
- Deleting Pay-per-Use Instances
- Reloading Table Data
- Changing a Parameter Template
- Modifying Parameters of a DDM Instance
- Rolling Back the Version of a DDM Instance
- Upgrading the Version of a DDM Instance
- Upgrading the DDM Engine and OS
- Connection Management
- Schema Management
- Shard Configuration
- Data Nodes
-
Parameter Template Management
- Instance Parameters
- Creating a Parameter Template
- Modifying a Custom Parameter Template
- Comparing Two Parameter Templates
- Viewing Parameter Change History
- Replicating a Parameter Template
- Applying a Parameter Template
- Viewing Application Records of a Parameter Template
- Modifying the Description of a Parameter Template
- Deleting a Parameter Template
- Account Management
- Backups and Restorations
-
Data Migration
- Overview
- Migration Evaluation
- Scenario 1: Migrating Data from an On-Premises MySQL Instance to DDM
- Scenario 2: Migrating Data from a Third-Party Cloud MySQL Instance to DDM
- Scenario 3: Migrating Data from an ECS-hosted MySQL Instance on Huawei Cloud to DDM
- Scenario 4: Exporting Data from a DDM Instance
- Scenario 5: Migrating Data from Heterogeneous Databases to DDM
- Scenario 6: Migrating Data from Huawei Cloud RDS for MySQL to DDM
- Session Management
- Slow Queries
- Monitoring and Alarm Reporting
- Task Center
- Tags
- Auditing
-
SQL Syntax
- Introduction
- DDL
- DML
- Online DDL
- Functions
- Unsupported Objects and Use Constraints
- Supported SQL Statements
- Global Sequence
- Database Management Syntax
- Advanced SQL Functions
- Quotas
-
API Reference
- Before You Start
- API Overview
- Calling APIs
-
APIs (Recommended)
-
DDM Instances
- Buying a DDM instance
- Querying DDM Instances
- Querying Details of a DDM Instance
- Modifying the Name of a DDM Instance
- Changing the Security Group of a DDM Instance
- Deleting a DDM Instance
- Restarting a DDM Instance
- Reloading Table Data
- Scaling Out a DDM Instance
- Scaling in a DDM instance
- Modifying the Read Policy of the Associated DB Instance
- Synchronizing Data Node Information
- Querying Nodes of a DDM Instance
- Querying Details of a DDM Instance Node
- Querying Parameters of a Specified DDM Instance
- Modifying Parameters of a DDM Instance
- Querying DDM Engine Information
- Querying DDM Node Classes Available in an AZ
- Changing the Node Class of a DDM Instance
- Obtaining the Instance Group Information
- Creating an Instance Group
- Schemas
- Accounts
- Monitoring
- Session Management
- Application Examples
-
DDM Instances
- Permissions Policies and Supported Actions
- Appendix
- SDK Reference
-
Best Practices
- Overview
- Formulating Sharding Rules
- Determining the Number of Shards in a Schema
- Using Broadcast and Unsharded Tables
- Transaction Models
- SQL Standards
- Migrating an Entire RDS Database to DDM
- Migrating an Entire MyCat Database to DDM
- Accessing DDM Using a JDBC Connection Pool
- Logging In to a DDM Instance Using Navicat
- Migrating Data from RDS for MySQL to DDM Using DRS
- Sharding Database and Table Data of an RDS for MySQL Instance
- Performance White Paper
-
FAQs
- General Questions
-
DDM Usage
- How Does DDM Perform Sharding?
- What Do I Do If I Fail to Connect to a DDM Instance Using the JDBC Driver?
- Why It Takes So Long Time to Export Data from MySQL Using mysqldump?
- What Do I Do If a Duplicate Primary Key Error Occurs When Data Is Imported into DDM?
- What Should I Do If an Error Message Is Returned When I Specify an Auto-Increment Primary Key During Migration?
- What Do I Do If an Error Is Reported When Parameter Configuration Does Not Time Out?
- Which Should I Delete First, a Schema or its Associated RDS Instances?
- Can I Manually Delete Databases and Accounts Remained in Data Nodes After a Schema Is Deleted?
- SQL Syntax
-
RDS-related Questions
- Is the Name of a Database Table Case-Sensitive?
- What Risky Operations on RDS for MySQL Will Affect DDM?
- How Do I Handle Data with Duplicate Primary Keys in a Table?
- How Can I Query RDS for MySQL Information by Running Command show full innodb status?
- What Should I Pay Attention to When Selecting RDS for MySQL Instance Specifications?
- Connection Management
- Resource Freezing, Release, Deletion, and Unsubscription
- Videos
-
More Documents
-
User Guide (ME-Abu Dhabi Region)
- Service Overview
- Getting Started
- Function Overview
- Instance Management
-
Parameter Template Management
- Creating a Parameter Template
- Editing a Parameter Template
- Comparing Two Parameter Templates
- Viewing Parameter Change History
- Replicating a Parameter Template
- Applying a Parameter Template
- Viewing Application Records of a Parameter Template
- Modifying the Description of a Parameter Template
- Deleting a Parameter Template
- Task Center
- Schema Management
- Account Management
- Backup Management
- Monitoring Management
- Auditing
-
SQL Syntax
- Introduction
- DDL
- DML
- Functions
- Unsupported Items
- Supported SQL Statements
- Global Sequence
- Database Management Syntax
- Advanced SQL Functions
-
FAQs
- General Questions
-
DDM Usage
- How Can I Rectify a Fault in Accessing DDM by Using the JDBC Driver?
- What Version and Parameters Should I Select?
- Why It Takes So Long Time to Export Data from MySQL Using mysqldump?
- How Should I Handle the Duplicate Primary Key Error Occurring After Data Is Imported into DDM?
- What Should I Do If an Error Message Is Returned After I Specify an Auto-Increment Primary Key?
- How Do I Handle the Error Reported When Parameter Configuration Does Not Time Out?
- Which Should I Delete First, Schema or Associated RDS DB Instances?
- Should I Manually Delete Databases and Accounts Remained in the Associated RDS DB Instances After a Schema Is Deleted?
- SQL Syntax
- RDS-related Questions
- Connection Management
-
User Guide (Kuala Lumpur Region)
- Service Overview
- Getting Started
- Function Overview
- Instance Management
-
Parameter Template Management
- Creating a Parameter Template
- Editing a Parameter Template
- Comparing Two Parameter Templates
- Viewing Parameter Change History
- Replicating a Parameter Template
- Applying a Parameter Template
- Viewing Application Records of a Parameter Template
- Modifying the Description of a Parameter Template
- Deleting a Parameter Template
- Task Center
- Schema Management
- Account Management
- Backup Management
- Monitoring Management
- Auditing
-
SQL Syntax
- Introduction
- DDL
- DML
- Functions
- Unsupported Items
- Supported SQL Statements
- Global Sequence
- Database Management Syntax
- Advanced SQL Functions
-
FAQs
- General Questions
-
DDM Usage
- How Can I Rectify a Fault in Accessing DDM by Using the JDBC Driver?
- What Version and Parameters Should I Select?
- Why It Takes So Long Time to Export Data from MySQL Using mysqldump?
- How Should I Handle the Duplicate Primary Key Error Occurring After Data Is Imported into DDM?
- What Should I Do If an Error Message Is Returned After I Specify an Auto-Increment Primary Key?
- How Do I Handle the Error Reported When Parameter Configuration Does Not Time Out?
- Which Should I Delete First, Schema or Associated RDS DB Instances?
- Should I Manually Delete Databases and Accounts Remained in the Associated RDS DB Instances After a Schema Is Deleted?
- SQL Syntax
- RDS-related Questions
- Connection Management
-
API Reference (Kuala Lumpur Region)
- Before You Start
- API Overview
- Calling APIs
-
DDM Instance Management
- Querying DDM Engine
- Querying the Quota of Classes Available in Each AZ
- Creating a DDM Instance
- Querying DDM Instances
- Viewing Details of a DDM Instance
- Modifying the Name of a DDM Instance
- Modifying the Security Group of a DDM Instance
- Deleting a DDM Instance
- Restarting a DDM Instance
- Reloading Table Data
- Scaling Out a DDM instance
- Scaling In a DDM instance
- Modifying the Read Policy of the Associated DB Instance
- Synchronizing DB Instance Data
- Querying Nodes of a DDM Instance
- Querying Details of a DDM Instance Node
- Querying Parameters of a Specified DDM Instance
- Modifying Parameters of a DDM Instance
- Schema Management
- Account Management
- Monitoring Management
- Permissions Policies and Supported Actions
- Appendix
- Change History
-
User Guide (ME-Abu Dhabi Region)
- General Reference
Show all
Copied.
SQL Standards
INSERT
- Syntax rules
- Do not use INSERT to add data entries one by one. INSERT INTO VALUES (),()..() is recommended.
- The MySQL JDBC driver ignores the executeBatch() statement by default, splits SQL statements that should be executed in batches into single statements, and sends them to the MySQL database one by one. This greatly deteriorates database performance. To execute SQL statements in batches, you have to set parameter rewriteBatchedStatements to true and ensure that the SQL JDBC driver is of version 5.1.13 or later. The driver executes SQL statements in batches only when rewriteBatchedStatements is set to true. This configuration is valid for INSERT, UPDATE, and DELETE operations.
CAUTION:
After you set rewriteBatchedStatements to true, set a proper value for batch size to control the number of INSERT, UPDATE, and DELETE operations. If the batch size value is too large, the performance may deteriorate. Unless otherwise specified, the value is not larger than 1000.
- Do not set the sharding key value to a function, expression, or sub-query. A constant is recommended.
- Do not set a common key value to a sub-query. A constant, function, or expression is recommended.
- Batch data import
LOAD DATA LOCAL INFILE is recommended for importing a large volume of data in batches.
CAUTION:
You only need to enable a session, and DDM will automatically imports data.
- Data migration
Use mysqldump to export SQL files and import them by running the MySQL source command.
- Field auto_increment
- DDM can create a unique global sequence of numbers using the AUTO-INCREMENT attribute.
- If field auto-increment is used, do not assign its value in the VALUES clause. Otherwise, a primary key conflict may occur. If a value has been assigned in the VALUES clause, you can change it using ALTER SEQUENCE.
- Do not set the auto-increment step to 1 to ensure stable performance. The default step is 1000.
UPDATE and DELETE
- Common updates
- Configure a sharding field in the WHERE condition when you perform an update or delete operation.
- If the sharding field cannot be configured, reduce concurrency and control data entries involved in updates or deletion operations. You can use SELECT to search for the data that you want to update or delete, determine the data scope with DOUBLE CHECK, and finally perform an update or deletion.
- Sharding field update
- When you update a sharding field, ensure that there is a maximum of 10,000 data entries in the target table. If there are more than 10,000 data entries, create a table with the required sharding field or update the original sharding field by dividing one update operation into multiple small equivalent operations.
- Update sharding fields during off-peak hours.
- Association
Do not perform an update or delete operation on multiple tables at the same time.
- Subquery and LIMIT
Do not use subqueries in an UPDATE or DELETE statement. Do not use LIMIT or ORDER BY LIMIT in UPDATE or DELETE statements.
SELECT
- ORDER BY LIMIT function
- When you use statement ORDER BY LIMIT, count or ORDER BY OFFSET, count, do not assign a large value for offset.
- If error Temp table limit exceeded is returned, a temporary table containing intermediate data is generated and its data entries exceed the upper limit. Contact DDM technical support for SQL tuning.
- GROUP BY function
- Configure only field group by in statement SELECT_LIST.
- Do not use clause ORDER BY in aggregate function group_concat that cannot be pushed.
- Ensure that there are no more than three DISTINCT or GROUP BY fields.
- Do not perform a GROUP BY operation after a JOIN or subquery operation.
- Do not use COUNT(DISTINCT ) or SUM(DISTINCT ).
- If error Temp table limit exceeded is returned, a temporary table containing intermediate data is generated during aggregation and its data entries exceed the upper limit. Contact DDM technical support for SQL tuning.
- JOIN function
- In a SELECT statement, specify a sharding field for each table or a broadcast table in the JOIN condition. Alternatively, use INNER/LEFT JOIN or RIGHT JOIN and ensure that the driving table is the smaller one.
- Do not join two large tables directly.
- Do not use OUTER JOIN in the JOIN ON condition.
- If error Temp table limit exceeded is returned, a temporary table containing intermediate data is generated during the JOIN operation and its data entries exceed the upper limit. Contact DDM technical support for SQL tuning.
- Do not join more than five tables directly.
- Do not enable transactions when you perform a JOIN query.
- Do not perform a JOIN query in a transaction. Enabling transactions affects DDM's selection of the most efficient JOIN algorithm.
CAUTION:
The size of tables depends on the volume of data selected using the WHERE condition.
- Subqueries
- Do not use a subquery or its JOIN condition in an OR expression.
- Do not use scalar subqueries containing LIMIT, for example, SELECT (SELECT x FROM t2 WHERE t2.id= t.id LIMIT 1),a,b FROM t.
- If subqueries and primary table are routed to the same shard, add /*+db=xxx*/ before your SQL statement to improve routing accuracy.
- Do not use JOIN clauses in subqueries.
- Do not use nested subqueries.
- Do not perform an operation by comparing ROW expression with a subquery, for example, SELECT * FROM t WHERE (a,b,c)=(SELECT x,y,z FROM t2 WHERE …).
- Do not use more than two subqueries in SELECT_LIST.
DDL
- Execution of DDL statements
Perform DDL operations on existing tables during off-peak hours.
- Number of shards
Before creating a sharded table, you can estimate the total volume of data to determine table shards. Do not configure more shards than required. The number of table shards is not as large as possible.
- High-risk DDL statements
Carefully check the SQL statement when you perform a high-risk DDL operation, for example, DROP TABLE and TRUNCATE TABLE.
- Rectification of DDL failures
If an error occurs during execution of a DDL statement, execute CHECK TABLE name to verify the structure of each table shard, locate the failed table shard, and rectify the fault. For example, if ALTER TABLE fails, add /*+allow_alter_rerun=true/ before the statement, enable the POWER operation, and execute the statement again till an output is returned, indicating structures of all tables are consistent.
- DDL execution error caused by MDL locks
- Background: Before a DDL statement is executed, DDM checks whether there are MDL locks held for tables in the associated RDS database to ensure DDL availability. If there are MDL locks, DDL reports an error and exits.
metadata lock exists, one of MDL is [%s],DDL operation can not proceed, please use 'show metadata lock' to check current mdl, and use 'kill physical threadId@host:port' to clean it
- Possible issues: If there are slow SQL statements that have been executed for several minutes, the possible cause may be MDL locks. In this case, DDL statements cannot be executed.
- Solution 1: Set a larger value for ddl_precheck_mdl_threshold_time on the DDM console, for example, set it to 30 minutes (1800 seconds).
NOTE:
ddl_precheck_mdl_threshold_time indicates the maximum duration in seconds for which a DDL statement holds an MDL lock. DDL reports an error only when the lock duration exceeds the threshold. The default value is 120 seconds.
- Solution 2: Execute SHOW METADATA LOCK to check whether DDL execution is blocked by the MDL lock held for a slow transaction. If yes, execute kill physical threadId@host:port to disable the underlying slow transaction. Then use hint /*+allow_alter_rerun=true*/ and CHECK TABLE to complete execution of DDL statements.
NOTE:
threadId indicates the thread ID of the underlying RDS instance node. host and port indicate the IP address and port of the RDS instance node.
- Background: Before a DDL statement is executed, DDM checks whether there are MDL locks held for tables in the associated RDS database to ensure DDL availability. If there are MDL locks, DDL reports an error and exits.
- Long execution time of DDL statements
If DDL execution is suspended for a long time during off-peak hours, enable another session and execute XA RECOVER to check whether there are slow transactions. If yes, contact technical support.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot