Can TiDB ensure that the IDs obtained later with an auto-increment primary key are always larger than those obtained earlier?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb是否能保证自增主键auto_increment后期获取到的ID一定比之前获取到的大

| username: Running

Can TiDB ensure that the IDs obtained later with an auto-increment primary key are always larger than those obtained earlier?

| username: Kongdom | Original post link

Support


| username: 啦啦啦啦啦 | Original post link

I remember starting from version 6.5, it supports global monotonic increment.

| username: 胡杨树旁 | Original post link

The official documentation states that it is auto-increment but does not guarantee continuity.

| username: zhimadi | Original post link

Starting from v6.4.0, TiDB has implemented a centralized service for allocating auto-increment IDs, allowing TiDB instances to not cache data but instead access the centralized service to obtain an ID for each request.
In MySQL compatibility mode, you can set AUTO_ID_CACHE to 1 when creating a table:

| username: Running | Original post link

Auto-increment but not continuous, can it be understood as each value obtained is definitely greater than the previous one? As long as this can be guaranteed, it’s fine.

| username: Running | Original post link

Are there any related articles or guides? Most of them talk about single instances.

| username: 胡杨树旁 | Original post link

Tested, it is like this. Each tidb_server node maintains this pattern.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.