I make bigger inserts consisting of a couple of thousand rows in my current web app and I would like to make sure that no one can do anything but read the table, until the insert开发者_开发知识库s have been done.
What is the best way to do this while keeping the read availability open for normal, non-admin users?
Thanks!
You may also need to change default isolation level:
set transaction isolation level serializable;
start transaction;
// insert data
commit
Since you're only inserting (not updating) this shouldn't be a problem. Just insert the records in a single transaction.
InnoDB supports row level locking if I recall correctly so even updates shouldn't be a problem.
Why not just do the insert in one big transaction? That would kind of prevent the need for any locking.
精彩评论