This topic describes how to use X-Engine.
Migrate a table from InnoDB to X-Engine
Run the following command to change the storage engine of a table from InnoDB to X-Engine:
ALTER TABLE <database_name>.<table_name> ENGINE xengine;The ALTER command blocks all Data Manipulation Language (DML) and Data Definition Language (DDL) write operations on the table while the conversion is in progress.
Create an X-Engine table
In a cluster that uses both InnoDB and X-Engine, specify the engine explicitly when creating a table:
CREATE TABLE t1(c1 int primary key , c2 int) ENGINE=xengine;Adjust the memory resource ratio
On the X-Engine (Warm Data) tab of the Configuration and Management > Time to Live page for your cluster, adjust the memory resource ratio at any time to match your workload.

The following table shows recommended ratios for three typical scenarios. Set the ratio based on your business requirements.
| Scenario | InnoDB (%) | X-Engine (%) |
|---|---|---|
| InnoDB for hot data, X-Engine for cold data that is seldom accessed | 80 | 20 |
| InnoDB for hot data, X-Engine for cold data that is still updated and queried | 50 | 50 |
| InnoDB for small amounts of data, X-Engine for large amounts that require updates or queries | 20 | 80 |
Limitations
Engine feature limits
X-Engine does not support the following SQL features, index types, and lock options. Features not listed in this table behave the same as in InnoDB.
| Category | Feature | Constraint |
|---|---|---|
| SQL features | Foreign keys | Not supported |
| Temporary tables | Not supported | |
| Generated columns | Not supported | |
| Handler API | Not supported | |
| Columns and records | Maximum columns per table | 10,000 |
| Maximum record length | 256 MB | |
| GIS data types | Not supported. This includes geometry, point, linestring, polygon, multipoint, multilinestring, multipolygon, and geometrycollection. | |
| Indexes | Hash indexes | Not supported |
| Spatial indexes | Not supported | |
| Full-text indexes | Not supported (creation and use) | |
| Transactions | Supported isolation levels | Read Committed (RC) and Repeatable Read (RR) |
| Maximum rows per transaction | 100,000 rows by default. Adjust with the loose_xengine_bulk_load_size parameter. | |
| Savepoint | Not supported | |
| XA transactions | Internal XA transactions are supported | |
| Locks | Lock granularity | Table-level locks and row-level locks are supported. Gap locks are not supported. |
| Skip Locked | Not supported | |
| Lock Nowait | Not supported | |
| Character sets | Non-indexed columns | All character sets and collations are supported |
| Indexed columns | Supported character sets: latin1 (latin1_bin), gbk (gbk_chinese_ci, gbk_bin), utf8 (utf8_general_ci, utf8_bin), utf8mb4 (utf8mb4_0900_ai_ci, utf8mb4_general_ci, utf8mb4_bin) | |
| Primary/secondary replication | Binary logging format | stmt, row, and mixed formats are supported. The default is row. The stmt and mixed formats may cause data security issues in specific concurrent scenarios. |
Limits on large transactions
X-Engine does not support large transactions. When a transaction modifies 10,000 or more rows, X-Engine automatically enables the commit in middle feature, which internally commits the transaction and starts a sub-transaction to continue. This does not strictly adhere to transaction atomicity.
The following behaviors apply when commit in middle is triggered:
INSERT operations: A portion of the inserted data is committed mid-transaction. Other sessions can read those rows before the entire transaction completes.
Modify operations: Rows committed by
commit in middlecannot be rolled back. In the following example, rolling back after inserting 12,000 rows only removes the last 2,000 — the first 10,000 are already committed:DROP TABLE t1; CREATE TABLE t1(c1 int primary key , c2 int)ENGINE=xengine; BEGIN; call insert_data(12000); -- Inserts 12,000 rows; the first 10,000 are committed by commit in middle rollback; -- Only the last 2,000 rows are rolled back SELECT COUNT(*) FROM t1; -- Returns 10,000 +----------+ | COUNT(*) | +----------+ | 10000 | +----------+ 1 row in set (0.00 sec)INSERT followed by DELETE in the same transaction:
commit in middlemay prevent the DELETE from reading rows inserted earlier in the same transaction, leaving those rows undeleted:DROP TABLE t1; CREATE TABLE t1(c1 int primary key , c2 int)ENGINE=xengine; call insert_data(10000); BEGIN; INSERT INTO t1 VALUES(10001,10001), (10002,10002); DELETE FROM t1 WHERE c1 >= 0; -- commit in middle prevents reading the newly inserted rows commit; SELECT * FROM t1; -- Rows 10001 and 10002 are still present +-------+-------+ | c1 | c2 | +-------+-------+ | 10001 | 10001 | | 10002 | 10002 | +-------+-------+ 2 rows in set (0.00 sec)
Parameters
Modify the following parameters based on your requirements. For instructions, see Set cluster parameters and node parameters.
Parameter name prefix:
PolarDB console: Parameters appear with the
loose_prefix for MySQL configuration file compatibility. Find and modify parameters using theirloose_-prefixed names.Database session (CLI or client): When using the
SETcommand, remove theloose_prefix and use the original parameter name.
| Category | Parameter | Description | Modifiable | Restart required |
|---|---|---|---|---|
| Performance | xengine_batch_group_max_group_size | Maximum number of groups in a transaction pipeline | No | N/A |
xengine_batch_group_max_leader_wait_time_us | Maximum wait time of a transaction pipeline | No | N/A | |
xengine_batch_group_slot_array_size | Maximum batch size of a transaction pipeline | No | N/A | |
xengine_parallel_read_threads | Number of concurrent parallel scans | Yes | No | |
xengine_parallel_wal_recovery | Parallel recovery | No | N/A | |
| Memory | xengine_block_cache_size | Size of the block cache used to cache table data and indexes | Yes | No |
xengine_row_cache_size | Size of the row cache | No | N/A | |
xengine_write_buffer_size | Maximum size of a single Memtable | No | N/A | |
xengine_block_size | Size of a data block on disk | No | N/A | |
xengine_db_write_buffer_size | Total size limit for active Memtables of all subtables | No | N/A | |
xengine_db_total_write_buffer_size | Total size limit for active and immutable Memtables of all subtables | Yes | No | |
xengine_scan_add_blocks_limit | Number of blocks that can be added to the block cache per range scan request | Yes | No | |
| Compaction | xengine_flush_delete_percent_trigger | Total number of records that triggers a Memtable switch | No | N/A |
| Locks | xengine_max_row_locks | Maximum number of rows that can be locked in a single SQL request | No | N/A |
xengine_lock_wait_timeout | Lock wait timeout period | Yes | No |