tencent cloud

TDSQL-C for MySQL

Release Notes and Announcements
Release Notes
Product Announcements
Beginner's Guide
Product Introduction
Overview
Strengths
Use Cases
Architecture
Product Specifications
Instance Types
Product Feature List
Database Versions
Regions and AZs
Common Concepts
Use Limits
Suggestions on Usage Specifications
Kernel Features
Kernel Overview
Kernel Version Release Notes
Optimized Kernel Version
Functionality Features
Performance Features
Security Features
Stability Feature
Analysis Engine Features
Inspection and Repair of Kernel Issues
Purchase Guide
Billing Overview
Product Pricing
Creating Cluster
Specification Adjustment Description
Renewal
Payment Overdue
Refund
Change from Pay-as-You-Go to Yearly/Monthly Subscription
Change from Pay-as-You-Go to Serverless Billing
Value-Added Services Billing Overview
Viewing Billing Statements
Getting Started
Database Audit
Overview
Viewing Audit Instance List
Enabling Audit Service
Viewing Audit Logs
Log Shipping
Post-Event Alarm Configuration
Modifying Audit Rule
Modifying Audit Service
Disabling Audit Service
Audit Rule Template
Viewing Audit Task
Authorizing Sub-User to Use Database Audit
Serverless Service
Serverless Introduction
Creating and Managing a Serverless Cluster
Elastic Scaling Management Tool
Serverless Resource Pack
Multi-AZ Deployment
Configuration Change
FAQs
Serverless Cost Estimator
Operation Guide
Operation Overview
Switching Cluster Page View in Console
Database Connection
Instance Management
Configuration Adjustment
Instance Mode Management
Cluster Management
Scaling Instance
Database Proxy
Account Management
Database Management
Database Management Tool
Parameter Configuration
Multi-AZ Deployment
GD
Backup and Restoration
Operation Log
Data Migration
Parallel Query
Columnar Storage Index (CSI)
Analysis Engine
Database Security and Encryption
Monitoring and Alarms
Basic SQL Operations
Connecting to TDSQL-C for MySQL Through SCF
Tag
Practical Tutorial
Classified Protection Practice for Database Audit of TDSQL-C for MySQL
Upgrading Database Version from MySQL 5.7 to 8.0 Through DTS
Usage Instructions for TDSQL-C MySQL
New Version of Console
Implementing Multiple RO Groups with Multiple Database Proxy Connection Addresses
Strengths of Database Proxy
Selecting Billing Mode for Storage Space
Creating Remote Disaster Recovery by DTS
Creating VPC for Cluster
Data Rollback
Solution to High CPU Utilization
How to Authorize Sub-Users to View Monitoring Data
White Paper
Security White Paper
Performance White Paper
Troubleshooting
Connection Issues
Performance Issues
API Documentation
History
Introduction
API Category
Making API Requests
Instance APIs
Multi-Availability Zone APIs
Other APIs
Audit APIs
Database Proxy APIs
Backup and Recovery APIs
Parameter Management APIs
Billing APIs
serverless APIs
Resource Package APIs
Account APIs
Performance Analysis APIs
Data Types
Error Codes
FAQs
Basic Concepts
Purchase and Billing
Compatibility and Format
Connection and Network
Features
Console Operations
Database and Table
Performance and Log
Database Audit
Between TDSQL-C for MySQL and TencentDB for MySQL
Service Agreement
Service Level Agreement
Terms of Service
TDSQL-C Policy
Privacy Policy
Data Privacy and Security Agreement
General References
Standards and Certifications
Glossary
Contact Us

Customizing Column-Format Storage Ordering Keys

PDF
Focus Mode
Font Size
Last updated: 2026-02-05 14:47:05
The analysis engine reorganizes data based on the primary key of the table by default, converting it to column-format storage format and saving it in the column-format storage node. This storage method can significantly improve the efficiency of queries based on the primary key as well as the efficiency of scans in filtering scenarios. However, if business queries mostly depend on other fields for filtering or sorting, the sorting mechanism based on the primary key may not fully leverage its performance benefits. In this case, you can further optimize SQL query efficiency by adjusting the ordering key of the column-format storage table. A typical example is SaaS business scenarios where tenant ID is often used to filter queries. In these scenarios, tenant ID can be set as the ordering key.
Note:
Currently, only the analysis engine kernel versions 2.2410.11.1, 3.2503.4.0 and later support customizing column-format storage ordering keys.
Customizing column-format storage ordering keys can suspend synchronization. It is recommended to perform the operation during off-peak business hours.
The custom columnar storage sort key feature is exclusively effective for the "Read-Only Analytical Engine" and is not supported by analytical cluster.

Scenarios Where Customizing Column-Format Storage Ordering Keys Is Not Supported

A custom column-format storage ordering key should include a primary key field. The analysis engine determines whether a primary key is included. If it is not included, it implicitly adds the primary key field to the ordering key.
Columns such as float, double, longtext, blob, boolean, and json are not supported as custom ordering keys.
Customizing column-format storage ordering keys is not supported for tables without primary keys.
After customizing a column-format storage ordering key for a table, performing DDL operations (dropping, modifying, renaming, changing columns, or dropping the primary key) on the ordering key columns can interrupt the synchronization of the column-format storage table. For example, if the ordering key is modified to "id, c1, c2", performing such operations on these three columns in the primary node will interrupt synchronization.
A custom column-format storage ordering key can include up to eight fields.
Columns whose names contain Chinese characters or special characters are not supported as ordering keys.

Operation Steps

Creating a Custom Column-Format Storage Ordering Key Table with the CREATE Statement

To create a table in the read-write instance, you can add order_key=column1,column2 information to the COMMENT section of the table definition statement, separating it from other comments with a space.
CREATE TABLE table_name (
...
) COMMENT 'order_key=column_name[,column_name]';

## Example:
CREATE TABLE part (
p_partkey BIGINT NOT NULL PRIMARY KEY,
p_name VARCHAR(55) NOT NULL,
p_mfgr CHAR(25) NOT NULL,
p_brand CHAR(10) NOT NULL,
p_type VARCHAR(25) NOT NULL,
p_size BIGINT NOT NULL,
p_container CHAR(10) NOT NULL,
p_retailprice DECIMAL(15,2) NOT NULL,
p_comment VARCHAR(23) NOT NULL
) COMMENT 'Part information table order_key=p_brand,p_container,p_type';

Modifying Table Ordering Keys with the ALTER Statement

For tables with data already imported, you need to set a custom column-format storage ordering key by executing the ALTER statement in the read-write instance. The syntax is as follows:
ALTER TABLE table_name COMMENT 'order_key=column_name[,column_name]';

## Example:
ALTER TABLE part COMMENT 'Part information table order_key=p_brand,p_container,p_type';

Confirming Ordering Key Modification Success

Currently, the adjustment progress of the ordering key cannot be viewed. However, during the adjustment process, you still can query table data. Although data synchronization will be paused during the process, you can monitor the synchronization delay to confirm whether the ordering key has been modified.

Non-Standard Ordering Key Syntax

An ordering key contains duplicate column names:
ALTER TABLE part COMMENT 'Part information table order_key=p_partkey,p_type,p_partkey COLUMNAR=1';
A non-existing column is specified as the ordering key:
ALTER TABLE part COMMENT 'Part information table order_key=column';
Keyword error:
ALTER TABLE part COMMENT 'Part information table ORDERKEY=column';
No space is added to separate from other COMMENT information:
ALTER TABLE part COMMENT 'Part information table order_key=p_partkey';
Multiple ordering key keywords are used consecutively:
ALTER TABLE part COMMENT 'Part information table order_key=p_partkey order_key=p_partkey';
Ordering key keywords are empty:
ALTER TABLE part COMMENT 'Part information table order_key= COLUMNAR=1';

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback