MySQL Forums
Forum List  »  General

Re: AUTO_INCREMENT seeding not working intermittently
Posted by: Rick James
Date: October 16, 2014 08:17AM

InnoDB? MyISAM? (It may make a difference.)
Was the server restarted between the ALTER and the first INSERT? (It probably makes a difference.)
Did you DELETE or REPLACE any rows? (It may make a difference.)
Are you ROLLBACKing any transactions? (That 'burns' an id.)

I ask all those questions (and more?) because they have an impact on AI calculation, and in an ENGINE-dependent manner. For example:
After a restart, the next AI will be MAX(id)+1.

As a workaround:
Skip the ALTER. Instead, INSERT a row with an explicit id=499999 just before doing the real INSERTs. Optionally DELETE it, but not until after some INSERTs have been done.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.