Limits
This topic describes the limits on sequences and how to troubleshoot issues.
New sequences
New sequences can be used only in AUTO databases in PolarDB-X instances whose kernel versions are V5.4.14 and later.
Only instances of PolarDB-X 5.4.17 and later allow you to specify the INCREMENT BY, MAXVALUE, and CYCLE or NOCYCLE parameters for new sequences.
Before you downgrade the kernel version of your PolarDB-X instance that contains new sequences to a version that does not support new sequences, you must convert all new sequences to group sequences. Perform the following steps to convert all new sequences to group sequences:
Reference the INFORMATION_SCHEMA.SEQUENCES view to check whether new sequences exist in the instance.
If new sequences exist in the instance, execute the
CONVERT ALL SEQUENCES FROM NEW TO GROUP
statement to convert all new sequences in the instance to group sequences. For more information, see CONVERT SEQUENCES.
- In a new sequence, Global Meta Service (GMS) is used to assign the values of auto-incremental columns. To ensure good performance, GMS must cache some values. If you perform an operation on GMS, such as an update, failover, configuration change, or migration, the values that are cached before the operation is performed are discarded and skipped in the sequence.
Group sequences
By default, group sequences are used in databases in PolarDB-X instances whose kernel versions are V5.4.13 and earlier, and databases in DRDS mode in PolarDB-X instances whose kernel versions are V5.4.14 and later.
The start value of a group sequence is 100001. This indicates that the minimum value of a group sequence is 100001.
A group sequence that contains multiple units cannot be converted to a sequence of another type, and other types of sequences cannot be converted to group sequences that contain multiple units. You can change only the value of the START WITH parameter for a group sequence that contains multiple units. The values of other parameters that are used to define the sequence cannot be changed.
In the definitions of unit sequences that belong to the same group sequence, the values of the UNIT COUNT parameter must be the same, and the values of the INDEX parameter must be different. This helps ensure that sequence values are globally unique across multiple instances or databases.
We recommend that you do not perform the following operations: Use a group sequence prefixed with
AUTO_SEQ_
that is automatically associated with the table when the table is created to obtain NEXTVAL and insert the obtained value into the table as an explicit value by usingINSERT
. If you perform the preceding operation, the group sequence may frequently refresh the cache and quickly increase the value.
Time sequences
If you want to use a time sequence to generate values for an auto-increment column of a table, the data type of the column must be BIGINT.