If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Simultaneous Insterts

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-16-06, 22:56
rsvirani rsvirani is offline
Registered User
 
Join Date: Jul 2006
Posts: 5
Simultaneous Insterts

I have a customer who says that he has three people using my php form to insert a new record in a mysql table at the same time. He says that every once in a while, the data never inserts. Is it possible that two insert queries are being issued simultaneously and bouncing one out? In general, what is supposed to happen when two insert queries are executed at the same time on the same table?
Reply With Quote
  #2 (permalink)  
Old 10-17-06, 09:27
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
in general, one of them waits

if inserts are not happening, look at your php code and beef up the error reporting
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 10-17-06, 11:11
rsvirani rsvirani is offline
Registered User
 
Join Date: Jul 2006
Posts: 5
is this true even if the users are both the same? people are using the same form which connects to the db with the same username/pass? Or does the user not matter? Does the db go by resurce?
Reply With Quote
  #4 (permalink)  
Old 10-17-06, 11:17
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
why would you allow people to share username/passwords?

it doesn't matter, the inserts can happen only one at a time anyway
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 10-17-06, 14:51
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Quote:
Originally Posted by r937
in general, one of them waits
Are you saying that MySQL cannot do parallel inserts in two different transactions?
Why is the second one waiting?
There shouldn't be any locks created by an INSERT in another transaction (sounds like another of those MySQL gotchas...)
Reply With Quote
  #6 (permalink)  
Old 10-17-06, 15:08
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
for myisam tables, the table is locked for each operation -- so one of them waits

for innodb, mysql uses row level locking, so, yes, it's possible that two transactions can operate at the same time

i think

(i am not a DBA)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 10-17-06, 15:17
ASP-Hosting.ca ASP-Hosting.ca is offline
Registered User
 
Join Date: Apr 2004
Posts: 50
Quote:
Originally Posted by shammat
Are you saying that MySQL cannot do parallel inserts in two different transactions?
Why is the second one waiting?
There shouldn't be any locks created by an INSERT in another transaction (sounds like another of those MySQL gotchas...)
You can't do transactions with myisam tables, and this is the table type most people use, because it's faster than innodb.

read this for more info on MySQL table locking:

http://dev.mysql.com/doc/refman/5.0/...l-locking.html
Reply With Quote
  #8 (permalink)  
Old 10-17-06, 16:13
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Quote:
Originally Posted by ASP-Hosting.ca
You can't do transactions with myisam tables, and this is the table type most people use, because it's faster than innodb.
Faster is relative. If you have a lot of concurrent updates, this doesn't sound faster.

I always forget that MySQL has this flat-file mode

Thanks for the link. I'll have a look at it.
Reply With Quote
  #9 (permalink)  
Old 10-19-06, 23:04
rsvirani rsvirani is offline
Registered User
 
Join Date: Jul 2006
Posts: 5
So basically, there is no way an entry could be totally disregarded right? Just to reiterate, I have a php form that connects to the mysql db and inserts a new row in a specific table. The table type is myisam. The form is using one username and password to connect as all forms do. If there are 3 people simultaneously inserting (submitting the form that inserts a new row), is it possible that one of those inserts just doesn’t happen? There is no error being sent back by mysql. All is normal, but the data isn’t there. Is this possible? Or does one connection wait for the current to finish, then also get executed? My tables are queried against between 100-1000 times a day. Should I convert to innoDB? what sort of performance loss will occur? Are there any code, sql command changes that need to happen if I do convert? Why does row level locking affect my case? I am not updating a row, I am inserting new ones. Thank you all for your input, I'm glad to have such experienced people discussing this issue.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On