key buffer(是myisam使用,具體參數爲myisam_sort_buffer_size)mysql
mdl cache (metadata_locks_cache_size)git
binlog cache
github
觀察SQL執行過程(有沒有建立臨時表等):
1.設置set profiling=1&set profiling_history_size=2
2.執行SQL(select benchmark(100000,pow(2,10));)
3.use information_schema;
3.select Query_ID,state,DURATION from PROFILING order by query_id desc limit 1;(8.0之前能夠直接用show profiles;查詢)算法
root@localhost [information_schema]>select benchmark(100000,pow(2,10)); +-----------------------------+ | benchmark(100000,pow(2,10)) | +-----------------------------+ | 0 | +-----------------------------+ 1 row in set (0.02 sec) root@localhost [information_schema]>select Query_ID,state,DURATION from PROFILING order by query_id desc limit 1; +----------+-------+----------+ | Query_ID | state | DURATION | +----------+-------+----------+ | 3 | init | 0.000024 | +----------+-------+----------+ 1 row in set, 1 warning (0.00 sec) root@localhost [information_schema]>show profiles; +----------+------------+------------------------------------------------------------------------------+ | Query_ID | Duration | Query | +----------+------------+------------------------------------------------------------------------------+ | 3 | 0.01043275 | select benchmark(100000,pow(2,10)) | | 4 | 0.00082200 | select Query_ID,state,DURATION from PROFILING order by query_id desc limit 1 | +----------+------------+------------------------------------------------------------------------------+ 2 rows in set, 1 warning (0.00 sec)
因此建議關閉
主要可瞭解存儲引擎:Innodb\TokuDB\MyRocks
|引擎名|特色|使用建議|
|-|-|
|InnoDB|支持事務,基於MVCC設計,索引組織表,只能有一個聚焦索引|在絕大多數場景建議使用此引擎,尤爲是OLTP|
|tokudb|支持事務,高壓縮,高速寫入|適用於基於時間有序數據的海量數據環境|
|MyIsam|早期版本引擎,堆表。在MariaDB用Aria替代,官方版本中也在減少對MyiSAM的使用|儘可能少使用MyISQL,MyISQL對CPU,內存,內存利用率不高,併發支持很差|
|inforbright,infinidb|列式存儲引擎,高壓縮,快速加載數據.|適用於OLAP環境|
|Memory|之內存爲存儲介質,請求速度高,但數據不安全|適用於數據安全要求不高的環境,如:臨時記數等|sql
1.查看plugin
查看plugin-dir參數設置,查找到plugin的存放位置(mysqladmin var|grep plugin_dir).
/usr/local/mysql/lib/plugin/
2.安裝plugin
mysql>install plugin rpl_semi_sync_master soname 'semisync_master.so'
3.刪除plugin
uninstall plugin rep_semi_sync_master;緩存
rockdb安全
引入性能計數器 show engine tokudb status ,更多選項。服務器
use syssession
統計根據索引的DML狀況:
select index_name,rows_selected,rows_inserted,rows_updated,rows_deleted from schema_index_statistics where table_schema='world' and table_name='city' and index_name='Conuntrycode';
|index_name|rows_selected|rows_inserted|rows_updated|rows_deleted|
|-|-|-|-|-|
|ID|18131|0|0|0|
|countrycode|2|0|0|0|併發
查看某個表的DML狀況:
root@localhost [sys]>select table_name,rows_fetched,rows_inserted,rows_updated,rows_deleted,io_read,io_read_requests,io_write,io_write_requests from schema_table_statistics where table_schema='wenyz' and table_name='t2'; +------------+--------------+---------------+--------------+--------------+-----------+------------------+----------+-------------------+ | table_name | rows_fetched | rows_inserted | rows_updated | rows_deleted | io_read | io_read_requests | io_write | io_write_requests | +------------+--------------+---------------+--------------+--------------+-----------+------------------+----------+-------------------+ | t2 | 68282 | 0 | 0 | 0 | 48.85 KiB | 10 | 0 bytes | 0 | +------------+--------------+---------------+--------------+--------------+-----------+------------------+----------+-------------------+ 1 row in set (0.01 sec)
select * from schema_redundant_indexes\G
root@localhost [sys]>select * from schema_tables_with_full_table_scans limit4; +---------------+-------------+-------------------+---------+ | object_schema | object_name | rows_full_scanned | latency | +---------------+-------------+-------------------+---------+ | wenyz | t2 | 68650 | 1.20 s | +---------------+-------------+-------------------+---------+ 1 row in set (0.00 sec)
root@localhost [sys]>select * from schema_table_statistics_with_buffer where table_schema='wenyz' and table_name='t2'\G; *************************** 1. row *************************** table_schema: wenyz table_name: t2 rows_fetched: 68866 fetch_latency: 1.21 s rows_inserted: 0 insert_latency: 0 ps rows_updated: 0 update_latency: 0 ps rows_deleted: 0 delete_latency: 0 ps io_read_requests: 10 io_read: 48.85 KiB io_read_latency: 2.10 ms io_write_requests: 0 io_write: 0 bytes io_write_latency: 0 ps io_misc_requests: 11 io_misc_latency: 111.24 us innodb_buffer_allocated: 16.00 KiB innodb_buffer_data: 14.36 KiB innodb_buffer_free: 1.64 KiB innodb_buffer_pages: 1 innodb_buffer_pages_hashed: 0 innodb_buffer_pages_old: 1 innodb_buffer_rows_cached: 362 1 row in set (0.05 sec)
select * from schema_table_lock_waits limit 4\G
nline DDL爲足的替代/補充工具
查詢分析日誌
#ps aux |grep mysql mysql 4279 9.4 80.9 23140516 19853348 ? Sl Sep12 7553:31 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf #pstack 4279> /tmp/pstack.txt ### pt-pmp /tmp/pstack.txt
pstack