Jump to content
Sign in to follow this  
ala888

is it safe to assume that auto_increment is atomic during select?

Recommended Posts

Is it safe to assume that auto_increment is atomic during select operations?

example, If I insert 1000 rows instantly (hypothetically), okay, I know that auto_increment will increment one by one. but can I be sure that ALL select operations during, before, after this insert will always show auto_increment (10) before auto_increment (20) ?

 

Like for some arbitrary optimization reason, even though a row with auto_increment (1) exists, the select operation will get 1,2,3..9,11,20

before a millisecond later 1,2,3,9,10,11,20 ?

 

Or will this never occur?

Share this post


Link to post
Share on other sites

The database doesn't count all of the rows that are going to be inserted and then starts inserting them in a random order, it will just sequentially insert rows as it gets to them. So yes, it will use lower numbers first.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...