1)查看MySQL全局占用多少内存
- SELECT (@@innodb_buffer_pool_size
- +@@innodb_log_buffer_size
- +@@key_buffer_size) / 1024 /1024 AS MEMORY_MB;
查询结果为:
- +----------------+
- | MEMORY_MB |
- +----------------+
- | 20512.00000000 |
- +----------------+
2)查看performance_schema占用多少内存
- SELECT SUBSTRING_INDEX(event_name,'/',2) AS
- code_area, sys.format_bytes(SUM(current_alloc))
- AS current_alloc
- FROM sys.x$memory_global_by_current_bytes
- GROUP BY SUBSTRING_INDEX(event_name,'/',2)
- ORDER BY SUM(current_alloc) DESC;
查询结果为:
- +---------------------------+---------------+
- | code_area | current_alloc |
- +---------------------------+---------------+
- | memory/performance_schema | 349.80 MiB |
- +---------------------------+---------------+
3)查看每个线程占用多少内存
- SELECT ( ( @@read_buffer_size
- + @@read_rnd_buffer_size
- + @@sort_buffer_size
- + @@join_buffer_size
- + @@binlog_cache_size
- + @@thread_stack
- + @@max_allowed_packet
- + @@net_buffer_length )
- ) / (1024*1024) AS MEMORY_MB;
查询结果为:
- +-----------+
- | MEMORY_MB |
- +-----------+
- | 87.5156 |
- +-----------+
查看当前线程
- show full processlist
(编辑:晋中站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|