标签:key erp backup rom 收购 场景 stack defaults amp
key buffer(是myisam使用,具体参数为myisam_sort_buffer_size)
mdl cache (metadata_locks_cache_size)
binlog cache
观察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|以内存为存储介质,请求速度高,但数据不安全|适用于数据安全要求不高的环境,如:临时记数等|
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 sys
统计根据索引的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
### mysql系统结构_3_Mysql_Learning_Notes
标签:key erp backup rom 收购 场景 stack defaults amp
原文地址:https://www.cnblogs.com/2woods/p/9956646.html