How to Practice TiDB and Design Schema Primary Keys in Production

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

Original topic: TiDB和设计Schema主键的时候,生产中一般怎么实践

| username: redgame

How is TiDB and schema primary key design generally practiced in production?

| username: zhanggame1 | Original post link

The primary key can use AUTO_INCREMENT (auto-increment AUTO_ID_CACHE 1 can ensure unique auto-increment, not equal to 1 does not guarantee unique auto-increment), AUTO_RANDOM (random) or UUID, or custom primary keys, such as single-column unique non-null fields, or multi-column composite fields, etc. Each table can choose the most suitable one according to the specific business situation.

| username: tidb菜鸟一只 | Original post link

For the bigint type, autorandom, it’s best to split according to the number of TiKV nodes.

| username: Kongdom | Original post link

:thinking: Generally, it is based on the business, setting the most commonly used meaningful primary key.

| username: Anna | Original post link

For the bigint type, autorandom, it’s best to split according to the number of TiKV nodes.

| username: system | Original post link

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