MySQL Forums
Forum List  »  InnoDB

Do SELECT statements create some kind of row/table lock?
Posted by: David Hicks
Date: December 02, 2012 07:04PM

I have encountered a situation in which it "appears" as if a SELECT is creating some kind of lock that blocks other sessions on a particular table. Here is the scenario.

I have a table with a large number of rows (more than 14 million) and 4 indexes. (Yes, I understand that this is not optimal for what should be a transaction-oriented system. I'll be dealing with that soon enough.) I am building a support table based on data in this large table. During that process, I use a correlated subquery to find data in this very large data and use it to update columns in my support table. Meanwhile, other sessions are inserting new rows into this very large table. When all this is going on, I can start up innotop and observe that the INSERT transactions are blocking and timing out. As soon as my UPDATE with the correlated subquery finishes, the blocking no longer seems to occur.

I thought I understood that SELECT statements (such as the one in the correlated subquery) would not produce any kind of blocking locks on the table, but this isn't consistent with what I'm witnessing.

Do I misunderstand the locking model? Or, is there some other possible explanation that I'm not thinking of?

Thanks,
Dave

Options: ReplyQuote


Subject
Views
Written By
Posted
Do SELECT statements create some kind of row/table lock?
1802
December 02, 2012 07:04PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.