Temporarily lock the innoDB table

I am doing large inserts of several thousand rows in my current web application and I would like to make sure that nobody else can do anything other than read the table until the inserts are done.

What's the best way to do this while keeping read accessibility available to regular non-admin users?

Thanks!

+2


a source to share


3 answers


You may also need to change the default isolation level:



 set transaction isolation level serializable;
 start transaction;
 // insert data
 commit

      

+2


a source


Since you are only inserting (not updating) this shouldn't be a problem. Just insert records in one transaction.



InnoDB supports row level locking, if I recall correctly, so even updates shouldn't be a problem.

+2


a source


Why not just insert one large transaction? This could prevent the need for blocking.

+1


a source







All Articles