PolarDB-X supports three sequence types — new sequences, group sequences, and time sequences — each with distinct version requirements, conversion rules, and behavioral constraints.
New sequences
New sequences are available only in AUTO databases on PolarDB-X instances running kernel version V5.4.14 or later.
Version requirements
| Feature | Minimum kernel version |
|---|---|
| New sequences in AUTO databases | V5.4.14 |
INCREMENT BY, MAXVALUE, CYCLE, NOCYCLE parameters | V5.4.17 |
Before downgrading your kernel version
If your instance contains new sequences and you plan to downgrade to a version that does not support them, convert all new sequences to group sequences first.
Check whether new sequences exist:
SELECT * FROM INFORMATION_SCHEMA.SEQUENCES;If new sequences exist, convert them all to group sequences:
CONVERT ALL SEQUENCES FROM NEW TO GROUP;For more information, see CONVERT SEQUENCES.
GMS caching behavior
In new sequences, Global Meta Service (GMS) assigns values for auto-increment columns. GMS caches a batch of values in advance to maintain performance.
If GMS undergoes an operation such as an update, failover, configuration change, or migration, all cached values are discarded and skipped. The sequence will not produce those values again, and gaps will appear in the output.
Group sequences
Group sequences are the default sequence type for:
All databases in PolarDB-X instances running kernel version V5.4.13 or earlier
Databases in DRDS mode in PolarDB-X instances running kernel version V5.4.14 or later
Constraints
| Constraint | Details |
|---|---|
| Minimum value | 100001 (the START WITH value defaults to 100001) |
| Multi-unit group sequence conversion | Cannot be converted to another sequence type; other sequence types cannot be converted to a multi-unit group sequence |
| Modifiable parameters for multi-unit group sequences | Only START WITH can be changed; all other defining parameters are fixed |
Unit sequence requirements
For unit sequences within the same group sequence:
The
UNIT COUNTvalue must be the same across all unit sequences.The
INDEXvalue must be different for each unit sequence.
These constraints ensure sequence values remain globally unique across multiple instances or databases.
Avoid using `AUTO_SEQ_` sequences with explicit INSERT
PolarDB-X automatically creates a group sequence prefixed with AUTO_SEQ_ when you create a table with an auto-increment column.
Do not call NEXTVAL on an AUTO_SEQ_-prefixed sequence and then insert the returned value explicitly with INSERT. This forces the sequence to refresh its cache frequently, causing the sequence value to increase rapidly.
Instead, omit the auto-increment column from your INSERT statement and let PolarDB-X generate the value automatically:
-- Recommended: let PolarDB-X generate the auto-increment value
INSERT INTO my_table (col1, col2) VALUES ('value1', 'value2');Time sequences
To use a time sequence for an auto-increment column, the column's data type must be BIGINT.