Loading...
Loading...
Design partition schemes, select partition keys, create GSI, and write SQL for PolarDB-X 2.0 Enterprise Edition AUTO mode databases, handling PolarDB-X vs MySQL differences (partitioned tables, GSI, CCI, Sequence, table groups, TTL, pagination, etc.). Use when designing partition schemes, selecting partition keys, converting single tables to partitioned tables, creating GSI/CCI indexes, writing or migrating SQL for PolarDB-X, or diagnosing slow queries on PolarDB-X. Triggers: "PolarDB-X SQL", "PolarDB-X create table", "partitioned table", "partition design", "partition scheme", "partition key", "GSI", "CCI", "Sequence", "MySQL migrate to PolarDB-X", "PolarDB-X compatibility", "single table to partitioned table", "convert to partitioned table", "large table", "distributed table", "AUTO mode", "pagination query", "Keyset pagination", "Range partition", "auto add partition", "PolarDB-X slow query", "full-shard scan"
npx skill4agent add aliyun/alibabacloud-aiops-skills alibabacloud-polardbx-sqlPARTITION BYdbpartition/tbpartitionSHOW CREATE DATABASE db_name;
-- Output containing MODE = 'auto' indicates AUTO modemysql -h <host> -P <port> -u <user> -p<password> -D <database>IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (e.g., RegionId, instance names, CIDR blocks, passwords, domain names, resource specifications, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
| Parameter Name | Required/Optional | Description | Default Value |
|---|---|---|---|
| host | Required | PolarDB-X instance connection address | None |
| port | Required | PolarDB-X instance port | 3306 |
| user | Required | Database username | None |
| password | Required | Database password | None |
| database | Required | Target database name | None |
SELECT VERSION();TDDL5.7.25-TDDL-5.4.19-20251031TDDL5.6.29-TDDL-5.4.12-16327949X-Cluster8.0.32-X-Cluster-8.4.20-20251017polardbx-standardSHOW CREATE DATABASE db_name;BROADCASTSINGLEPARTITION BY KEY(...) PARTITIONS NKEYHASHEXPLAINEXPLAIN EXECUTEEXPLAIN SHARDINGEXPLAIN ANALYZESINGLEBROADCAST-- ✅ Correct: GSI with PARTITION BY clause
GLOBAL INDEX g_i_seller(seller_id) PARTITION BY KEY(seller_id) PARTITIONS 16
CLUSTERED INDEX cg_i_buyer(buyer_id) PARTITION BY KEY(buyer_id) PARTITIONS 16
-- ❌ Wrong: Missing PARTITION BY (this is NOT MySQL INDEX syntax)
GLOBAL INDEX gsi_seller(seller_id)CLUSTERED COLUMNAR INDEXNEW SEQUENCEINSPECT INDEXPARTITION BY KEY(...) PARTITIONS NGLOBAL INDEX idx(col):=EXPLAIN SHARDINGEXPLAIN ANALYZELIMIT M, N(sort_column, id)TTL_CLEANUP = 'OFF'CLEANUP EXPIRED DATA WITH TTL_CLEANUP = 'OFF'| Reference | Description |
|---|---|
| references/create-table.md | CREATE TABLE syntax, table types (single/broadcast/partitioned), partition strategies, secondary partitions, partition management |
| references/partition-design-best-practice.md | Partition design best practices: partition key/GSI/algorithm/count selection, three-step migration, complete examples |
| references/primary-key-unique-key.md | Primary key and unique key Global/Local classification, rules, risks, and recommendations |
| references/gsi.md | Global Secondary Index GSI/UGSI/Clustered GSI creation, querying, and limitations |
| references/cci.md | Clustered Columnar Index CCI creation, usage, and applicable scenarios |
| references/sequence.md | Sequence types (NEW/GROUP/SIMPLE/TIME), creation and usage |
| references/transactions.md | Distributed transaction model, isolation levels, and considerations |
| references/mysql-compatibility-notes.md | MySQL vs PolarDB-X compatibility differences and development limitations |
| references/explain.md | EXPLAIN command variants and execution plan diagnostics |
| references/ttl-table.md | TTL table definition, cold data archiving, and cleanup scheduling |
| references/online-ddl.md | Online DDL assessment, lock-free execution strategy, long transaction checks, DMS lock-free changes |
| references/pagination-best-practice.md | Efficient pagination: Keyset pagination, per-shard traversal, index requirements, Java examples |
| references/auto-add-range-parts.md | Range partition auto-add: TTL-based partition pre-creation, first/second level configuration, management commands |
| references/cli-installation-guide.md | Alibaba Cloud CLI installation guide |