definition of a deadlock:
- you lock table A
- another person locks table B
- You want to edit table B, but it's locked so you have to wait fo the lock to be released.
- The other person wants to edit table A, but he must wait for your lock to be released.
now you are waiting for him, and he is waiting for you: deadlock.
Proper databases like MS-SQL will refuse to do this and whoever came last get's an error.
"they may grab the same MAX(ID) + 1 from the table"
As you know, this is evil, a definate "you may not do this, never ever, not in your lifetime, not on this planet, never ever" it is punishable by maumau.
Every database has an auto_increment type, but real database call them 'serial' or 'sequence'. Beware that each database has a different way of retreiving this value after it has been generated.
Locking a table can speed up updates because you simply explude the rest of the world, you make the table single-user. You bet that's fast 🙂 But everyone else has to wait. So if you have 200 reads and one update, then all 200 reads have to wait for the one update to finish. Not good.
PS, every database takes care of locking, but real database like MS-SQL have row-level-locking wich means that they only lock what you are updating and nothing more than that.
And that means that you can update 1 record and leave all other records available for other people. Good stuff (only MYSQL 4.x+ support row-level-locking)
A forum, a FAQ, what else do you need?