SHOW OPEN TABLES – what is in your table cache
One command, which few people realize exists is SHOW OPEN TABLES – it allows you to examine what tables do you have open right now:
mysql> show open tables from test;
+----------+-------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+-------+--------+-------------+
| test | a | 3 | 0 |
+----------+-------+--------+-------------+
1 row in set (0.00 sec)
This command lists all non-temporary tables in the table-cache, showing each of them only once (even if table is opened more than ones)
In_use show how many threads are currently using this table, meaning have it locked or waiting on the table lock for this table to lock it.
Name_locked shows whenever the name for this table is locked. It is used for DROP or RENAME TABLE, so you would very rarely see this field to contain anything else than 0.
Besides just figuring out what tables are in the table_cache this command is rather helpful to understand if there is activity on the given table. Just run “FLUSH TABLES mytable” and examine open tables later – if you see this table in table cache again chances are it is being used.
Note however if you’re starting MySQL Command line client without “-A” option it opens all tables in the active database to allow tab completion which can screw results.
Another use for this command is pre-flush implementation (as part of your backup routine) – instead of running FLUSH TABLES on ALL tables one by one you can run SHOW OPEN TABLES and flush only open tables, when run it again and see how many tables are open and in use and if FLUSH TABLES WITH READ LOCK can be run or not.
Unfortunately this command does not really help to answer the very common question you may have during table lock troubleshooting – who is holding lock for this table ?
I would much rather see all entries in the table_cache used, not grouped by the table, with thread_id using the table set (0 if table is not in use), lock_type READ/WRITE/READ_LOCAL etc as well as whenever the thread is looking for lock right now.
It also deserves to be converted to INFORMATION_SCHEMA table – so it would be easily to operate it using SQL commands.
Another thing which would be handly is LRU position for the given table (so you can see what tables are candidates for replacement) and the timestamp when this table was locked (or lock wait started) – MySQL anyway initializes the timer so it would not be much overhead to store that time together in the table cache. This could allow to understand table locks much better.
转自:http://www.mysqlperformanceblog.com/2008/12/14/show-open-tables-what-is-in-your-table-cache/
SHOW OPEN TABLES – what is in your table cache的更多相关文章
- detecting locked tables mysql (locked by LOCK TABLE)
detecting locked tables mysql (locked by LOCK TABLE) up vote15down votefavorite 7 I would like to kn ...
- 如何安全地关闭MySQL实例
如何安全地关闭MySQL实例 转载自:http://imysql.com/2014/08/13/mysql-faq-howto-shutdown-mysqld-fulgraceful.shtml 本文 ...
- MySQL优化之——安全地关闭MySQL实例
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46812371 关闭过程: 1.发起shutdown,发出 SIGTERM信号 2 ...
- 安全关闭MySQL
想要安全关闭 mysqld 服务进程,建议按照下面的步骤来进行: 0.用具有SUPER.ALL等最高权限的账号连接MySQL,最好是用 unix socket 方式连接: 1.在5.0及以上版本,设置 ...
- MySQL/MariaDB数据库的服务器配置
MySQL/MariaDB数据库的服务器配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.MySQL中的系统数据库 1>.mysql数据库 是mysql的核心数据库,类 ...
- People Tools catalog tables.
People Tools catalog tables. Projects PSPROJECTDEFN — Project header table PSPROJECTITEM — Definitio ...
- Table of Contents ---BCM
Table of ContentsAbout This Document................................................................ ...
- zstu.2512. Moving Tables(贪心)
Moving Tables Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1182 Solved: 563 Description The famo ...
- DB2 for z: system catalog tables
http://www.ibm.com/support/knowledgecenter/SSEPEK_10.0.0/com.ibm.db2z10.doc.sqlref/src/tpc/db2z_cata ...
随机推荐
- windows8.1 plsql连接oracle
http://pan.baidu.com/share/link?shareid=3782452820&uk=3557941237 http://pan.baidu.com/share/link ...
- # 20145210 《Java程序设计》第05周学习总结
教材学习内容总结 第八章 异常处理 8.1语法与继承架构 •使用 try.catch •Java中所有信息都会被打包为对象,如果愿意,可以尝试(try)捕捉(catch)代表错误的对象后做一些处理 • ...
- HDU 5093
http://acm.hdu.edu.cn/showproblem.php?pid=5093 二分图最大匹配的经典建图模型,行列分别缩点(连起来的'*' & 'o'),交集有'*'就连边 #i ...
- inno安装卸载时检测程序是否正在运行卸载完成后自动打开网页-代码无效
inno安装卸载时检测程序是否正在运行卸载完成后自动打开网页-代码无效 inno setup 安装卸载时检测程序是佛正在运行卸载完成后自动打开网页-代码无效 --------------------- ...
- [转]LUA 学习笔记
Lua 学习笔记 入门级 一.环境配置 方式一: 1.资源下载http://www.lua.org/download.html 2.用src中的源码创建了一个工程,注释调luac.c中main函数,生 ...
- CentOS下启动Tomcat
http://tianlihu.iteye.com/blog/2010028 1. Tomcat的部署包存放的路径 /var/lib/tomcat6/webapps/ 2. Tomcat的配置文件路 ...
- i++为什么没有自增探析——JVM中i++的实现(转)
很多朋友在使用Java时候会发现一个很奇怪的现象. 那就是使用下列的短句时会发现i没有自增,这是很让人迷惑的,因为大家印象中,虽然i++优先级较低,但是总是会自增的,这里为什么i++没有自增? i=i ...
- MyBatis对应的xml的数据类型
MyBatis对应的xml的数据类型 JDBC Type Java TypeCHAR StringVARCHAR StringLONGVARCHAR StringNUMERIC java.math.B ...
- PostgresSQL 学习资料记录处
PostgresSQL 学习资料记录处 博客:http://francs3.blog.163.com PostgreSQL9.4 中文手册:http://www.postgres.cn/docs/9 ...
- hdu 3666 Making the Grade
题目大意 给出了一列数,要求通过修改某些值,使得最终这列数变成有序的序列,非增或者非减的,求最小的修改量. 分析 首先我们会发现,最终修改后,或者和前一个数字一样,或者和后一个数字一样,这样才能修改量 ...