All Products
Search
Document Center

PolarDB:X-Engine usage notes

Last Updated:Mar 28, 2026

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;
Important

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.

image

The following table shows recommended ratios for three typical scenarios. Set the ratio based on your business requirements.

ScenarioInnoDB (%)X-Engine (%)
InnoDB for hot data, X-Engine for cold data that is seldom accessed8020
InnoDB for hot data, X-Engine for cold data that is still updated and queried5050
InnoDB for small amounts of data, X-Engine for large amounts that require updates or queries2080

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.

CategoryFeatureConstraint
SQL featuresForeign keysNot supported
Temporary tablesNot supported
Generated columnsNot supported
Handler APINot supported
Columns and recordsMaximum columns per table10,000
Maximum record length256 MB
GIS data typesNot supported. This includes geometry, point, linestring, polygon, multipoint, multilinestring, multipolygon, and geometrycollection.
IndexesHash indexesNot supported
Spatial indexesNot supported
Full-text indexesNot supported (creation and use)
TransactionsSupported isolation levelsRead Committed (RC) and Repeatable Read (RR)
Maximum rows per transaction100,000 rows by default. Adjust with the loose_xengine_bulk_load_size parameter.
SavepointNot supported
XA transactionsInternal XA transactions are supported
LocksLock granularityTable-level locks and row-level locks are supported. Gap locks are not supported.
Skip LockedNot supported
Lock NowaitNot supported
Character setsNon-indexed columnsAll character sets and collations are supported
Indexed columnsSupported 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 replicationBinary logging formatstmt, 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 middle cannot 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 middle may 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 their loose_-prefixed names.

  • Database session (CLI or client): When using the SET command, remove the loose_ prefix and use the original parameter name.

CategoryParameterDescriptionModifiableRestart required
Performancexengine_batch_group_max_group_sizeMaximum number of groups in a transaction pipelineNoN/A
xengine_batch_group_max_leader_wait_time_usMaximum wait time of a transaction pipelineNoN/A
xengine_batch_group_slot_array_sizeMaximum batch size of a transaction pipelineNoN/A
xengine_parallel_read_threadsNumber of concurrent parallel scansYesNo
xengine_parallel_wal_recoveryParallel recoveryNoN/A
Memoryxengine_block_cache_sizeSize of the block cache used to cache table data and indexesYesNo
xengine_row_cache_sizeSize of the row cacheNoN/A
xengine_write_buffer_sizeMaximum size of a single MemtableNoN/A
xengine_block_sizeSize of a data block on diskNoN/A
xengine_db_write_buffer_sizeTotal size limit for active Memtables of all subtablesNoN/A
xengine_db_total_write_buffer_sizeTotal size limit for active and immutable Memtables of all subtablesYesNo
xengine_scan_add_blocks_limitNumber of blocks that can be added to the block cache per range scan requestYesNo
Compactionxengine_flush_delete_percent_triggerTotal number of records that triggers a Memtable switchNoN/A
Locksxengine_max_row_locksMaximum number of rows that can be locked in a single SQL requestNoN/A
xengine_lock_wait_timeoutLock wait timeout periodYesNo