What would happen if I was to insert say 1000 rows (taking 20 seconds, but one query). After 2 seconds someone else tried to insert a row at the same location e.g.
20secondquery
1|yellow
2|blue
3|green
4|violet
2secondquery
4|blue
Would their row be inserted or would it queue until my insert was finished?
(MyISAM)
Depends on what sort of transactions and/or locking you’re using.
If someone issues a single big INSERT statement, that will complete atomically as a single operation. If they are spamming a whole bunch of INSERTS, then the secondquery will fall in between those.
You need to look into Table Locking to control this sort of thing.
For the time between the
LOCK TABLESandUNLOCK TABLESnothing else will be able to read or write to the table.