Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: tidb的兼容性
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?
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. https://docs.pingcap.com/zh/tidb/stable/auto-increment#mysql-compatibility-mode
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?
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.
Our version is 6.5.0. Wouldn’t using auto_increment directly increase access hotspots?
Adding the AUTO_INCREMENT
attribute using ALTER TABLE
is not supported.
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?
Hmm… I didn’t mean to increase auto_increment, but to increase AUTO_ID_CACHE to 1.
It seems not supported, I encountered a syntax error during my test.
Oh, okay, thank you, boss.
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.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.