Innodb auto-incrementing key. Is there any way to solve the id inconsistency caused by transaction rollback?

Source: Internet
Author: User
Describe your problem. For example, paste the relevant code and error information. paste the relevant information. Which methods have been tried? Still not solved? (attach the relevant link)
  1. Describe your problem
    Example

  2. Paste related Code

  3. Post error message

  4. Labeling

  5. Methods that have been tried are still not resolved (attached with the relevant link)

Reply content:
  1. Describe your problem
    Example

  2. Paste related Code

  3. Post error message

  4. Labeling

  5. Methods that have been tried are still not resolved (attached with the relevant link)

Auto-increment id, if it is also transactional, will easily lead to blocking. Therefore, it is designed because if the business needs to be continuous, You can manually assign id through count and so on when inserting instead of auto-increment.

Why do IDs need to be continuous? uniqueness is king.

It clearly tells you that there is no way.
The primary key of mysql is maintained in the memory. Once a fault occurs, it cannot be repaired. Why must it be continuous? Jie Li?

If you really want to keep IDs consecutively, you can roll back the discarded ID and save it for the next time.

However, I think the IDS also represent the time sequence of database insertion to a certain extent. After reuse, the order is messy...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.