“响应时间”是衡量数据库性能的常用指标。在MariaDB中可以使用插件“QUERY_RESPONSE_TIME”来获取查询时间区间的统计信息。 

// 安装插 

$ cd ${mysql_base}/lib/plugin
$ ll
-rw-r--r--. 1 root root 403898 Feb 25 01:15 query_response_time.so

MariaDB [(none)]> install plugin query_response_time_audit soname 'query_response_time.so';

MariaDB [(none)]> install plugin query_response_time soname 'query_response_time.so';

MariaDB [(none)]> show plugins;

... | QUERY_RESPONSE_TIME_AUDIT | ACTIVE | AUDIT | query_response_time.so | GPL |

| QUERY_RESPONSE_TIME | ACTIVE | INFORMATION SCHEMA | query_response_time.so | GPL |

+-------------------------------+----------+--------------------+------------------------+---------+

// 参数说明

MariaDB [(none)]> show variables like 'query_response%';
+--------------------------------+-------+
| Variable_name | Value |
+--------------------------------+-------+
| query_response_time_flush | OFF |
| query_response_time_range_base | 10 |
| query_response_time_stats | OFF |
+--------------------------------+-------+
3 rows in set (0.00 sec)

query_response_time_flush

Description: Updating this variable flushes the statistics and re-reads query_response_time_range_base. 
Commandline: None 
Scope: Global 
Dynamic: Yes 
Data Type: boolean 
Default Value: OFF 

query_response_time_range_base 
Description: Select base of log for QUERY_RESPONSE_TIME ranges. WARNING: variable change takes affect only after flush. 
Commandline: --query-response-time-range-base=# 
Scope: Global 
Dynamic: Yes 
Data Type: numeric 
Default Value: 10 
Range: 2 to 1000 

if the range base=10, we have the following intervals: 
(0; 10 ^ -6], (10 ^ -6; 10 ^ -5], (10 ^ -5; 10 ^ -4], ...,  
  (10 ^ -1; 10 ^1], (10^1; 10^2]...(10^7; positive infinity] 

query_response_time_stats 
Description: Enable or disable query response time statistics collecting 
Commandline: query-response-time-stats[={0|1}] 
Scope: Global 
Dynamic: Yes 
Data Type: boolean 
Default Value: OFF 

// 打开统计

MariaDB [(none)]> set global query_response_time_stats = 1;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> set global query_response_time_flush='ON';
Query OK, 0 rows affected (0.00 sec)

MariaDB [information_schema]> select * from information_schema.QUERY_RESPONSE_TIME;
+----------------+-------+----------------+
| TIME | COUNT | TOTAL |
+----------------+-------+----------------+
| 0.000001 | 0 | 0.000000 |
| 0.000010 | 0 | 0.000000 |
| 0.000100 | 70 | 0.002200 |
| 0.001000 | 16 | 0.005615 |
| 0.010000 | 0 | 0.000000 |
| 0.100000 | 0 | 0.000000 |
| 1.000000 | 0 | 0.000000 |
| 10.000000 | 0 | 0.000000 |
| 100.000000 | 0 | 0.000000 |
| 1000.000000 | 0 | 0.000000 |
| 10000.000000 | 0 | 0.000000 |
| 100000.000000 | 0 | 0.000000 |
| 1000000.000000 | 0 | 0.000000 |
| TOO LONG | 0 | TOO LONG |
+----------------+-------+----------------+
14 rows in set (0.00 sec)

// 分析 
从上面的记录可知: 
有70个查询的执行时间在0.000010秒<query execution time < =0.000100秒这个区间里;耗时总计0.002200秒。 
有16个查询的执行时间在0.000100秒<query execution time < =0.001000秒这个区间里;耗时总计0.005615秒。

MariaDB的"response time"插件的更多相关文章

  1. mariadb介绍

    事务(Transaction):组织多个操作为一个整体,要么全部执行,要么全部不执行 “回滚” ,rollback SQL接口:sql语句分析器和优化器 表:为了满足范式设计要求,将一个数据集分拆为多 ...

  2. 【转】对Django框架架构和Request/Response处理流程的分析

    本文转载于疯狂的蚂蚁. 一. 处理过程的核心概念 如下图所示django的总览图,整体上把握以下django的组成: 核心在于中间件middleware,django所有的请求.返回都由中间件来完成. ...

  3. 关于数据库管理系统DBMS--关系型数据库(MySQL/MariaDB)

    数据库的结构(3种):层次,网状,关系型(用的最多): DBMS的三层模型: 视图层:面向最终用户: 逻辑层:面向程序员或DBA: 物理层:面向系统管理员: 关系型数据库管理系统——RDBMS: 主要 ...

  4. Mastering MariaDB 神秘的MariaDB 中文翻译版

    是某群的哥们义务翻译的,宣传一下,还没时间时间读,粗滤看了全部翻译完了300多页佩服 https://github.com/CMant/Mastering-MariaDB- 原地址:如果你需要读,请s ...

  5. 【RDB】MariaDB 之事务、复制、集群

    目录 简介 安装启动 权限 事务 脏读.不可重复读.幻读 MVCC 复制 异步复制 半同步复制 GTID复制 集群(Galera) 配置 监控(Zabbix) 简介 环境: CentOS 7.4.17 ...

  6. 对Django框架架构和Request/Response处理流程的分析(转)

    原文:http://blog.sina.com.cn/s/blog_8a18c33d010182ts.html 一. 处理过程的核心概念 如下图所示django的总览图,整体上把握以下django的组 ...

  7. 对django框架架构和request/response处理流程的分析

    一. 处理过程的核心概念 如下图所示django的总览图,整体上把握以下django的组成: 核心在于中间件middleware,django所有的请求.返回都由中间件来完成. 中间件,就是处理HTT ...

  8. [MySQL Reference Manual] 6 安全性

    6. 安全性 在Mysql安装配置时要考虑安全性的影响,以下几点: Ÿ   常规因素影响安全性 Ÿ   程序自身安全性 Ÿ   数据库内部的安全性,即,访问控制 Ÿ   网络安全性和系统安全性 Ÿ   ...

  9. mysql之一

    MySQL or MariaDB 简介 DBMS:数据库管理系统 RDBMS:关系型数据库管理系统    总之:他们都是一个数据管理程序:大多都是CS架构,都有专门的通信协议进行数据交换 关系模型: ...

随机推荐

  1. MongoDB 数据库备份与恢复

    1.MongoDB数据库备份     1.语法:         mongodump -h dbhost -d dbname -o dbdirectory         参数说明:         ...

  2. intellij 打开node项目 一直停留在scanning files to index....,或跳出内存不够的提示框

    说明: 在npm install 后,会出现Scanning files to index ...... 出现这个是正常的,但是一直不消失就不正常了.原因是npm install 后 node_mod ...

  3. .Net 关于 InfoPath 的基本使用

    最近几天接触微软的  InfoPath 表单工具,结合VS 使用,遇到的一些问题与解决方法,记录一下,百度上的内容很少,或许我根本不知道咋搜,所有也留一个网页帮助自己使用当然使用的时候碰到了好几个坑: ...

  4. 《深入浅出Netty》【PDF】下载

    <深入浅出Netty>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230062563 内容简介 本文档主要讲述的是深入浅出Netty: ...

  5. 【java】对象变成垃圾被垃圾回收器gc收回前执行的操作:Object类的protected void finalize() throws Throwable

    package 对象被回收前执行的操作; class A{ @Override protected void finalize() throws Throwable { System.out.prin ...

  6. java显示目录文件列表和删除目录

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...

  7. iOS自定义文字高度添加行间距

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000 } span.s1 { } span.s2 { c ...

  8. (一)基于阿里云的MQTT远程控制(Android 连接MQTT服务器,ESP8266连接MQTT服务器实现远程通信控制----简单的连接通信)

    如果不了解MQTT的可以看这篇文章  http://www.cnblogs.com/yangfengwu/p/7764667.html http://www.cnblogs.com/yangfengw ...

  9. nova创建虚拟机源码分析系列之一 restful api

    开始学习openstack源码,源码文件多,分支不少.按照学习的方法走通一条线是最好的,而网上推荐的最多的就是nova创建虚机的过程.从这一条线入手,能够贯穿openstack核心服务.写博文仅做学习 ...

  10. 获取数据库时间sql 以及行级锁总结-共享锁-排他锁-死锁

    --TRUNC(date,[fmt]) /TRUNC(number[,decimals])SELECT SYSDATE FROM dual;SELECT TRUNC(SYSDATE) FROM dua ...