MySQL/MariaDB的response time插件
生活随笔
收集整理的這篇文章主要介紹了
MySQL/MariaDB的response time插件
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
“響應(yīng)時(shí)間”是衡量數(shù)據(jù)庫性能的常用指標(biāo)。在MariaDB中可以使用插件“QUERY_RESPONSE_TIME”來獲取查詢時(shí)間區(qū)間的統(tǒng)計(jì)信息。// 安裝插 件
$ 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 | +-------------------------------+----------+--------------------+------------------------+---------+
// 參數(shù)說明
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
// 打開統(tǒng)計(jì)
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個(gè)查詢的執(zhí)行時(shí)間在0.000010秒<query execution time < =0.000100秒這個(gè)區(qū)間里;耗時(shí)總計(jì)0.002200秒。
有16個(gè)查詢的執(zhí)行時(shí)間在0.000100秒<query execution time < =0.001000秒這個(gè)區(qū)間里;耗時(shí)總計(jì)0.005615秒。
轉(zhuǎn)載于:https://my.oschina.net/liuliufa/blog/645377
總結(jié)
以上是生活随笔為你收集整理的MySQL/MariaDB的response time插件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在子线程更新主线程的UI组件
- 下一篇: [LeetCode]题解(python)