Compatibility of TiDB

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

Original topic: tidb的兼容性

| username: 烂番薯0

Hello everyone, I have a question. Our production MySQL table has an auto-increment column, AUTO_INCREMENT. I want to use TiDB’s built-in DM for full data synchronization, but TiDB recommends using compatibility mode. I want to ask, if I first use DM to import data, how do I later change the table to compatibility mode? How do I add a new field, AUTO_ID_CACHE 1? Also, if I don’t change it, will it have a significant impact?

| username: wzf0072 | Original post link

After using MySQL compatibility mode, it can ensure that IDs are unique and monotonically increasing, with behavior almost completely consistent with MySQL. Even when accessing across TiDB instances, IDs will not roll back. Only when the centralized service’s “primary” TiDB instance crashes abnormally, there might be a small number of non-continuous IDs. This is because during the primary-secondary switch, the “secondary” node needs to discard some IDs that the previous “primary” node might have already allocated to ensure no duplicate IDs.

| username: 烂番薯0 | Original post link

Brother, I mean if I use DM for full import, should I create the table on TiDB now? Or can I modify the table and add AUTO_ID_CACHE = 1 after the import is complete?

| username: tidb狂热爱好者 | Original post link

For versions 6.5 and above, you can directly use auto_increment. For versions below, no changes are needed either. It’s just that the auto-increment for this table might skip, but it doesn’t affect anything. Don’t rely on auto-increment for sorting.

| username: 烂番薯0 | Original post link

Our version is 6.5.0. Wouldn’t using auto_increment directly increase access hotspots?

| username: wzf0072 | Original post link

Adding the AUTO_INCREMENT attribute using ALTER TABLE is not supported.

| username: 烂番薯0 | Original post link

Boss, our auto-increment is used as the main criterion. Is there any way to ensure that this auto-increment still exists and preferably does not change?

| username: 烂番薯0 | Original post link

Hmm… I didn’t mean to increase auto_increment, but to increase AUTO_ID_CACHE to 1.

| username: wzf0072 | Original post link

It seems not supported, I encountered a syntax error during my test.

| username: 烂番薯0 | Original post link

Oh, okay, thank you, boss.

| username: 小气鬼1105 | Original post link

First, create the table and change the auto-increment primary key to a unique key or a regular primary key, then use DM to import the data.

| username: system | Original post link

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