欢迎投稿

今日深度:

mysql优化之status和variables区别

mysql优化之status和variables区别


mysql之status和variables区别
 
首先可以通过下属两个命令来查看mysql的相应的系统参数

show status like '%abc%';

show variables like '%abc%';
 
但是很多人不明白二者到底有什么区别

status是状态是系统的状态不可更改,是系统现在的运行状态参数,说明如下:

mysql> show status like 'innodb_rows_%';

+----------------------+---------+ 
| Variable_name        | Value   | 
+----------------------+---------+ 
| Innodb_rows_deleted  | 0       | 
| Innodb_rows_inserted | 1169098 | 
| Innodb_rows_read     | 7955216 | 
| Innodb_rows_updated  | 0       | 
+----------------------+---------+ 

4 rows in set (0.00 sec) 

 一条条说明如下:
 
| Innodb_rows_deleted|0                  |  为innodb表删除的行数,此处为0标示没有删除过

| Innodb_rows_inserted | 1169098 | 为innodb表insert的行数,此处标示现在insert了1169098 行

| Innodb_rows_read     | 7955216    | 为innodb表执行select获取的行数

| Innodb_rows_updated  | 0              | 为innodb表执行update涉及到的行数

上述4个是innodb表的运行状态参数,不能人为修改,只能系统去update,用途很显然是为了告诉dba现在系统的状态,好让dba去做优化,上述4个记录告诉dba此时读大于写(我在执行insert into a select * from a,故出上述数据),可以考虑建立适当索引,如果读是0,写很大,那么可以考虑删除index等等。

mysql> show variables like 'query%';

+------------------------------+----------+ 
| Variable_name                | Value    | 
+------------------------------+----------+ 
| query_alloc_block_size       | 8192     | 
| query_cache_limit            | 1048576  | 
| query_cache_min_res_unit     | 4096     | 
| query_cache_size             | 16777216 | 
| query_cache_type             | ON       | 
| query_cache_wlock_invalidate | OFF      | 
| query_prealloc_size          | 8192     | 
+------------------------------+----------+ 

7 rows in set (0.00 sec) 

上述标示查看查询缓存的相关信息,此时可以根据status做适当的优化此处注意是系统管用cache的相关配置信息,是可以通过set或者修改配置文件来修改的。

您可能感兴趣的文章

  • mysql中tinyint、smallint、int和bigint类型的用法区别
  • mysql中优化sql语句查询的30种方法
  • mysql中null与not null的区别及效率问题
  • php中在变量和函数前加static关键字之后的区别
  • select into from 提示 Undeclared variable.....错误的解决办法
  • php中echo,print,print_r,var_export,var_dump 的用法与区别
  • MySQL数据库引擎MyISAM和InnoDB的区别介绍
  • javascript中scrollHeight,scrollWidth,scrollLeft,scrolltop等区别小解

www.htsjk.Com true http://www.htsjk.com/Mysql/10306.html NewsArticle mysql优化之status和variables区别 mysql之status和variables区别 首先可以通过下属两个命令来查看mysql的相应的系统参数 show status like '%abc%'; show variables like '%abc%'; 但是很多人不明白二者到底有什...
评论暂时关闭