开启变量:默认是关闭的,它在内存中创建了几个HASH表
set global userstat=on;
set global thread_statistics=on;
查看索引使用情况:可以判断索引是否用到
select * from t where c1='a1' and c2='a2' and c5='a5' order by c2,c3;
SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t' and table_schema='test';
+--------------+------------+------------+-----------+
| TABLE_SCHEMA | TABLE_NAME | INDEX_NAME | ROWS_READ |
+--------------+------------+------------+-----------+
| test | t | idx_t_c1 | 18 |
+--------------+------------+------------+-----------+
ROWS_READ:从索引访问取的行数,是个累积值
set global userstat=on;
set global thread_statistics=on;
查看索引使用情况:可以判断索引是否用到
select * from t where c1='a1' and c2='a2' and c5='a5' order by c2,c3;
SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t' and table_schema='test';
+--------------+------------+------------+-----------+
| TABLE_SCHEMA | TABLE_NAME | INDEX_NAME | ROWS_READ |
+--------------+------------+------------+-----------+
| test | t | idx_t_c1 | 18 |
+--------------+------------+------------+-----------+
ROWS_READ:从索引访问取的行数,是个累积值
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/91975/viewspace-2103829/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/91975/viewspace-2103829/