I got a query inserting some data into a table. The query has a join to another table. Will this other table be locked while the query is running?
-e-
here is a query like the one i'm using:
INSERT INTO table_1
SELECT t3.first_row,
t3.second_row
FROM table_2 t2
INNER JOIN
table_3 t3
ON t2.t3_fk = t3.id
WHERE t3.id IN (1, 2, 3, 4)
AND t2.created_at <= '2014-12-21 22:59:59'
The query is running in a rails transaction.
it will be locked while inserting. Insertion through transaction will be much better.
I found a solution. When setting transaction-isolation= to "READ-COMMITTED", read statements won't lock a table.
See: http://harrison-fisk.blogspot.ch/2009/02/my-favorite-new-feature-of-mysql-51.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.