MySQL Forums
Forum List  »  General

Re: Is it best practice to lock table for every Mysql query?
Posted by: Craig Liu
Date: December 21, 2018 03:03PM

Thank Peter. Because it is still difficult for us to convince others that lock tables are necessary for even pure SELECT query.

For example, we have a simple query:
SELECT * FROM t1 LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c)

Why we have to use this:
lock tables t1,t2,t3,t4 READ;
SELECT * FROM t1 LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c);
unlock tables;

Is it a best practice for lock tables (MyISAM) before run a Select query?

Options: ReplyQuote




Sorry, only registered users may post in this forum.

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.