Wednesday, 15 August 2012

Inserting in MySQL with PHP large amount of rows and autoincrementation ID -



Inserting in MySQL with PHP large amount of rows and autoincrementation ID -

i have 50k entries inserting in mysql via php. table simple id (autoincrementation), , few varchar fields...

since scheme allows multiple users login @ same time , same operation of inserting data, let's user1 starts "insert" , in same millisecond user2 starts inserting info in same table - curious if mysql wait user1 finish process , process user2 entries or insert simultaneously ?

so next logic user1 insert id's 1 50k , user2 50k-100k, or @ other hand shuffle them?

...and if "shuffling" there way prevent ?

p.s. know - can add together additional field user_id can distinguish user did actual "entry", in case reserve space 1-50k user1 , 50k-100k user2....

to reserve table , thereby auto increment ids should lock table before origin inserts. otherwise "shuffling" of ids likely.

note though nothing, locking, guarantees continuity of autoincrement ids. understand "a nice touch" have block of inserts continuous ids, that's not , there no guarantees in scheme create so. don't rely on or expect in way.

php mysql mysqli mysql-insert-id

No comments:

Post a Comment