How much is insert_id affected by concurrency in mysql?

the user inserts the data and gets the self-growing id, $db- > insert_id.

can accurate id? be obtained once concurrency occurs

Php
Mar.04,2021

is unaffected. Insert_id is associated with a specific link. It returns the id of the last insert operation performed by a specific connection
different database connections while insert does not interfere with insert_id


for example,
the content of the php file is

.
<?php
    $ip=$_SERVER["REMOTE_ADDR"];;
    echo $ip;

A. User, B user, will A user echo to B user's value when they turn on A user at the same time?


do the redis queue, and then store the id in mysql, one by one from redis to get the id and return it to the corresponding user. In the case of a large amount of concurrency, you can limit the operation once in several seconds, but the user needs to wait a few seconds


@ @ IDENTITY in

SQL server is thread safe.

< H2 > will not appear: < / H2 >

if you query the data again after insertion, you may not get the correct ID,. If two users insert data at the same time, the order is
user1: do insert
user2: do insert
user1: do query
user2: do query

. The id obtained by

user1 is

of user2. < hr >

such a situation.

you can check SQL server's help.

The lock of

mysql is maintained by mysql, and the insert, for the primary key id has nothing to do with the language. Don't worry about repetition.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaa9c9-1fe9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaa9c9-1fe9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?