Reputation: 567
I'm no database guru, so I'm curious if a table lock is necessary in the following circumstance:
Relevant DB Columns (exp_channel_titles)
My Hypothetical Solution -- is table locking required here?
Let's say there are 100 entries in the table, and each entry in the table has a url_title like entry_1, entry_2, entry_3, etc., all the way to entry_100. Each time a user adds an entry, my script would do something like this:
Since my database knowledge is limited, I don't know if I need to worry about locking here. What if a thousand people try to add entries to the database within a 10 second period? Does MySQL automatically handle this, or do I need to lock the table while each new entry is added, to ensure each entry has the correct id?
Running on the MyISAM engine, if that makes a difference.
Upvotes: 2
Views: 439
Reputation: 14149
I think you should look at one of two approaches:
AUTO_INCREMENT
column to assign the idUpvotes: 1