开发者

Parallel writing to MySQL Database table - Will cause any problems?

I am having a PHP script, which starts another php script multiple times in an foreach loop. The other p开发者_JAVA技巧hp scripts writes data to the same database table.

Will this cause any problems, because there will be around 30 processes writing to the same database table...

Or is this automatically handeled by MySQL ?

Thanks you!

Bye, WorldSignia


It depends on what you are writing. INSERT can be used simultaneously. UPDATE ... WHERE ... might lead to conflicts.

Imagine you are executing UPDATE ... WHERE id=2 from two scripts at once. One might overwrite the other. You need to implement some locking facility.


You should be fine until two processes attempt to modify/retreive the same row(s). If you suspect you might run into such problems, you may take a look at mysql transactions(You need mysql server 5 or later for it) http://dev.mysql.com/doc/refman/5.0/en/commit.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜