Lee,

Gleb is right. Conceptually, MySQL 'locks' every table that it uses in a SELECT query. The functions are ::store_lock() and ::external_lock(). But in the case of InnoDB, those table locks are very weak, they do not block anything.

Heikki
Oracle Corp./Innobase Oy
InnoDB - transactions, row level locking, and foreign keys for MySQL

InnoDB Hot Backup - a hot backup tool for InnoDB which also backs up MyISAM tables
http://www.innodb.com/order.php

.................
List:       mysql
Subject:    Re: Table_locks_immediate and Innodb Selects
From:       Gleb Paharenko <gleb.paharenko () ensita ! net>
Date:       2005-11-08 10:10:35
Message-ID: bl6643xdki.ln2 () blend ! ensita ! net
[Download message RAW]

Hello.

In my opinion, it is just for some statistics. The variable
locks_immediate (which corresponds to Table_locks_immediate) is
incremented very often in mysys/thr_lock.c in this way:
  statistic_increment(locks_immediate,&THR_LOCK_lock);




lee wrote:
Why would a simple select against an innodb db result in a bump of the \
table_locks_immediate variable? I've been debugging a different problem and I \ noticed this behavior. I don't believe it is a problem but can't explain the \
behavor and it seems odd.
Regards,
Lee

mysql> create table test (a char(1)) engine=innodb;
Query OK, 0 rows affected (0.14 sec)

mysql> flush status;
Query OK, 0 rows affected (0.07 sec)

mysql> show status like 'table_lock%';
+-----------------------+-------+
> Variable_name         | Value |
+-----------------------+-------+
> Table_locks_immediate | 0     |
> Table_locks_waited    | 0     |
+-----------------------+-------+
2 rows in set (0.07 sec)

mysql> select count(*) from test;
+----------+
> count(*) |
+----------+
> 0 |
+----------+
1 row in set (0.07 sec)

mysql> show status like 'table_lock%';
+-----------------------+-------+
> Variable_name         | Value |
+-----------------------+-------+
> Table_locks_immediate | 1     |
> Table_locks_waited    | 0     |
+-----------------------+-------+
2 rows in set (0.07 sec)


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to