List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:August 29 1999 2:50pm
Subject:Mysql internal locks are all exclusive?
View as plain text  
>>>>> "Jules" == Jules Bean <jules@stripped> writes:

Jules> I've just noticed that all mysql internal locks are exclusive.
Jules> I.e., if thread 1 has a lock on table_a, then thread 2, also accessing
Jules> table_a, blocks until thread 1 is done.

Jules> I would have thought that the obvious design is to allowed shared read
Jules> locks, but make write locks require exclusive access?

Jules> For example:

Jules> Query 1:

Jules> SELECT * from employees WHERE name LIKE '%Bloggs%';   # slow query,
Jules> requires table scan

Jules> Query 2:

Jules> SELECT * from employees WHERE name='Smith'l  # fast query, uses an
Jules> index.


Jules> Now, unless I'm misunderstanding badly, mysql will lock query 2 until
Jules> query 1 finishes.  I can see no reason that they shouldn't execute in
Jules> parallel (and then query 2 finishes much faster, query 1 slightly
Jules> slower).

Jules> Any plans in this direction?

Hi!

MySQL does allow multiple readers (and single writers).  If you have
some example that doesn't work as expected, please mail us about it!

Note however that some threads implementations (like BSDI:s) doesn't
balance between threads that good if you have a very CPU intensive
thread.

(MySQL 3.22.25 includes a fix for this for BSDI!)

Regards,
Monty

PS: Please ALWAYS use the mysqlbug script when you post questions !



Thread
Mysql internal locks are all exclusive?Jules Bean26 Aug
  • Mysql internal locks are all exclusive?Michael Widenius29 Aug
  • Re: Mysql internal locks are all exclusive?Jules Bean31 Aug
    • Re: Mysql internal locks are all exclusive?Michael Widenius31 Aug