All Products
Search
Document Center

PolarDB:Usage of X-Engine

Last Updated:Feb 10, 2025

This topic describes how to use X-Engine.

Change the storage engine of a table from InnoDB to X-Engine

Execute the following statement to change the storage engine of a table from InnoDB to X-Engine:

ALTER TABLE <database name>.<table name> ENGINE xengine;
Note

When you use the ALTER statement to change the storage engine of a table from InnoDB to X-Engine, DML and DDL write operations to the table are blocked.

Create a table by using X-Engine

To create a table by using X-Engine in a cluster that uses X-Engine and InnoDB, specify X-Engine as the storage engine when you create the table. Sample statement:

CREATE TABLE t1(c1 int primary key , c2 int) ENGINE=xengine;

Adjust the proportion of memory resources

Log on to the PolarDB console and then find a cluster that you want to manage. On the cluster details page, choose Settings and Management > Data Lifecycle. On the page that appears, click the X-Engine (Warm Data) tab. On this tab, adjust the proportion of memory resources based on your business requirements.image

The following table provides the recommended proportion for three typical scenarios. You can set your proportion based on your business requirements.

Scenario

InnoDB (%)

X-Engine (%)

Use InnoDB for hot data and X-Engine for cold data. The cold data is classified as seldom accessed data.

80

20

Use InnoDB for hot data and X-Engine for cold data. The cold data is still updated and can be queried.

50

50

Use InnoDB for small amounts of data and X-Engine for large amounts of data that require to be updated or queried.

20

80

Limits

X-Engine imposes limits on features and large transactions.

Limits on features

Category

Feature

Description

SQL features

Foreign keys

Not supported

Temporary tables

Not supported

Generated Column

Not supported

Handler API

Not supported

Column properties

Maximum column length (longblob/longtext/json)

32 MB

GIS data types

X-Engine does not support GIS data types, including GEOMETRY, POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, and GEMOMETRYCOLLECTION.

Indexes

Hash indexes

Not supported

Spatial indexes

Not supported. X-Engine does not support the creation or use of full-text indexes.

Transactions

Transaction isolation level

X-Engine supports the following isolation levels:

  • Read Committed (RC)

  • Repeatable Read (RR)

Maximum amount of data supported by a transaction

32 MB

Savepoint

Not supported

XA transactions

X-Engine supports internal XA transactions.

Locks

Lock granularity

  • X-Engine supports table-level and row-level locks.

  • X-Engine does not support gap locks.

Skip Locked

Not supported

Lock Nowait

Not supported

Character sets

Character sets supported by non-indexed columns

All

Character sets supported by indexed columns

  • Latin1 (latin1_bin)

  • GBK (gbk_chinese_ci and gbk_bin)

  • UTF-8 (utf8_general_ci and utf8_bin)

  • UTF-8MB4 (utf8mb4_0900_ai_ci, utf8mb4_general_ci, and utf8mb4_bin)

Primary/secondary replication

Binary log formats

X-Engine supports the following formats:

  • stmt

  • row

  • mixed

Note

By default, binary logs use the row format. The stmt and mixed log formats may cause data security issues in specific concurrency scenarios.

Note

By default, the features of X-Engine that are not described in the preceding table are the same as the features of InnoDB.

Limits on large transactions

X-Engine does not support large transactions. If the number of rows modified in a transaction is greater than or equal to 10,000, X-Engine enables the commit in middle feature. This way, X-Engine can internally commit the transaction and start a sub-transaction to continue to perform the transaction. However, the commit in middle feature may not ensure the atomicity of transactions. Take note of the following items when you use the commit in middle feature:

  • Assume that you want to start a transaction to insert a large amount of data. During the insertion, part of the data is committed because of the commit in middle feature. The inserted data can be queried by other requests.

  • Assume that you want to start a transaction to modify a large amount of data. The data that has been committed by the commit in middle feature cannot be rolled back.

    DROP TABLE t1;
    CREATE TABLE t1(c1 int primary key , c2 int)ENGINE=xengine;
    BEGIN;
    call insert_data(12000);// 12,000 rows are inserted and a commit in middle operation is triggered. As a result, the first 10,000 rows of data are committed. 
    rollback;// You can roll back only the last 2,000 rows. 
    SELECT COUNT(*) FROM t1;// The committed 10,000 rows of data can be queried. 
    +----------+
    | COUNT(*) |
    +----------+
    |    10000 |
    +----------+
    1 row in set (0.00 sec)
  • Assume that you want to modify and delete a large amount of data in a transaction. The DELETE operation cannot read the committed rows in this transaction because of the commit in middle feature. As a result, you cannot delete the newly committed data.

    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;// The deletion operation triggers a commit in middle operation, and the two rows of data inserted by the current transaction are not deleted. 
    commit;
    SELECT * FROM t1;
    +-------+-------+
    | c1    | c2    |
    +-------+-------+
    | 10001 | 10001 |
    | 10002 | 10002 |
    +-------+-------+
    2 rows in set (0.00 sec)

Parameters

You can modify the parameters that allow modifications based on your business scenarios. For more information, see Configure cluster and node parameters.

Note To ensure compatibility with MySQL configuration files, all parameters in the PolarDB console is prefixed with loose_. If you want to modify the imci_enable_pack_order_key parameter in the PolarDB console, specify the MySQL-compatible version that has the loose_ prefix, which is loose_imci_enable_pack_order_key.

Category

Parameter

Description

Modifiable

Restart after modification

Performance

xengine_batch_group_max_group_size

The maximum number of groups in a transaction pipeline.

No

N/A

xengine_batch_group_max_leader_wait_time_us

The maximum waiting time of a transaction pipeline.

No

N/A

xengine_batch_group_slot_array_size

The maximum batch size of a transaction pipeline.

No

N/A

xengine_parallel_read_threads

The number of parallel read threads.

Yes

No

xengine_parallel_wal_recovery

Specifies whether to enable parallel Write-Ahead Logging (WAL) recovery.

No

N/A

Memory

xengine_block_cache_size

The size of the read block cache.

Yes

No

xengine_row_cache_size

The size of the row cache.

No

N/A

xengine_write_buffer_size

The maximum size of a memory table.

No

N/A

xengine_block_size

The size of the data block on a disk.

No

N/A

xengine_db_write_buffer_size

The maximum size of the active memory tables in all subtables.

No

N/A

xengine_db_total_write_buffer_size

The maximum size of the active memory tables and immutable memory tables in all subtables.

Yes

No

xengine_scan_add_blocks_limit

The number of blocks that can be added to the block cache during each range-based scan request.

Yes

No

compaction

xengine_flush_delete_percent_trigger

The number of records to trigger memory table switching. If the number of records in a memory table is greater than the value of this parameter, a memory table switching is triggered.

No

N/A

Locks

xengine_max_row_locks

The maximum number of rows that can be locked in a single SQL request.

No

N/A

xengine_lock_wait_timeout

The timeout period of a lock wait.

Yes

No